Skip to content

Commit

Permalink
ENH: Globally enable Cython free-threading directive (#59248)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lysnikolaou authored Jul 16, 2024
1 parent a8875e1 commit 56c80f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,6 @@ jobs:
- name: Run Tests
uses: ./.github/actions/run-tests
env:
PYTHON_GIL: 0

# NOTE: this job must be kept in sync with the Pyodide build job in wheels.yml
emscripten:
Expand Down
5 changes: 5 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ else
meson.add_dist_script(py, versioneer, '-o', '_version_meson.py')
endif

cy = meson.get_compiler('cython')
if cy.version().version_compare('>=3.1.0')
add_project_arguments('-Xfreethreading_compatible=true', language : 'cython')
endif

# Needed by pandas.test() when it looks for the pytest ini options
py.install_sources(
'pyproject.toml',
Expand Down
4 changes: 4 additions & 0 deletions pandas/_libs/src/vendored/ujson/python/ujson.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ PyMODINIT_FUNC PyInit_json(void) {
return NULL;
}

#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
#endif

#ifndef PYPY_VERSION
PyObject *mod_decimal = PyImport_ImportModule("decimal");
if (mod_decimal) {
Expand Down

0 comments on commit 56c80f8

Please sign in to comment.