forked from threeML/threeML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
136 lines (98 loc) · 3.38 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python
import os
import sys
import glob
from setuptools import setup
import versioneer
# This dynamically loads a module and return it in a variable.
# Will use it for check optional dependencies
def is_module_available(module_name):
# Fast path: see if the module has already been imported.
try:
exec("import %s" % module_name)
except ImportError:
return False
else:
return True
# Create list of data files
def find_data_files(directory):
paths = []
for (path, directories, filenames) in os.walk(directory):
for filename in filenames:
paths.append(os.path.join("..", path, filename))
return paths
extra_files = find_data_files("threeML/data")
# This list will contain the messages to print just before the end of the setup
# so that the user actually note them, instead of loosing them in the tons of
# messages of the build process
setup(
packages=[
"threeML",
"threeML/exceptions",
"threeML/bayesian",
"threeML/minimizer",
"threeML/utils",
"threeML/utils/OGIP",
"threeML/utils/spectrum",
"threeML/utils/polarization",
"threeML/utils/photometry",
"threeML/utils/time_series",
"threeML/utils/data_builders",
"threeML/utils/data_builders/fermi",
"threeML/utils/data_download",
"threeML/utils/data_download/Fermi_LAT",
"threeML/utils/data_download/Fermi_GBM",
"threeML/utils/fitted_objects",
"threeML/utils/statistics",
"threeML/plugins",
"threeML/classicMLE",
"threeML/catalogs",
"threeML/io",
"threeML/io/plotting",
"threeML/io/cern_root_utils",
"threeML/parallel",
"threeML/config",
"threeML/test",
"threeML/plugins/experimental",
],
cmdclass=versioneer.get_cmdclass(),
version=versioneer.get_version(),
license="BSD-3",
keywords=[
"Likelihood",
"Multi-mission",
"3ML",
"HAWC",
"Fermi",
"HESS",
"joint",
"fit",
"bayesian",
"multi-wavelength",
],
# NOTE: we use '' as package name because the extra_files already contain the full path from here
package_data={"": extra_files,},
) # End of setup()
# Check for optional dependencies
optional_dependencies = {
"cthreeML": [False, "needed by HAWC plugin"],
"pymultinest": [False, "provides the Multinest sampler for Bayesian analysis"],
"ultranest": [False, "procides the UltraNest sampler for Bayesian Analysis"],
"zeus": [False, "procides the zeus sampler for Bayesian Analysis"],
"pyOpt": [False, "provides more optimizers"],
"ROOT": [False, "provides the ROOT optimizer"],
"ipywidgets": [False, "provides widget for jypyter (like the HTML progress bar)"],
"chainconsumer": [False, "consumes the chains output from Monte Carlo processes"],
}
for dep_name in optional_dependencies:
optional_dependencies[dep_name][0] = is_module_available(dep_name)
# Now print the final messages
print("\n\n##################")
print("OPTIONAL FEATURES:")
print("##################\n\n")
for dep_name in optional_dependencies:
if optional_dependencies[dep_name][0]:
status = "available"
else:
status = "*NOT* available"
print(" * %s is %s (%s)\n" % (dep_name, status, optional_dependencies[dep_name][1]))