-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_ext.py
More file actions
49 lines (42 loc) · 1.19 KB
/
setup_ext.py
File metadata and controls
49 lines (42 loc) · 1.19 KB
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
"""
Build script for Cython extensions.
Usage:
python setup_ext.py build_ext --inplace
This compiles the optional Cython extensions for logarithma. If Cython or
a C compiler is not available the package still works via pure-Python fallback.
"""
from setuptools import setup, Extension
try:
from Cython.Build import cythonize
USE_CYTHON = True
except ImportError:
USE_CYTHON = False
_ext_dir = "src/logarithma/algorithms/shortest_path"
if USE_CYTHON:
extensions = cythonize(
[
Extension(
"logarithma.algorithms.shortest_path.block_heap_cy",
sources=[f"{_ext_dir}/block_heap.pyx"],
language="c",
),
Extension(
"logarithma.algorithms.shortest_path.breaking_barrier_core",
sources=[f"{_ext_dir}/breaking_barrier_core.pyx"],
language="c",
),
],
compiler_directives={
"language_level": "3",
"boundscheck": False,
"wraparound": False,
"cdivision": True,
},
annotate=False,
)
else:
extensions = []
setup(
name="logarithma-ext",
ext_modules=extensions,
)