forked from threeML/cthreeML
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
139 lines (79 loc) · 3.59 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
#!/usr/bin/env python
import os
import sys
import numpy as np
from setuptools import setup, Extension
# Get the version number from ModelInterface.h
__version__ = None
with open("cthreeML/ModelInterface.h") as f:
for line in f:
if line.find("#define INTERFACE_VERSION")==0:
__version__ = "%i.0.3" % int(line.split(" ")[2])
print __version__
break
if __version__ is None:
raise RuntimeError("Could not probe version from ModelInterface.h")
# Now a global __version__ is available
# A list to store final messages to print at the end
final_messages = []
# Probe whether the user has specified its own boost directory through the BOOSTROOT
# environment variable
boost_root = os.environ.get("BOOSTROOT")
if boost_root:
# Check that the directory provided actually exists
if not os.path.exists(boost_root):
print("\nERROR: the directory %s specified in BOOSTROOT does not exist!" % boost_root)
sys.exit(-1)
# The user want to override pre-defined location of boost
print("\n\n **** Using boost.python from the env. variable $BOOSTROOT (%s)" % boost_root)
include_dirs = [os.path.join(boost_root, 'include')]
library_dirs = [os.path.join(boost_root, 'lib')]
# Check that the include and library directories exist
if not os.path.exists(include_dirs[0]):
print("\nERROR: the include directory %s for boost.python does not exist!" % include_dirs[0])
sys.exit(-1)
if not os.path.exists(library_dirs[0]):
print("\nERROR: the library directory %s for boost.python does not exist!" % library_dirs[0])
sys.exit(-1)
final_messages.append("Used boost.python from the env. variable BOOSTROOT")
final_messages.append(" Include dir: %s" % include_dirs)
final_messages.append(" Library dir: %s" % library_dirs)
else:
include_dirs = []
library_dirs = []
final_messages.append("Using boost.python from the system path.")
# Now add the numpy headers
include_dirs.append(np.get_include())
# Configure the variables to build the external module with the C/C++ wrapper
ext_modules_configuration = [
Extension("cthreeML.pyModelInterfaceCache",
["cthreeML/pyToCppModelInterfaceCache.cxx",],
libraries=["boost_python"],
include_dirs=include_dirs,
library_dirs=library_dirs,
extra_compile_args = [])]
headers_configuration = ["cthreeML/ModelInterface.h",
"cthreeML/pyToCppModelInterfaceCache.h"]
setup(
name="cthreeML",
packages=["cthreeML"],
version=__version__,
description="The C/C++ bridge for the Multi-Mission Maximum Likelihood framework (github.com/giacomov/3ML)",
long_description="The C/C++ bridge for the Multi-Mission Maximum Likelihood framework (github.com/giacomov/3ML)",
license='BSD-3',
author='Giacomo Vianello',
author_email='[email protected]',
url='https://github.com/giacomov/cthreeML',
download_url='https://github.com/giacomov/cthreeML/archive/%s' % __version__,
keywords=['Likelihood', 'Multi-mission', '3ML', 'HAWC', 'Fermi', 'HESS', 'joint', 'fit', 'bayesian',
'multi-wavelength'],
classifiers=[],
ext_modules=ext_modules_configuration,
headers=headers_configuration,
install_requires=[])
# Now print the final messages if there are any
if len(final_messages) > 0:
print("\n#############")
print("FINAL NOTES:")
print("#############")
print("\n".join(final_messages))