]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
build: Fix free-threaded build, mark speedups module as no-GIL
authorLysandros Nikolaou <lisandrosnik@gmail.com>
Thu, 1 May 2025 18:42:30 +0000 (20:42 +0200)
committerGitHub <noreply@github.com>
Thu, 1 May 2025 18:42:30 +0000 (14:42 -0400)
setup.py
tornado/speedups.c

index de6cd3f0ae41d7f037ba66c025314c9814596fcf..e2a699124273ce04663466fbcf46442e6da6b115 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@ if (
             # Use the stable ABI so our wheels are compatible across python
             # versions.
             py_limited_api=can_use_limited_api,
-            define_macros=[("Py_LIMITED_API", "0x03090000")],
+            define_macros=[("Py_LIMITED_API", "0x03090000")] if can_use_limited_api else [],
         )
     ]
 
index 525d66034ca4b63679d5827980daa8bba8c7e1a1..992c29c15b7042ce99f9ec2a6c2e440682f93388 100644 (file)
@@ -51,20 +51,36 @@ static PyObject* websocket_mask(PyObject* self, PyObject* args) {
     return result;
 }
 
+static int speedups_exec(PyObject *module) {
+    return 0;
+}
+
 static PyMethodDef methods[] = {
     {"websocket_mask",  websocket_mask, METH_VARARGS, ""},
     {NULL, NULL, 0, NULL}
 };
 
+static PyModuleDef_Slot slots[] = {
+    {Py_mod_exec, speedups_exec},
+#if (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030c0000) || Py_LIMITED_API >= 0x030c0000
+    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
+#endif
+#if (!defined(Py_LIMITED_API) && PY_VERSION_HEX >= 0x030d0000) || Py_LIMITED_API >= 0x030d0000
+    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
+#endif
+    {0, NULL}
+};
+
 static struct PyModuleDef speedupsmodule = {
    PyModuleDef_HEAD_INIT,
    "speedups",
    NULL,
-   -1,
-   methods
+   0,
+   methods,
+   slots,
 };
 
 PyMODINIT_FUNC
 PyInit_speedups(void) {
-    return PyModule_Create(&speedupsmodule);
+    return PyModuleDef_Init(&speedupsmodule);
 }