forked from decred/tinydecred
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
42 lines (31 loc) · 1.19 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
"""
Copyright (c) 2020, The Decred developers
See LICENSE for details
This file implements Cython integration (see https://cython.org/) to generate
a C extension that speeds up the low-level secp256k1 crypto code. This is used
by the Poetry tool when generating the wheel archive via its `build` command.
It uses a currently undocumented Poetry feature, see:
https://github.com/python-poetry/poetry/issues/11#issuecomment-379484540
If Cython or a C compiler cannot be found, we skip the compilation
of the C extension, and the Python code will be used.
The shared library can also be built manually using the command:
$ cythonize -X language_level=3 -a -i ./decred/crypto/secp256k1/field.py
"""
from distutils.command.build_ext import build_ext
class BuildExt(build_ext):
def build_extensions(self):
try:
super().build_extensions()
except Exception:
pass
def build(setup_kwargs):
try:
from Cython.Build import cythonize
setup_kwargs.update(
dict(
ext_modules=cythonize(["decred/crypto/secp256k1/field.py"]),
cmdclass=dict(build_ext=BuildExt),
)
)
except Exception:
pass