-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsetup.py
57 lines (51 loc) · 1.43 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
"""Build cython extensions.
The full project config can be found in `pyproject.toml`. `setup.py` is still
required to build cython extensions.
"""
import os
import re
import sys
import sysconfig
import numpy
from Cython.Build import cythonize
from setuptools import setup
from setuptools.extension import Extension
# Decide whether to use OpenMP or not
if (
("CAPUT_NO_OPENMP" in os.environ)
or (re.search("gcc", sysconfig.get_config_var("CC")) is None)
or (sys.platform == "darwin")
):
print("Not using OpenMP")
omp_args = []
else:
omp_args = ["-fopenmp"]
# Set up project extensions
extensions = [
Extension(
name="caput.weighted_median",
sources=["caput/weighted_median.pyx"],
include_dirs=[numpy.get_include()],
language="c++",
extra_compile_args=[*omp_args, "-std=c++11", "-g0", "-O3"],
extra_link_args=[*omp_args, "-std=c++11"],
),
Extension(
name="caput.truncate",
sources=["caput/truncate.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=[*omp_args, "-g0", "-O3"],
extra_link_args=omp_args,
),
Extension(
name="caput._fast_tools",
sources=["caput/_fast_tools.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=[*omp_args, "-g0", "-O3"],
extra_link_args=omp_args,
),
]
setup(
name="caput", # required
ext_modules=cythonize(extensions),
)