-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathsetup.py
More file actions
53 lines (45 loc) · 1.81 KB
/
Copy pathsetup.py
File metadata and controls
53 lines (45 loc) · 1.81 KB
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
# This file exists solely to configure the dynamic C extension.
# All project metadata lives in pyproject.toml.
from setuptools import setup, Extension
from glob import glob
import os
import sys
import sysconfig
##### Git hash
try:
import subprocess
ghash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("ascii").strip()
ghash_arg = f"-DGITHASH={ghash}"
except Exception:
ghash_arg = "-DGITHASH=53773afe758ed4540dd515968ca9726f851ea5e7" #GITHASHAUTOUPDATE
##### Link args
extra_link_args = []
if sys.platform == "darwin":
cfg = sysconfig.get_config_vars()
cfg["LDSHARED"] = cfg["LDSHARED"].replace("-bundle", "-shared")
suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so"
extra_link_args = [f"-Wl,-install_name,@rpath/librebound{suffix}"]
##### Compile args
if sys.platform == "win32":
extra_compile_args = [ghash_arg, "-DBUILDINGLIBREBOUND", "-D_GNU_SOURCE", "-DSERVER"]
else:
extra_compile_args = [ "-fstrict-aliasing", "-std=c99", "-Wno-unreachable-code", "-Wno-unknown-pragmas", ghash_arg, "-D_GNU_SOURCE", "-DSERVER", "-fPIC"]
if os.environ.get("COVERAGE"):
extra_compile_args += ["-O1", "-fprofile-arcs", "-ftest-coverage", "--coverage"]
extra_link_args += ["-fprofile-arcs", "-ftest-coverage", "--coverage"]
else:
extra_compile_args.append("-O3")
##### Turn off floating point contractions for bitwise reproducibility
if os.environ.get("FFP_CONTRACT_OFF"):
extra_compile_args.append("-ffp-contract=off")
if os.environ.get("AVX512"):
extra_compile_args += ["-march=native", "-DAVX512"]
##### C Extension
libreboundmodule = Extension(
"librebound",
sources=sorted(glob("src/*.c")),
include_dirs=["src"],
extra_link_args=extra_link_args,
extra_compile_args=extra_compile_args,
)
setup(ext_modules=[libreboundmodule])