Skip to content

Commit 5d7b761

Browse files
committed
Support free-threading builds of Python 3.14t
Build wheels for 3.14t, and declare that our extension module doesn't rely on the GIL. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
1 parent ade542a commit 5d7b761

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

.github/workflows/build_wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Build wheels
6969
uses: pypa/cibuildwheel@v3.0.1
7070
env:
71-
CIBW_BUILD: "cp3{8..14}-${{ matrix.wheel_type }}"
71+
CIBW_BUILD: "cp3{8..14}{t,}-${{ matrix.wheel_type }}"
7272
CIBW_ARCHS_LINUX: auto aarch64
7373
CIBW_ENABLE: cpython-prerelease
7474
- uses: actions/upload-artifact@v4

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"cdivision": True,
3434
"c_string_type": "unicode",
3535
"c_string_encoding": "utf8",
36+
"freethreading_compatible": True,
3637
}
3738

3839
DEFINE_MACROS = []
@@ -50,6 +51,7 @@
5051
"infer_types": True,
5152
"c_string_type": "unicode",
5253
"c_string_encoding": "utf8",
54+
"freethreading_compatible": True,
5355
}
5456
DEFINE_MACROS.extend([("CYTHON_TRACE", "1"), ("CYTHON_TRACE_NOGIL", "1")])
5557

tests/integration/empty_thread_extension/testext.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ static struct PyModuleDef moduledef = {PyModuleDef_HEAD_INIT, "testext", "", -1,
3939
PyMODINIT_FUNC
4040
PyInit_testext(void)
4141
{
42-
return PyModule_Create(&moduledef);
42+
PyObject *mod = PyModule_Create(&moduledef);
43+
#ifdef Py_GIL_DISABLED
44+
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
45+
#endif
46+
return mod;
4347
}
4448
#else
4549
PyMODINIT_FUNC

tests/integration/empty_thread_extension_with_os_threads/testext.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ static struct PyModuleDef moduledef = {PyModuleDef_HEAD_INIT, "testext", "", -1,
6969
PyMODINIT_FUNC
7070
PyInit_testext(void)
7171
{
72-
return PyModule_Create(&moduledef);
72+
PyObject *mod = PyModule_Create(&moduledef);
73+
#ifdef Py_GIL_DISABLED
74+
PyUnstable_Module_SetGIL(mod, Py_MOD_GIL_NOT_USED);
75+
#endif
76+
return mod;
7377
}
7478
#else
7579
PyMODINIT_FUNC

0 commit comments

Comments
 (0)