]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
setup: Don't use stable ABI for free-threaded builds 3466/head
authorBen Darnell <ben@bendarnell.com>
Fri, 28 Feb 2025 02:47:55 +0000 (21:47 -0500)
committerBen Darnell <ben@bendarnell.com>
Fri, 28 Feb 2025 02:47:55 +0000 (21:47 -0500)
Free-threading builds unfortunately require some intrusive build
changes, so we must make the stable ABI optional python 3.13t.

setup.py
tornado/test/util.py

index 0b175af856b482f1d810b51328c2802b06cd0de3..de6cd3f0ae41d7f037ba66c025314c9814596fcf 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -18,6 +18,7 @@
 import os
 import platform
 import setuptools
+import sysconfig
 
 
 kwargs = {}
@@ -35,6 +36,9 @@ if (
     platform.python_implementation() == "CPython"
     and os.environ.get("TORNADO_EXTENSION") != "0"
 ):
+
+    can_use_limited_api = not sysconfig.get_config_var("Py_GIL_DISABLED")
+
     # This extension builds and works on pypy as well, although pypy's jit
     # produces equivalent performance.
     kwargs["ext_modules"] = [
@@ -46,12 +50,13 @@ if (
             optional=os.environ.get("TORNADO_EXTENSION") != "1",
             # Use the stable ABI so our wheels are compatible across python
             # versions.
-            py_limited_api=True,
+            py_limited_api=can_use_limited_api,
             define_macros=[("Py_LIMITED_API", "0x03090000")],
         )
     ]
 
-    kwargs["options"] = {"bdist_wheel": {"py_limited_api": "cp39"}}
+    if can_use_limited_api:
+        kwargs["options"] = {"bdist_wheel": {"py_limited_api": "cp39"}}
 
 
 setuptools.setup(
index 25dd2000fd5ce06555e24fc035374d6abb670d89..c409b4ce0b20b0df92e4769c6bb508c4b35cea0b 100644 (file)
@@ -3,6 +3,7 @@ import os
 import platform
 import socket
 import sys
+import sysconfig
 import textwrap
 import typing
 import unittest
@@ -21,7 +22,11 @@ skipIfNonUnix = unittest.skipIf(
 skipIfNoNetwork = unittest.skipIf("NO_NETWORK" in os.environ, "network access disabled")
 
 skipNotCPython = unittest.skipIf(
-    platform.python_implementation() != "CPython", "Not CPython implementation"
+    # "CPython" here essentially refers to the traditional synchronous refcounting GC,
+    # so we skip these tests in free-threading builds of cpython too.
+    platform.python_implementation() != "CPython"
+    or sysconfig.get_config_var("Py_GIL_DISABLED"),
+    "Not CPython implementation",
 )