From a111c28ecef721af960721c26b40f4e5108760c7 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Mon, 27 May 2024 22:55:39 +0200 Subject: Add support for detecting free-threaded Python on Windows 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. --- mesonbuild/scripts/python_info.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'mesonbuild/scripts/python_info.py') diff --git a/mesonbuild/scripts/python_info.py b/mesonbuild/scripts/python_info.py index 5b048ca42..6aab38045 100755 --- a/mesonbuild/scripts/python_info.py +++ b/mesonbuild/scripts/python_info.py @@ -106,6 +106,9 @@ if sys.version_info >= (3, 2): if is_pypy: limited_api_suffix = suffix +# Whether we're targeting a free-threaded CPython interpreter +is_freethreaded = bool(variables.get('Py_GIL_DISABLED', False)) + print(json.dumps({ 'variables': variables, 'paths': paths, @@ -118,4 +121,5 @@ print(json.dumps({ 'link_libpython': links_against_libpython(), 'suffix': suffix, 'limited_api_suffix': limited_api_suffix, + 'is_freethreaded': is_freethreaded, })) -- cgit v1.2.3