Skip to content

Commit

Permalink
BLD: do not try to use limited API in freethreading builds
Browse files Browse the repository at this point in the history
  • Loading branch information
tacaswell committed Oct 27, 2024
1 parent 385fd88 commit abd9e05
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import platform
import setuptools

import sysconfig

kwargs = {}

Expand All @@ -35,6 +35,16 @@
platform.python_implementation() == "CPython"
and os.environ.get("TORNADO_EXTENSION") != "0"
):
# build with Py_LIMITED_API unless in freethreading build (which does not currently
# support the limited API in py313t)
if not sysconfig.get_config_var("Py_GIL_DISABLED"):
extension_kwargs = dict(
py_limited_api=True, define_macros=[("Py_LIMITED_API", "0x03090000")]
)
kwargs["options"] = {"bdist_wheel": {"py_limited_api": "cp39"}}
else:
extension_kwargs = {}

# This extension builds and works on pypy as well, although pypy's jit
# produces equivalent performance.
kwargs["ext_modules"] = [
Expand All @@ -45,13 +55,12 @@
# fall back to the pure-python implementation on any build failure.
optional=os.environ.get("TORNADO_EXTENSION") != "1",
# Use the stable ABI so our wheels are compatible across python
# versions.
py_limited_api=True,
define_macros=[("Py_LIMITED_API", "0x03090000")],
# versions if not in freethreading build
**extension_kwargs,
)
]

kwargs["options"] = {"bdist_wheel": {"py_limited_api": "cp39"}}



setuptools.setup(
Expand Down

0 comments on commit abd9e05

Please sign in to comment.