-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetup.py
More file actions
40 lines (34 loc) · 1.09 KB
/
setup.py
File metadata and controls
40 lines (34 loc) · 1.09 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
import os
import sys
from setuptools import setup
from setuptools_rust import RustExtension
use_rust = int(os.environ.get("USE_RUST", "-1"))
# Detect if we're only asking for version info (e.g. during packaging)
is_version_query = any(arg in sys.argv for arg in ["--version", "--name"])
if not is_version_query:
if use_rust == 0:
print("Building pure Python version.")
elif use_rust == 1:
print("Building rust bindings version.")
else:
print("Building with rust bindings, and if failing reverting to pure Python.")
if use_rust == 0: # pure python
rust_extensions = []
elif use_rust == 1: # rust extension
rust_extensions = [
RustExtension(
"polytope_feature.polytope_rs",
path="rust/Cargo.toml",
debug=False,
)
]
else: # (default) try rust extension, if fail fallback to python
rust_extensions = [
RustExtension(
"polytope_feature.polytope_rs",
path="rust/Cargo.toml",
debug=False,
optional=True,
)
]
setup(rust_extensions=rust_extensions)