forked from ariebovenberg/whenever
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
51 lines (41 loc) · 1.3 KB
/
setup.py
File metadata and controls
51 lines (41 loc) · 1.3 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
50
51
import os
import platform
from setuptools import setup
_SKIP_BUILD_SUGGESTION = """
*******************************************************************************
Building the Rust extension of the library `whenever` failed. See errors above.
Set the `WHENEVER_NO_BUILD_RUST_EXT` environment variable to any value to skip
building the Rust extension and use the (slower) Python version instead.
*******************************************************************************
"""
extra_setup_kwargs = {}
if (
os.getenv("WHENEVER_NO_BUILD_RUST_EXT")
or platform.python_implementation() in ("PyPy", "GraalVM")
):
print("Skipping Whenever Rust extension build")
else:
from setuptools_rust import Binding, RustExtension, build_rust
class BuildRust(build_rust):
def run(self):
try:
build_rust.run(self)
except Exception as e:
print(_SKIP_BUILD_SUGGESTION)
raise e
extra_setup_kwargs.update(
{
"rust_extensions": [
RustExtension(
"whenever._whenever",
binding=Binding.NoBinding,
)
],
"cmdclass": {
"build_rust": BuildRust,
},
}
)
setup(
**extra_setup_kwargs,
)