Add support for detecting free-threaded Python on Windows #13338
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This does a couple of things:
Py_GIL_DISABLED
sysconfig var, which is the best way as of today to determine whether the target interpreter was built with--disable-gil
.libpython
.pyconfig.h
, which the CPython devs have said is unlikely to be fixed since headers are shared between the regular and free-threaded builds in a single NSIS installer (see https://discuss.python.org/t/windows-installer-freethreading-and-building-extension-modules/54391/2).I have tested this with NumPy; the
libpython
change makes numpy build, and the added define fixes the ABI issue that otherwise makesimport numpy
segfault immediately due to thepyconfig.h
problem. It passes its full test suite under free-threaded CPython then, modulo a few trivial failures.This fixes the problem reported in gh-13263. I'd like to leave that issue open for now, since adding CI coverage is still to be done. It's too early right now, I don't think there's a good way to install free-threaded CPython 3.13.0b2 yet; there's only the NSIS installer from python.org right now, and even there it's an optional extra that you need to explicitly enable.