-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
executable file
·56 lines (46 loc) · 1.81 KB
/
setup.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
#!/usr/bin/env python3
import os
from setuptools import setup, find_packages, Extension
try:
from Cython.Build import cythonize
except ImportError:
cythonize = None
# https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#distributing-cython-modules
def no_cythonize(extensions, **_ignore):
for extension in extensions:
sources = []
for sfile in extension.sources:
path, ext = os.path.splitext(sfile)
if ext in (".pyx", ".py"):
if extension.language == "c++":
ext = ".cpp"
else:
ext = ".c"
sfile = path + ext
sources.append(sfile)
extension.sources[:] = sources
return extensions
extensions = [
Extension('pyavro_stardust.baseavro', ['src/pyavro_stardust/baseavro.pyx'], language="c++"),
Extension('pyavro_stardust.flowtuple3', ['src/pyavro_stardust/flowtuple3.pyx'], language="c++"),
Extension('pyavro_stardust.flowtuple4', ['src/pyavro_stardust/flowtuple4.pyx'], language="c++"),
Extension('pyavro_stardust.rsdos', ['src/pyavro_stardust/rsdos.pyx'], language="c++")
]
CYTHONIZE = bool(int(os.getenv("CYTHONIZE", 0))) and cythonize is not None
if CYTHONIZE:
compiler_directives = {"language_level": 3, "embedsignature": True}
extensions = cythonize(extensions, compiler_directives=compiler_directives, annotate=True)
else:
extensions = no_cythonize(extensions)
with open("requirements.txt") as fp:
install_requires = fp.read().strip().split("\n")
with open("requirements-dev.txt") as fp:
dev_requires = fp.read().strip().split("\n")
setup(
ext_modules=extensions,
install_requires=install_requires,
extras_require={
"dev": dev_requires,
"docs": ["sphinx", "sphinx-rtd-theme"]
},
)