-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
53 lines (45 loc) · 1.41 KB
/
Copy pathsetup.py
File metadata and controls
53 lines (45 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
import os
import shlex
from setuptools import Extension, setup
from Cython.Build import cythonize
target_arch = os.environ.get("PROXY_ARCH", "native").strip()
lto_mode = os.environ.get("PROXY_LTO", "full").strip().lower()
extra_compile_args = [
"-O3",
"-fno-semantic-interposition",
"-fvisibility=hidden",
]
extra_link_args = []
if target_arch.lower() not in {"", "none", "default"}:
extra_compile_args.append(f"-march={target_arch}")
if lto_mode in {"1", "on", "true", "full"}:
extra_compile_args.append("-flto")
extra_link_args.append("-flto")
elif lto_mode == "thin":
extra_compile_args.append("-flto=thin")
extra_link_args.append("-flto=thin")
elif lto_mode not in {"0", "off", "false", "none"}:
raise ValueError("PROXY_LTO must be one of: full, thin, or off")
extra_compile_args.extend(shlex.split(os.environ.get("PROXY_CFLAGS", "")))
extra_link_args.extend(shlex.split(os.environ.get("PROXY_LDFLAGS", "")))
ext = Extension(
"proxy",
["proxy.pyx"],
extra_compile_args=extra_compile_args,
extra_link_args=extra_link_args,
)
setup(
python_requires=">=3.11",
ext_modules=cythonize(
ext,
language_level="3",
compiler_directives={
"boundscheck": False,
"wraparound": False,
"cdivision": True,
"infer_types": True,
"nonecheck": False,
"initializedcheck": False,
},
)
)