-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.py
48 lines (41 loc) · 1.74 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
# -*- coding: utf-8 -*-
"""
The shared library can also be built manually using the command:
$ cythonize -X language_level=3 -a -i ./fastcdc/fastcdc_cy.pyx
"""
from distutils.command.build_ext import build_ext
class BuildExt(build_ext):
def run(self):
try:
print("Trying to compile C accelerator module")
build_ext.run(self)
print("Successfully comiled C accelerator module")
except Exception as e:
print(e)
print("************************************************************")
print("Cannot compile C accelerator module, use pure python version")
print("************************************************************")
def build_extensions(self):
try:
print("Trying to compile C accelerator module")
super().build_extensions()
print("Successfully comiled C accelerator module")
except Exception as e:
print(e)
print("************************************************************")
print("Cannot compile C accelerator module, use pure python version")
print("************************************************************")
def build(setup_kwargs):
try:
from Cython.Build import cythonize
setup_kwargs.update(
dict(
ext_modules=cythonize(["fastcdc/fastcdc_cy.pyx"]),
cmdclass=dict(build_ext=BuildExt),
)
)
except Exception as e:
print(e)
print("************************************************************")
print("Cannot compile C accelerator module, use pure python version")
print("************************************************************")