]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115582: Make default PC/pyconfig.h work for free-threaded builds with manual ...
authorSteve Dower <steve.dower@python.org>
Mon, 26 Feb 2024 19:14:14 +0000 (19:14 +0000)
committerGitHub <noreply@github.com>
Mon, 26 Feb 2024 19:14:14 +0000 (19:14 +0000)
Misc/NEWS.d/next/Windows/2024-02-23-11-43-43.gh-issue-115582.sk1XPi.rst [new file with mode: 0644]
PC/pyconfig.h.in
PCbuild/pythoncore.vcxproj

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 (file)
index 0000000..f2e82bf
--- /dev/null
@@ -0,0 +1,3 @@
+Building extensions intended for free-threaded builds of CPython now require
+compiling with ``/DPy_GIL_DISABLED`` manually when using a regular install. This
+is expected to change in future releases.
index 8bbf877a5bb5edc7c692c0e6bc2f18d52a0c56b4..d72d6282c2806f1770d7b7a9a9bab67311425453 100644 (file)
@@ -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 */
 
index c7b698f0e17a396acb2634ee825e3092da42daa1..ef21f85107bc32df8102af4fbd309c4582c13edb 100644 (file)
       <OldPyConfigH Condition="Exists('$(IntDir)pyconfig.h')">$([System.IO.File]::ReadAllText('$(IntDir)pyconfig.h'))</OldPyConfigH>
     </PropertyGroup>
     <PropertyGroup Condition="$(DisableGil) == 'true'">
-      <PyConfigHText>$(PyConfigHText.Replace('#undef Py_GIL_DISABLED', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
+      <PyConfigHText>$(PyConfigHText.Replace('/* #define Py_GIL_DISABLED 1 */', '#define Py_GIL_DISABLED 1'))</PyConfigHText>
     </PropertyGroup>
     <Message Text="Updating pyconfig.h" Condition="$(PyConfigHText.TrimEnd()) != $(OldPyConfigH.TrimEnd())" />
     <WriteLinesToFile File="$(IntDir)pyconfig.h"