From 214f8d48ba62f5c849d532b9ec000e78e13b1a7a Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Fri, 23 Feb 2024 11:44:19 +0000 Subject: [PATCH 1/3] gh-115582: Make default PC/pyconfig.h work for free-threaded builds with manual /DPy_GIL_DISABLED --- .../Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst | 3 +++ PC/pyconfig.h.in | 7 ++++++- PCbuild/pythoncore.vcxproj | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst diff --git a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst new file mode 100644 index 00000000000000..ff5dd1e20efb0a --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst @@ -0,0 +1,3 @@ +Building extensions intended for free-threaded builds of CPython now require +defining :env:`Py_GIL_DISABLED` manually when using a regular install. This +is expected to change in future releases. diff --git a/PC/pyconfig.h.in b/PC/pyconfig.h.in index 8bbf877a5bb5ed..d72d6282c2806f 100644 --- a/PC/pyconfig.h.in +++ b/PC/pyconfig.h.in @@ -95,7 +95,12 @@ WIN32 is still required for the locale module. #endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */ /* Define to 1 if you want to disable the GIL */ -#undef Py_GIL_DISABLED +/* Uncomment the definition for free-threaded builds, or define it manually + * when compiling extension modules. Note that we test with #ifdef, so + * defining as 0 will still disable the GIL. */ +#ifndef Py_GIL_DISABLED +/* #define Py_GIL_DISABLED 1 */ +#endif /* Compiler specific defines */ diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index c7b698f0e17a39..ef21f85107bc32 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -677,7 +677,7 @@ $([System.IO.File]::ReadAllText('$(IntDir)pyconfig.h')) - $(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1')) + $(PyConfigHText.Replace('/* #define Py_GIL_DISABLED 1 */', '#define Py_GIL_DISABLED 1')) Date: Fri, 23 Feb 2024 11:54:08 +0000 Subject: [PATCH 2/3] Fix role --- .../next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst index ff5dd1e20efb0a..209d356f96eeb4 100644 --- a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst +++ b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst @@ -1,3 +1,3 @@ Building extensions intended for free-threaded builds of CPython now require -defining :env:`Py_GIL_DISABLED` manually when using a regular install. This +defining :envvar:`Py_GIL_DISABLED` manually when using a regular install. This is expected to change in future releases. From 625b72bbbe84905227744212939e4e0a2c755197 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Mon, 26 Feb 2024 17:26:29 +0000 Subject: [PATCH 3/3] More appropriate NEWS suggestion --- .../next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst index 209d356f96eeb4..f2e82bf6a3e028 100644 --- a/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst +++ b/Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst @@ -1,3 +1,3 @@ Building extensions intended for free-threaded builds of CPython now require -defining :envvar:`Py_GIL_DISABLED` manually when using a regular install. This +compiling with ``/DPy_GIL_DISABLED`` manually when using a regular install. This is expected to change in future releases.