-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.py
64 lines (59 loc) · 2.58 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
# -*- coding: utf-8 -*-
"""
Build cython extension modules.
The shared library can also be built manually using the command:
$ cythonize -X language_level=3 -a -i ./iscc_core/cdc.py
$ cythonize -X language_level=3 -a -i ./iscc_core/minhash.py
$ cythonize -X language_level=3 -a -i ./iscc_core/simhash.py
$ cythonize -X language_level=3 -a -i ./iscc_core/dct.py
$ cythonize -X language_level=3 -a -i ./iscc_core/wtahash.py
"""
try:
from Cython.Build import cythonize, build_ext
except ImportError:
# dummy build function for poetry
def build(setup_kwargs):
pass
else:
class build_ext_gracefull(build_ext):
def run(self):
try:
print("Trying to compile C accelerator modules")
super().run()
print("Successfully comiled C accelerator modules")
except Exception as e:
print(e)
print("********************************************************************")
print("Failed to compile C accelerator module, falling back to pure python.")
print("********************************************************************")
def build_extensions(self):
try:
print("Trying to compile C accelerator modules")
super().build_extensions()
print("Successfully comiled C accelerator modules")
except Exception as e:
print(e)
print("********************************************************************")
print("Failed to compile C accelerator module, falling back to pure python.")
print("********************************************************************")
def build(setup_kwargs):
try:
setup_kwargs.update(
dict(
ext_modules=cythonize(
[
"iscc_core/cdc.py",
"iscc_core/minhash.py",
"iscc_core/simhash.py",
"iscc_core/dct.py",
"iscc_core/wtahash.py",
]
),
cmdclass=dict(build_ext=build_ext_gracefull),
)
)
except Exception as e:
print(e)
print("********************************************************************")
print("Failed to compile C accelerator module, falling back to pure python.")
print("********************************************************************")