https://github.com/python/cpython/commit/c612fd4cf363cf1af28bb67f11b4a11dca57507f
commit: c612fd4cf363cf1af28bb67f11b4a11dca57507f
branch: main
author: Andrej730 <[email protected]>
committer: zooba <[email protected]>
date: 2026-08-18T15:07:19+01:00
summary:

PC/pyconfig.h: Improve readability of implicit .lib linking (GH-155995)

files:
M PC/pyconfig.h

diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index 2381ed3772b109e..22c3ccc05bb004e 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -317,39 +317,33 @@ Py_NO_ENABLE_SHARED to find out.  Also support 
MS_NO_COREDLL for b/w compat */
 /*  All windows compilers that use this header support __declspec */
 #define HAVE_DECLSPEC_DLL
 
-/* For an MSVC DLL, we can nominate the .lib files used by extensions */
-#ifdef MS_COREDLL
-#       if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
-                /* not building the core - must be an ext */
-#               if defined(_MSC_VER) && !defined(Py_NO_LINK_LIB)
-                        /* So MSVC users need not specify the .lib
-                        file in their Makefile */
-                        /* Define Py_NO_LINK_LIB to build extension disabling 
pragma
-                        based auto-linking.
-                        This is relevant when using build-system generator 
(e.g CMake) where
-                        the linking is explicitly handled */
-#                       if defined(Py_GIL_DISABLED)
-#                       if defined(Py_DEBUG)
-#                               pragma comment(lib,"python316t_d.lib")
-#                       elif defined(Py_LIMITED_API) || 
defined(Py_TARGET_ABI3T)
-#                               pragma comment(lib,"python3t.lib")
-#                       else
-#                               pragma comment(lib,"python316t.lib")
-#                       endif /* Py_DEBUG */
-#                       else /* Py_GIL_DISABLED */
-#                       if defined(Py_DEBUG)
-#                               pragma comment(lib,"python316_d.lib")
-#                       elif defined(Py_TARGET_ABI3T)
-#                               pragma comment(lib,"python3t.lib")
-#                       elif defined(Py_LIMITED_API)
-#                               pragma comment(lib,"python3.lib")
-#                       else
-#                               pragma comment(lib,"python316.lib")
-#                       endif /* Py_DEBUG */
-#                       endif /* Py_GIL_DISABLED */
-#               endif /* _MSC_VER && !Py_NO_LINK_LIB */
-#       endif /* Py_BUILD_CORE */
-#endif /* MS_COREDLL */
+/* Automatic linking of extension python3x.lib files for MSVC DLLs.
+   This lets MSVC users build extensions without manually specifying .lib 
files.
+   Define Py_NO_LINK_LIB to disable this behavior. */
+#if !defined(Py_NO_LINK_LIB) \
+    && defined(_MSC_VER) && defined(Py_ENABLE_SHARED) \
+    && !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
+        /* not building the core - must be an ext */
+#       if defined(Py_GIL_DISABLED)
+#           if defined(Py_DEBUG)
+#               pragma comment(lib,"python316t_d.lib")
+#           elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T)
+#               pragma comment(lib,"python3t.lib")
+#           else
+#               pragma comment(lib,"python316t.lib")
+#           endif /* Py_DEBUG */
+#       else
+#           if defined(Py_DEBUG)
+#               pragma comment(lib,"python316_d.lib")
+#           elif defined(Py_TARGET_ABI3T)
+#               pragma comment(lib,"python3t.lib")
+#           elif defined(Py_LIMITED_API)
+#               pragma comment(lib,"python3.lib")
+#           else
+#               pragma comment(lib,"python316.lib")
+#           endif /* Py_DEBUG */
+#       endif /* Py_GIL_DISABLED */
+#endif
 
 #ifdef MS_WIN64
 /* maintain "win32" sys.platform for backward compatibility of Python code,

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to