-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.py
46 lines (40 loc) · 1.1 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
from setuptools import Extension
from Cython.Build import cythonize
from setuptools.dist import Distribution
try:
from Cython.Build import cythonize
except ImportError:
use_cython = False
ext = 'c'
ext_pp = 'cpp'
else:
use_cython = True
ext = ext_pp = 'pyx'
cyfuncs_ext = Extension(name='cyrtd.cymod.cyfuncs',
sources=['cyrtd/cymod/cyfuncs.' + ext]
)
EXTENSIONS = [
cyfuncs_ext
]
if use_cython:
EXTENSIONS = cythonize(EXTENSIONS, language_level=3)
def build(setup_kwargs):
setup_kwargs.update({
'ext_modules': EXTENSIONS,
'zip_safe': False,
})
def build_extensions():
"""
Function for building extensions inplace for docs and tests
:return:
"""
build_params = {}
build(build_params)
dist = Distribution(attrs=build_params)
build_clib_cmd = dist.get_command_obj('build_clib')
build_clib_cmd.ensure_finalized()
build_clib_cmd.run()
build_ext_cmd = dist.get_command_obj('build_ext')
build_ext_cmd.ensure_finalized()
build_ext_cmd.inplace = 1
build_ext_cmd.run()