-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsetup.py
More file actions
54 lines (43 loc) · 1.41 KB
/
setup.py
File metadata and controls
54 lines (43 loc) · 1.41 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
52
53
54
import os
import platform
from setuptools import Extension, setup
system = platform.system()
current_arch = platform.machine()
print(f"System: {system} ({current_arch})")
IS_EXTENSION_BUILDABLE = system == "Linux" and current_arch in [
"x86_64",
"aarch64",
]
IS_EXTENSION_REQUIRED = (
os.environ.get("PYTEST_CODSPEED_FORCE_EXTENSION_BUILD") is not None
)
SKIP_EXTENSION_BUILD = (
os.environ.get("PYTEST_CODSPEED_SKIP_EXTENSION_BUILD") is not None
)
if SKIP_EXTENSION_BUILD and IS_EXTENSION_REQUIRED:
raise ValueError("Extension build required but the build requires to skip it")
if IS_EXTENSION_REQUIRED and not IS_EXTENSION_BUILDABLE:
raise ValueError(
"The extension is required but the current platform is not supported"
)
# Build native C extension
native_extension = Extension(
"pytest_codspeed.instruments.hooks.dist_instrument_hooks",
sources=[
"src/pytest_codspeed/instruments/hooks/instrument_hooks_module.c",
"src/pytest_codspeed/instruments/hooks/instrument-hooks/dist/core.c",
],
include_dirs=["src/pytest_codspeed/instruments/hooks/instrument-hooks/includes"],
optional=not IS_EXTENSION_REQUIRED,
)
print(
"CodSpeed native extension is "
+ ("required" if IS_EXTENSION_REQUIRED else "optional")
)
setup(
ext_modules=(
[native_extension]
if IS_EXTENSION_BUILDABLE and not SKIP_EXTENSION_BUILD
else []
),
)