-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsetup.py
91 lines (77 loc) · 1.8 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
"""
When making a new distribution use:
$ python setup.py sdist
"""
import os
import re
import subprocess
from pathlib import Path
from setuptools import (
Extension,
setup,
)
import numpy
ROOT = Path(__file__).parent
WINDOWS = os.name == "nt"
CONDA = os.environ.get("CONDA_BUILD", 0)
def gsl_config(*args, **kwargs):
"""Run gsl-config and return pre-formatted output"""
if WINDOWS:
cmd = "gsl-config {}".format(" ".join(args))
kwargs.setdefault("shell", True)
else:
cmd = ["gsl-config"] + list(args)
return subprocess.check_output(cmd, **kwargs).decode("utf-8").strip()
# define ext_modules
extra_compile_args = [
"-Wall",
"-DHAVE_PYTHON_LINTEGRATE",
]
if WINDOWS:
extra_compile_args += [
"-O2",
"-DGSL_DLL",
"-DWIN32",
]
elif CONDA:
extra_compile_args += [
"-O3",
]
else:
extra_compile_args += [
"-O3",
"-Wextra",
"-m64",
"-ffast-math",
"-fno-finite-math-only",
"-funroll-loops",
]
ext_modules = [
Extension(
"lintegrate.lintegrate",
sources=[
"src/lintegrate/lintegrate.pyx",
"src/lintegrate_qag.c",
"src/lintegrate_qng.c",
"src/lintegrate_cquad.c",
],
include_dirs=[
numpy.get_include(),
gsl_config("--cflags")[2:],
"src",
],
library_dirs=[
gsl_config("--libs-without-cblas").split(" ")[0][2:],
],
libraries=[
l.replace("-l", "") for l in gsl_config("--libs-without-cblas").split()[1:]
],
extra_compile_args=extra_compile_args,
),
]
for e in ext_modules:
e.cython_directives = {"language_level": "3"}
setup(
ext_modules=ext_modules,
)