-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_ssht_cffi.py
61 lines (46 loc) · 1.25 KB
/
build_ssht_cffi.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
import glob
import os
import shutil
import subprocess
import tempfile
from cffi import FFI
ffi = FFI()
with open(os.path.join("src", "ssht_numba", "src", "ssht.h")) as fl:
cdef_str = fl.read()
ffi.cdef(cdef_str)
fftw_path = os.getenv("FFTW_PATH", None)
extra_link_args = []
if fftw_path:
extra_link_args.append(["-L" + fftw_path])
ssht_src_files = sorted(glob.glob(os.path.join("ssht", "src", "c", "*.c")))
ssht_src_files = [
fl
for fl in ssht_src_files
if not fl.endswith("ssht_about.c") and not fl.endswith("ssht_test.c")
]
ssht_inc_files = sorted(glob.glob(os.path.join("ssht", "src", "c", "*.h")))
makeopts = [
"-std=c99",
"-Wall",
"-O3",
'-DSSHT_VERSION="1.2b1"',
'-DSSHT_BUILD="`git rev-parse HEAD`"',
"-fPIC",
]
if os.getenv("OPENMP", False):
makeopts += ["-fopenmp"]
inc_string = ""
for inc in ssht_inc_files:
inc_string += '#include "{}"\n'.format(os.path.basename(inc))
include_dirs = [os.path.join("ssht", "src", "c")]
ffi.set_source(
"ssht_numba._ssht_cffi",
inc_string,
sources=ssht_src_files,
libraries=["fftw3"],
include_dirs=include_dirs,
extra_link_args=extra_link_args,
extra_compile_args=makeopts,
)
if __name__ == "__main__":
ffi.compile(verbose=True)