Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for detecting free-threaded Python on Windows #13338

Merged
merged 1 commit into from
Jun 23, 2024

Conversation

rgommers
Copy link
Contributor

This does a couple of things:

  1. Scrape the Py_GIL_DISABLED sysconfig var, which is the best way as of today to determine whether the target interpreter was built with --disable-gil.
  2. Link against the correct libpython.
  3. On Windows, work around a known issue in the python.org installer with a missing define in 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 makes import numpy segfault immediately due to the pyconfig.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.

This does a couple of things:
1. Scrape the `Py_GIL_DISABLED` sysconfig var, which is the best way as of today
   to determine whether the target interpreter was built with `--disable-gil`
2. link against the correct libpython
3. On Windows, work around a known issue in the python.org installer with a
   missing define in `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.
@rgommers rgommers requested a review from jpakkane as a code owner June 19, 2024 14:32
@eli-schwartz
Copy link
Member

From a quick look this all makes sense. Will give it a final once-over later today and most likely merge.

@jpakkane jpakkane merged commit a111c28 into mesonbuild:master Jun 23, 2024
33 checks passed
@rgommers rgommers deleted the python-nogil-windows branch June 24, 2024 08:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants