forked from threeML/threeML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
160 lines (107 loc) · 4.19 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/usr/bin/env python
import os
import sys
import glob
from setuptools import setup
# Get the version number
execfile('threeML/version.py')
# Now a global __version__ is available
# 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(
name="threeML",
packages=['threeML',
'threeML/exceptions',
'threeML/bayesian',
'threeML/minimizer',
'threeML/plugins',
'threeML/plugins/OGIP',
'threeML/plugins/spectrum',
'threeML/plugins/Fermi_LAT',
'threeML/plugins/Fermi_GBM',
'threeML/plugins/photometry',
'threeML/classicMLE',
'threeML/catalogs',
'threeML/io',
'threeML/io/plotting',
'threeML/io/cern_root_utils',
'threeML/utils',
'threeML/utils/time_series',
'threeML/utils/data_builders',
'threeML/utils/data_builders/fermi',
'threeML/utils/fitted_objects',
'threeML/parallel',
'threeML/config'
],
version=__version__,
description="The Multi-Mission Maximum Likelihood framework",
long_description="3ML can be used for single or multi-instrument likelihood modeling or Bayesian inference",
license='BSD-3',
author='Giacomo Vianello',
author_email='[email protected]',
url='https://github.com/giacomov/3ML',
download_url='https://github.com/giacomov/3ML/archive/%s' % __version__,
keywords=['Likelihood', 'Multi-mission', '3ML', 'HAWC', 'Fermi', 'HESS', 'joint', 'fit', 'bayesian',
'multi-wavelength'],
classifiers=[],
# Install configuration file in user home and in the package repository
# data_files=[(os.path.join(os.path.expanduser('~'), '.threeML'), ["threeML/config/threeML_config.yml"]),
# ('threeML/config', ["threeML/config/threeML_config.yml"])
# ],
# NOTE: we use '' as package name because the extra_files already contain the full path from here
package_data={'': extra_files, },
include_package_data=True,
install_requires=[
'numpy >= 1.6',
'scipy',
'emcee',
'astropy>=1.0.3',
'matplotlib',
'uncertainties',
'pyyaml',
'dill',
'iminuit>=1.2',
'astromodels>=0.4.0',
'corner>=1.0.2',
'pandas',
'html2text',
'requests',
'speclite'
])
# Check for optional dependencies
optional_dependencies = {'cthreeML': [False,'needed by HAWC plugin'],
'pymultinest': [False, 'provides the Multinest 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)']}
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]))