1# This module is a mixture of imports and code, so we allow import anywhere
2# pylint: disable=wrong-import-position,wrong-import-order
3
4from Orange import data
5
6from .misc.lazy_module import _LazyModule
7from .misc.datasets import _DatasetInfo
8from .version import \
9    short_version as __version__, git_revision as __git_version__
10
11ADDONS_ENTRY_POINT = 'orange.addons'
12
13for mod_name in ['classification', 'clustering', 'distance', 'ensembles',
14                 'evaluation', 'misc', 'modelling', 'preprocess', 'projection',
15                 'regression', 'statistics', 'version', 'widgets']:
16    globals()[mod_name] = _LazyModule(mod_name)
17
18datasets = _DatasetInfo()
19
20del mod_name
21
22# If Qt is available (GUI) and Qt5, install backport for PyQt4 imports
23try:
24    import AnyQt.importhooks
25except ImportError:
26    pass
27else:
28    if AnyQt.USED_API == "pyqt5":
29        # Make the chosen PyQt version pinned
30        from AnyQt.QtCore import QObject
31        del QObject
32
33        import pyqtgraph  # import pyqtgraph first so that it can detect Qt5
34        del pyqtgraph
35
36        AnyQt.importhooks.install_backport_hook('pyqt4')
37    del AnyQt
38
39
40# A hack that prevents segmentation fault with Nvidia drives on Linux if Qt's browser window
41# is shown (seen in https://github.com/spyder-ide/spyder/pull/7029/files)
42try:
43    import ctypes
44    ctypes.CDLL("libGL.so.1", mode=ctypes.RTLD_GLOBAL)
45except:  # pylint: disable=bare-except
46    pass
47finally:
48    del ctypes
49