/
setup.py
61 lines (50 loc) · 1.4 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
#!/usr/bin/env python
import os
import sys
import glob
import tensorflow as tf
from setuptools import setup
sys.path.append("exoplanet")
from cpp_extension import ( # NOQA
BuildExtension, CppExtension, CUDAExtension
)
def construct_op(name):
path = os.path.join("exoplanet", "ops", name)
cpp_files = glob.glob(os.path.join(path, "*.cc"))
cuda_files = glob.glob(os.path.join(path, "*.cu"))
flags = []
if sys.platform == "darwin":
flags += ["-mmacosx-version-min=10.9"]
if tf.test.is_built_with_cuda() and len(cuda_files):
flags.append("-DGOOGLE_CUDA=1")
return CUDAExtension(
"exoplanet." + name + "_op",
cpp_files + cuda_files,
include_dirs=[path, "include"],
extra_compile_args={
"cxx": flags,
"nvcc": flags + ["--expt-relaxed-constexpr"],
},
extra_link_args=flags,
)
return CppExtension(
"exoplanet." + name + "_op",
cpp_files,
include_dirs=[path, "include"],
extra_compile_args=flags,
extra_link_args=flags,
)
extensions = [
construct_op("transit"),
construct_op("interp"),
construct_op("kepler"),
construct_op("cubic"),
]
setup(
name="exoplanet",
license="MIT",
packages=["exoplanet"],
ext_modules=extensions,
cmdclass={"build_ext": BuildExtension},
zip_safe=True,
)