-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathsetup.py
More file actions
32 lines (27 loc) · 1.14 KB
/
Copy pathsetup.py
File metadata and controls
32 lines (27 loc) · 1.14 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
from setuptools import setup
from setuptools.command.build_ext import build_ext
import os
import sys
import sysconfig
# Check whether to indicate abi3 support in a wheel name.
# BUILD_ABI3 is set for every cibuildwheel identifier, but no free-threaded
# build may claim it: setuptools' bdist_wheel raises on `py_limited_api` whenever
# Py_GIL_DISABLED is set (checked in 84.0.0), 3.15t included, even though cffi
# already builds a stable-ABI module there. The stricter of the two gates wins.
_free_threaded = sysconfig.get_config_var("Py_GIL_DISABLED")
_abi3 = bool(os.getenv("BUILD_ABI3", "")) and not _free_threaded
print("Using ABI3 wheel suffix:", _abi3, file=sys.stderr)
class fallible_build_ext(build_ext):
def run(self):
try:
return build_ext.run(self)
except Exception as e:
print(
f"Failed to build CFFI extension: {e}, proceed with non-native implementation",
file=sys.stderr,
)
setup(
cffi_modules=["timezonefinder/build.py:ffibuilder"],
cmdclass={"build_ext": fallible_build_ext},
options={"bdist_wheel": {"py_limited_api": "cp312"} if _abi3 else {}},
)