-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.py
79 lines (66 loc) · 1.59 KB
/
build.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
import os
import sys
from glob import glob
from setuptools import Extension
################################################
# Hack for https://github.com/python-poetry/poetry/issues/6154#issue-1336927568
import subprocess
try:
import numpy
except ImportError:
subprocess.run(["pip", "install", "oldest-supported-numpy"])
import numpy
################################################
LINUX_OPTS = {
"extra_link_args": [
"-fopenmp",
],
"extra_compile_args": [
"-fopenmp",
"-Wno-strict-prototypes",
"-Wno-maybe-uninitialized",
"-O3",
"-std=c99",
],
}
OSX_OPTS = {
"extra_link_args": [
"-L/usr/local/opt/libomp/lib",
"-fopenmp",
],
"extra_compile_args": [
"-Wno-strict-prototypes",
"-Wno-uninitialized",
"-fopenmp",
"-O3",
],
}
WINDOWS_OPTS = {
"extra_compile_args": [
"/Ox",
]
}
if os.name == "posix":
if sys.platform.startswith("darwin"):
OPTS = OSX_OPTS
else:
OPTS = LINUX_OPTS
else:
OPTS = WINDOWS_OPTS
def build(setup_kwargs):
setup_kwargs.update(
{
"ext_modules": [
Extension(
"gamred_native",
sources=glob("gamred_native/*.c"),
include_dirs=["gamred_native", numpy.get_include()],
define_macros=[
("NPY_NO_DEPRECATED_API", None),
("NPY_1_7_API_VERSION", None),
],
**OPTS,
),
],
}
)