-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsetup.py
66 lines (58 loc) · 1.93 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
"""
Setup for ArCTIc cython wrapper. See README.md.
Build with:
python3 setup.py build_ext --inplace
"""
import os
import numpy as np
from setuptools import setup, Extension
from Cython.Build import cythonize
# Directories
dir_wrapper = "python/arcticpy"
dir_wrapper_src = os.path.join(dir_wrapper, "src")
dir_wrapper_include = os.path.join(dir_wrapper, "include")
dir_include = "include/"
dir_src = "src/"
dir_gsl = os.environ.get("DIR_GSL", "/usr/local/")
dir_gsl_include = os.path.join(dir_gsl, "include")
dir_gsl_lib = os.path.join(dir_gsl, "lib")
# Clean (really needed anymore?)
for root, dirs, files in os.walk(dir_wrapper, topdown=False):
for name in files:
file = os.path.join(root, name)
if name.endswith(".o") or (
name.startswith("wrapper")
and not (name.endswith(".pyx") or name.endswith(".pxd"))
):
print("rm", file)
os.remove(file)
# Build
if "CC" not in os.environ:
os.environ["CC"] = "g++"
ext_headers = [os.path.join(dir_include, header) for header in os.listdir(dir_include)]
ext_sources = [os.path.join(dir_src, src) for src in os.listdir(dir_src)]
extensions = [
Extension(
name="arcticpy.wrapper",
sources=[
os.path.join(dir_wrapper, "wrapper.pyx"),
os.path.join(dir_wrapper_src, "interface.cpp"),
*ext_sources,
],
language="c++",
libraries=["gsl"],
runtime_library_dirs=[dir_gsl_lib],
include_dirs=[
dir_wrapper_include,
dir_include,
np.get_include(),
dir_gsl_include,
],
extra_compile_args=["-std=c++17", "-O3"],
define_macros=[("NPY_NO_DEPRECATED_API", 0)],
),
]
setup(
ext_modules=cythonize(extensions, compiler_directives={"language_level": "3"}),
headers=ext_headers, # currently ignored (?)
)