-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
58 lines (51 loc) · 1.44 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
import os
import numpy as np
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
class LazyImportBuildExtCmd(build_ext):
def finalize_options(self):
from Cython.Build import cythonize
compiler_directives = dict(
language_level=3,
boundscheck=False,
wraparound=False,
cdivision=True,
initializedcheck=False,
embedsignature=True,
)
if os.environ.get("CYTHON_COVERAGE"):
compiler_directives["linetrace"] = True
annotate = True
else:
annotate = False
self.distribution.ext_modules = cythonize(
self.distribution.ext_modules,
compiler_directives=compiler_directives,
annotate=annotate,
)
super(LazyImportBuildExtCmd, self).finalize_options()
if os.environ.get("CYTHON_COVERAGE"):
macros = [
("CYTHON_TRACE", "1"),
("CYTHON_TRACE_NOGIL", "1"),
]
else:
macros = list()
extensions = [
Extension(
"bilby_cython.geometry",
["bilby_cython/geometry.pyx"],
include_dirs=[np.get_include()],
define_macros=macros,
),
Extension(
"bilby_cython.time",
["bilby_cython/time.pyx"],
include_dirs=[np.get_include()],
define_macros=macros,
),
]
setup(
cmdclass={"build_ext": LazyImportBuildExtCmd},
ext_modules=extensions,
)