-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_setup.py
106 lines (99 loc) · 3.52 KB
/
c_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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from setuptools import setup, Extension
import os
import distutils.ccompiler
import numpy
from Cython.Build import cythonize
def _up(path: str) -> str:
return path[::-1].split(os.sep, 1)[-1][::-1]
base_path = _up(__file__)
cython_src_path = base_path+os.sep+"cython_src"+os.sep+"utility"+os.sep
compiler = distutils.ccompiler.get_default_compiler()
if compiler == "msvc":
extensions = [
Extension(
"perlin_noise",
[cython_src_path+"perlin_noise.pyx"],
extra_compile_args=["/O2"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"extended_perlin_noise",
[cython_src_path+"extended_perlin_noise.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["/O2"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"number_converter",
[cython_src_path+"number_converter.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["/O2"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"math_utils",
[cython_src_path+"math_utils.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["/O2"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
)
]
elif compiler == "gcc" or compiler == "unix":
extensions = [
Extension(
"perlin_noise",
[cython_src_path+"perlin_noise.pyx"],
extra_compile_args=["-O3"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"extended_perlin_noise",
[cython_src_path+"extended_perlin_noise.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["-O3"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"number_converter",
[cython_src_path+"number_converter.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["-O3"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"math_utils",
[cython_src_path+"math_utils.pyx"],
include_dirs=[numpy.get_include()],
extra_compile_args=["-O3"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
)
]
else:
extensions = [
Extension(
"perlin_noise",
[cython_src_path+"perlin_noise.pyx"],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"extended_perlin_noise",
[cython_src_path+"extended_perlin_noise.pyx"],
include_dirs=[numpy.get_include()],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"number_converter",
[cython_src_path+"number_converter.pyx"],
include_dirs=[numpy.get_include()],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
),
Extension(
"math_utils",
[cython_src_path+"math_utils.pyx"],
include_dirs=[numpy.get_include()],
define_macros=[('NPY_NO_DEPRECATED_API', 'NPY_1_7_API_VERSION')],
)
]
setup(
ext_modules=cythonize(extensions),
)