-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
47 lines (37 loc) · 1.26 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
import setuptools
from setuptools.extension import Extension
from Cython.Distutils import build_ext
# import sys
# cython and python dependency is handled by pyproject.toml
from Cython.Build import cythonize
import numpy
# -----------------------------------------------------------------------------
# Compilation of C module in c_lib
com_args = ['-std=c99', '-O3', '-fopenmp']
link_args = ['-fopenmp']
extensions = [
Extension("pcython_proj.cython_lib.example_cython",
["pcython_proj/cython_lib/example_cython.pyx",
"pcython_proj/cython_lib/example.c"],
# extra_compile_args={'gcc': com_args},
extra_compile_args=com_args,
extra_link_args=link_args,
include_dirs=[numpy.get_include()]
)
]
# -----------------------------------------------------------------------------
class BuildExt(build_ext):
def build_extensions(self):
try:
super().build_extensions()
except Exception:
pass
def build(setup_kwargs):
setup_kwargs.update(
dict(
cmdclass=dict(build_ext=BuildExt),
ext_modules=cythonize(extensions,
language_level=3),
zip_safe=False
)
)