Skip to content

Commit 56c80f8

Browse files
authored
ENH: Globally enable Cython free-threading directive (#59248)
* ENH: Globally enable Cython free-threading directive This is the Cython equivalent of adding a `Py_mod_gil` slot with `Py_MOD_GIL_NOT_USED` like we did in #59135. * Use add_project_arguments * Mark json with Py_MOD_GIL_NOT_USED & remove PYTHON_GIL env var from ci test job
1 parent a8875e1 commit 56c80f8

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

.github/workflows/unit-tests.yml

-2
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,6 @@ jobs:
388388
389389
- name: Run Tests
390390
uses: ./.github/actions/run-tests
391-
env:
392-
PYTHON_GIL: 0
393391

394392
# NOTE: this job must be kept in sync with the Pyodide build job in wheels.yml
395393
emscripten:

meson.build

+5
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ else
4444
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
4545
endif
4646

47+
cy = meson.get_compiler('cython')
48+
if cy.version().version_compare('>=3.1.0')
49+
add_project_arguments('-Xfreethreading_compatible=true', language : 'cython')
50+
endif
51+
4752
# Needed by pandas.test() when it looks for the pytest ini options
4853
py.install_sources(
4954
'pyproject.toml',

pandas/_libs/src/vendored/ujson/python/ujson.c

+4
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ PyMODINIT_FUNC PyInit_json(void) {
384384
return NULL;
385385
}
386386

387+
#ifdef Py_GIL_DISABLED
388+
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
389+
#endif
390+
387391
#ifndef PYPY_VERSION
388392
PyObject *mod_decimal = PyImport_ImportModule("decimal");
389393
if (mod_decimal) {

0 commit comments

Comments
 (0)