-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Description
Bug report
On Windows, the Py_GIL_DISABLED macro is not defined when building C API extensions with the free-threaded build of CPython 3.13 (i.e., --disable-gil). Now that biased reference counting (6dfb8fe) landed, this leads to incorrect/failed compilation of extensions on Windows 1. The problem does not occur on Linux/macOS and other ./configure based builds because that build system defines the Py_NOGIL macro as part of pyconfig.h. On Windows, Py_GIL_DISABLED instead defined as a pre-processor definition in pyproject.props, but that's used by C-API extensions.
Among other problems, this leads to test_peg_generator failing on the nogil Windows buildbot (example failure).
I can think of two possible approaches to fixing this:
- Modify setuptools (maybe setuptools.distutils?) to define
Py_GIL_DISABLEDwhen invoking the compiler ifsysconfig.get_config_var("Py_NOGIL")isTrue. - In the CPython Windows build, generate a header file defining/undefing
Py_GIL_DISABLEDdepending on if the build is invoked with--disable-gilor not.
The first option seems a little more straightforward to me, but there is a risk that we might encounter this same issue across multiple extension build systems. The second option seems like it would more robustly address this issue.
Linked PRs
- gh-111650: Generate pyconfig.h on Windows #112179
- gh-111650: Ensure pyconfig.h includes Py_GIL_DISABLED on Windows #112778
Footnotes
-
Modules built as part of the CPython build (i.e., standard library modules) still work ↩