-
Notifications
You must be signed in to change notification settings - Fork 18
/
setup.py
112 lines (97 loc) · 3.58 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
import setuptools
import platform
import os
import sys
import subprocess
from numpy import get_include
from Cython.Build import cythonize
# Set to true to enable line profiling
line_debug = False
#Load the readme as a long description
with open('README.md') as fp:
long_description = fp.read()
# Compile Cython
try:
numpyInclude = [get_include(), '.']
#Install Bioscrape Core Package
package_data = {'bioscrape': ['*.pxd']}
bioscrape_src_dir = 'bioscrape'
ext_options = {}
ext_options['language'] = 'c++'
ext_options['include_dirs'] = numpyInclude
if platform.system() == "Darwin":
ext_options['extra_compile_args'] = ['-std=c++11', "-mmacosx-version-min=10.9"]
ext_options['extra_link_args'] = ["-stdlib=libc++", "-mmacosx-version-min=10.9"]
print('Using macOS clang args')
if line_debug:
ext_options['define_macros'] = [('CYTHON_TRACE_NOGIL', '1')]
#used to generate HTML annotations of the cython code for
#optimization purposes.
cythonize_options = {
"include_path":[bioscrape_src_dir],
"language_level":"2" #Language level 3 does not work yet
}
if "annotate" in sys.argv:
cythonize_options['annotate'] = True
sys.argv.remove("annotate")
if line_debug:
cythonize_options["compiler_directives"] = {
'profile': True,
'linetrace': True,
'binding': True
}
# # Turn on to enable gdb debugging
# cythonize_options["gdb_debug"] = True
# # Turn on to enable gdb debugging
# cythonize_options["gdb_debug"] = True
#Determine if we install bioscrape, lineage, or both
install_bioscrape = False
install_lineage = False
if "bioscrape" not in sys.argv and "lineage" not in sys.argv:
install_bioscrape = True
install_lineage = True
if "bioscrape" in sys.argv:
install_bioscrape = True
sys.argv.remove("bioscrape")
if "lineage" in sys.argv:
install_lineage = True
sys.argv.remove("lineage")
elif "bioscrape" not in sys.argv:
install_lineage = True
cython_extensions = []
if install_bioscrape:
print("Installing Bioscrape...")
bioscrape_source_files = ['random.pyx',
'types.pyx',
'simulator.pyx',
'inference.pyx']
bioscrape_extensions = [
setuptools.Extension(
name = 'bioscrape.'+s.split('.')[0],
sources = [bioscrape_src_dir+'/'+s],
**ext_options) for s in bioscrape_source_files
]
cython_extensions += cythonize(bioscrape_extensions, **cythonize_options)
print("Bioscrape Cythonized.")
if install_lineage:
package_data['lineage'] = ['*.pxd']
print("Installing Lineage...")
lineage_src_dir = 'lineage'
lineage_source_files = ['lineage.pyx']
lineage_extensions = [
setuptools.Extension(name = 'bioscrape.'+s.split('.')[0],
sources = [lineage_src_dir+'/'+s],
**ext_options) for s in lineage_source_files
]
cython_extensions += cythonize(lineage_extensions, **cythonize_options)
print("Lineage Cythonized.")
except Exception as e:
print("Error occured during Cython Compilation. Check C++ Compiler and Cython Installation.")
raise
setuptools.setup(
long_description=long_description,
# package_dir = {'bioscrape' : bioscrape_src_dir},
package_data = package_data,
ext_modules = cython_extensions,
zip_safe=False,
)