-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc_build.py
34 lines (29 loc) · 918 Bytes
/
c_build.py
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
import os
import sys
import shlex
import sys
import re
from setuptools import Extension, setup
extra_compile_args = []
cmd = ['build', '--build-lib', os.getcwd()]
sys.argv.extend(cmd)
if "PYZAS_CFLAGS" in os.environ:
extra_compile_args = shlex.split(os.environ["PYZAS_CFLAGS"])
if "PYZAS_FIX_GIL" in os.environ:
extra_compile_args.append("-DPy_GIL_DISABLED=1")
setup(
ext_modules=[
Extension(
name="pyzas.pyzas",
sources=["c/pyzas.c", "c/methods.c"],
extra_compile_args=extra_compile_args,
),
]
)
if "PYZAS_FIX_GIL" in os.environ:
base_name = f"cp3{str(sys.version_info[1])}"
expected_name = f"{base_name}t"
for file in os.listdir("pyzas"):
expected_name = re.sub(r"(cp313)([^t])", r"\1t\2", file)
if file != expected_name:
os.rename(os.path.join("pyzas", file), os.path.join("pyzas", expected_name))