source: orange/Orange/__init__.py @ 10827:8527a7511c4f

Revision 10827:8527a7511c4f, 4.1 KB checked in by mitar, 2 years ago (diff)

Support for widgets loading from modules, registered through entry point.

Line 
1from __future__ import absolute_import
2
3__version__ = "2.6a1"
4
5ADDONS_ENTRY_POINT = 'orange.addons'
6
7from . import orange
8
9# Definitely ugly, but I see no other workaround.
10# When, e.g. data.io executes "from orange import ExampleTable"
11# orange gets imported again since it is not in sys.modules
12# before this entire file is executed
13import sys
14sys.modules["orange"] = orange
15
16# Little trick so that legacy imports work automatically
17import Orange.orng
18sys.path = Orange.orng.__path__ + sys.path
19
20import warnings
21import pkg_resources
22
23alreadyWarned = False
24disabledMsg = "Some features will be disabled due to failing modules\n"
25def _import(name):
26    global alreadyWarned
27    try:
28        __import__(name, globals(), locals(), [], -1)
29    except ImportError, err:
30        warnings.warn("%sImporting '%s' failed: %s" %
31            (disabledMsg if not alreadyWarned else "", name, err),
32            UserWarning, 2)
33        alreadyWarned = True
34
35def _import_addons():
36    globals_dict = globals()
37    for entry_point in pkg_resources.iter_entry_points(ADDONS_ENTRY_POINT):
38        try:
39            module = entry_point.load()
40            if '.' not in entry_point.name:
41                globals_dict[entry_point.name] = module
42            sys.modules['Orange.%s' % (entry_point.name,)] = module
43        except ImportError, err:
44            warnings.warn("Importing add-on '%s' failed: %s" % (entry_point.name, err), UserWarning, 2)
45
46_import("utils")
47
48_import("data")
49_import("data.io")
50_import("data.sample")
51_import("data.outliers")
52_import("data.preprocess")
53_import("data.preprocess.scaling")
54_import("data.utils")
55_import("data.discretization")
56_import("data.continuization")
57_import("data.filter")
58_import("data.imputation")
59
60_import("feature")
61_import("feature.construction")
62_import("feature.construction.functionDecomposition")
63_import("feature.construction.univariate")
64_import("feature.discretization")
65_import("feature.imputation")
66_import("feature.scoring")
67_import("feature.selection")
68
69_import("network")
70
71_import("stat")
72
73_import("statistics")
74_import("statistics.estimate")
75_import("statistics.contingency")
76_import("statistics.distribution")
77_import("statistics.basic")
78_import("statistics.evd")
79
80_import("classification")
81_import("classification.tree")
82
83_import("classification.rules")
84
85_import("classification.lookup")
86_import("classification.bayes")
87_import("classification.svm")
88_import("classification.logreg")
89_import("classification.knn")
90_import("classification.majority")
91
92_import("tuning")
93
94_import("projection")
95_import("projection.linear")
96_import("projection.mds")
97_import("projection.som")
98
99_import("ensemble")
100_import("ensemble.bagging")
101_import("ensemble.boosting")
102_import("ensemble.forest")
103_import("ensemble.stacking")
104
105_import("regression")
106_import("regression.base")
107_import("regression.earth")
108_import("regression.lasso")
109_import("regression.linear")
110_import("regression.mean")
111_import("regression.pls")
112_import("regression.tree")
113
114_import("multitarget")
115_import("multitarget.tree")
116
117_import("multilabel")
118_import("multilabel.multibase")
119_import("multilabel.br")
120_import("multilabel.lp")
121_import("multilabel.mlknn")
122_import("multilabel.brknn")
123_import("multilabel.mulan")
124
125_import("associate")
126
127_import("distance")
128
129_import("wrappers")
130
131_import("featureConstruction")
132_import("featureConstruction.univariate")
133_import("featureConstruction.functionDecomposition")
134
135_import("evaluation")
136_import("evaluation.scoring")
137_import("evaluation.testing")
138_import("evaluation.reliability")
139
140_import("clustering")
141_import("clustering.kmeans")
142_import("clustering.hierarchical")
143_import("clustering.consensus")
144
145_import("misc")
146
147_import("utils") #TODO hide utils from the user
148_import("utils.environ")
149_import("utils.counters")
150_import("utils.addons")
151_import("utils.render")
152_import("utils.serverfiles")
153
154_import_addons()
155
156try:
157    from . import version
158    # Always use short_version here (see PEP 386)
159    __version__ = version.short_version
160    __hg_revision__ = version.hg_revision
161except ImportError:
162    # Leave the default version defined at the top.
163    pass
164
165del _import
166del _import_addons
167del alreadyWarned
168del disabledMsg
Note: See TracBrowser for help on using the repository browser.