-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
47 lines (40 loc) · 1.26 KB
/
setup.py
File metadata and controls
47 lines (40 loc) · 1.26 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
import sys
import glob
import os.path as op
from setuptools import setup
from setuptools.extension import Extension
from Cython.Build import cythonize
def extension_kwargs(f):
"""Disables new Numpy Cython API for dist_metrics and Boruvka module.
The dist metrics module requires inheritance with inline functions.
This is not supported by the new API. Removing the inline attribute from these
functions makes the code compile, but results in noticeable slowdowns.
Disabling the new API is the better choice.
"""
import numpy as np
if sys.platform == "win32":
cpp_flags = ["/O2"]
else:
cpp_flags = ["-O2"]
kwargs = {
'include_dirs': [np.get_include()],
'extra_compile_args': cpp_flags,
}
if 'dist_metrics' in f:
return kwargs
kwargs['language'] = 'c++'
kwargs['define_macros'] = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
return kwargs
extensions = cythonize(
[
Extension(
f.replace("src/", "").replace(".pyx", "").replace(op.sep, "."),
[f],
**extension_kwargs(f)
)
for f in glob.glob(op.join("src/flasc", "*.pyx"))
if op.isfile(f)
],
language_level=3,
)
setup(ext_modules=extensions)