diff --git a/Include/pyabi.h b/Include/pyabi.h
index 8c4ae281a43faf..21a6ab0c1ee6ea 100644
--- a/Include/pyabi.h
+++ b/Include/pyabi.h
@@ -55,6 +55,8 @@
*
* (Don't use Py_TARGET_ABI3T directly. It's currently only used to set these
* 2 macros, and defined for users' convenience.)
+ *
+ * This logic is currently partially duplicated in PC/pyconfig.h.
*/
#if defined(Py_LIMITED_API) && defined(Py_GIL_DISABLED) \
&& !defined(Py_TARGET_ABI3T)
diff --git a/PC/pyconfig.h b/PC/pyconfig.h
index a126fca6f5aafb..72a475777b7ad0 100644
--- a/PC/pyconfig.h
+++ b/PC/pyconfig.h
@@ -331,7 +331,7 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# if defined(Py_GIL_DISABLED)
# if defined(Py_DEBUG)
# pragma comment(lib,"python315t_d.lib")
-# elif defined(Py_LIMITED_API)
+# elif defined(Py_LIMITED_API) || defined(Py_TARGET_ABI3T)
# pragma comment(lib,"python3t.lib")
# else
# pragma comment(lib,"python315t.lib")
@@ -339,6 +339,8 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
# else /* Py_GIL_DISABLED */
# if defined(Py_DEBUG)
# pragma comment(lib,"python315_d.lib")
+# elif defined(Py_TARGET_ABI3T)
+# pragma comment(lib,"python3t.lib")
# elif defined(Py_LIMITED_API)
# pragma comment(lib,"python3.lib")
# else
diff --git a/PCbuild/abi3t-compat.vcxproj b/PCbuild/abi3t-compat.vcxproj
new file mode 100644
index 00000000000000..48ae567aef832f
--- /dev/null
+++ b/PCbuild/abi3t-compat.vcxproj
@@ -0,0 +1,113 @@
+
+
+
+
+ Debug
+ ARM
+
+
+ Debug
+ ARM64
+
+
+ Debug
+ Win32
+
+
+ Debug
+ x64
+
+
+ PGInstrument
+ ARM
+
+
+ PGInstrument
+ ARM64
+
+
+ PGInstrument
+ Win32
+
+
+ PGInstrument
+ x64
+
+
+ PGUpdate
+ ARM
+
+
+ PGUpdate
+ ARM64
+
+
+ PGUpdate
+ Win32
+
+
+ PGUpdate
+ x64
+
+
+ Release
+ ARM
+
+
+ Release
+ ARM64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+ abi3t-compat
+ Win32Proj
+ false
+
+
+
+
+ $(PyAbi3tCompatDllName)
+ DynamicLibrary
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+
+
+ $(BuildPath)$(PyAbi3tCompatDllDir)\
+
+
+
+ PYTHON_DLL_NAME="$(PyDllName)";%(PreprocessorDefinitions)
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PCbuild/abi3t-compat.vcxproj.filters b/PCbuild/abi3t-compat.vcxproj.filters
new file mode 100644
index 00000000000000..37510e3c7398f2
--- /dev/null
+++ b/PCbuild/abi3t-compat.vcxproj.filters
@@ -0,0 +1,23 @@
+
+
+
+
+ {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
+ cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
+
+
+ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
+ rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav
+
+
+
+
+ Source Files
+
+
+
+
+ Resource Files
+
+
+
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj
index 7a5327bf016cea..71958f92b24328 100644
--- a/PCbuild/pcbuild.proj
+++ b/PCbuild/pcbuild.proj
@@ -61,6 +61,8 @@
+
+
diff --git a/PCbuild/pcbuild.sln b/PCbuild/pcbuild.sln
index 7296ea75301157..f6d445822e6dfe 100644
--- a/PCbuild/pcbuild.sln
+++ b/PCbuild/pcbuild.sln
@@ -33,6 +33,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcxproj",
{78D80A15-BD8C-44E2-B49E-1F05B0A0A687} = {78D80A15-BD8C-44E2-B49E-1F05B0A0A687}
{86937F53-C189-40EF-8CE8-8759D8E7D480} = {86937F53-C189-40EF-8CE8-8759D8E7D480}
{885D4898-D08D-4091-9C40-C700CFE3FC5A} = {885D4898-D08D-4091-9C40-C700CFE3FC5A}
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2} = {947BB5F5-6025-4A4F-8182-1B175469F8D2}
{900342D7-516A-4469-B1AD-59A66E49A25F} = {900342D7-516A-4469-B1AD-59A66E49A25F}
{9E48B300-37D1-11DD-8C41-005056C00008} = {9E48B300-37D1-11DD-8C41-005056C00008}
{9EC7190A-249F-4180-A900-548FDCF3055F} = {9EC7190A-249F-4180-A900-548FDCF3055F}
@@ -104,6 +105,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_multiprocessing", "_multip
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3dll", "python3dll.vcxproj", "{885D4898-D08D-4091-9C40-C700CFE3FC5A}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "abi3t-compat", "abi3t-compat.vcxproj", "{947BB5F5-6025-4A4F-8182-1B175469F8D2}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited", "xxlimited.vcxproj", "{F749B822-B489-4CA5-A3AD-CE078F5F338A}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_testbuffer", "_testbuffer.vcxproj", "{A2697BD3-28C1-4AEC-9106-8B748639FD16}"
@@ -984,6 +987,38 @@ Global
{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|Win32.Build.0 = Release|Win32
{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|x64.ActiveCfg = Release|x64
{885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|x64.Build.0 = Release|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|ARM.ActiveCfg = Debug|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|ARM.Build.0 = Debug|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|ARM64.ActiveCfg = Debug|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|ARM64.Build.0 = Debug|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|Win32.Build.0 = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|x64.ActiveCfg = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Debug|x64.Build.0 = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|ARM.Build.0 = PGInstrument|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|Win32.ActiveCfg = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|Win32.Build.0 = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|x64.ActiveCfg = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGInstrument|x64.Build.0 = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|ARM.Build.0 = PGUpdate|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|Win32.ActiveCfg = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|Win32.Build.0 = Debug|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|x64.ActiveCfg = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.PGUpdate|x64.Build.0 = Debug|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|ARM.ActiveCfg = Release|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|ARM.Build.0 = Release|ARM
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|ARM64.ActiveCfg = Release|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|ARM64.Build.0 = Release|ARM64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|Win32.ActiveCfg = Release|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|Win32.Build.0 = Release|Win32
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|x64.ActiveCfg = Release|x64
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}.Release|x64.Build.0 = Release|x64
{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|ARM.ActiveCfg = Debug|ARM
{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|ARM64.ActiveCfg = Debug|ARM64
{F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|Win32.ActiveCfg = Release|Win32
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index 94ae718d58c4ba..5cff8777be6c40 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -49,6 +49,7 @@
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition)
<_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)$(PyDebugExt)";
+ <_Abi3tCompatDllNamePreprocessorDefinition Condition="$(DisableGil) != 'true'">ABI3T_COMPAT_DLLNAME=L"$(PyAbi3tCompatDllDir)\\$(PyAbi3tCompatDllName)$(PyDebugExt)";
<_FreeThreadedPreprocessorDefinition Condition="$(DisableGil) == 'true'">Py_GIL_DISABLED=1;
<_PymallocHugepagesPreprocessorDefinition Condition="$(UsePymallocHugepages) == 'true'">PYMALLOC_USE_HUGEPAGES=1;
@@ -57,6 +58,7 @@
$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(PySourcePath)PC;%(AdditionalIncludeDirectories)
WIN32;$(_Py3NamePreprocessorDefinition)$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)$(_FreeThreadedPreprocessorDefinition)$(_PymallocHugepagesPreprocessorDefinition)%(PreprocessorDefinitions)
_Py_USING_PGO=1;%(PreprocessorDefinitions)
+ $(_Abi3tCompatDllNamePreprocessorDefinition)%(PreprocessorDefinitions)
MaxSpeed
true
diff --git a/PCbuild/python.props b/PCbuild/python.props
index 3ad8d81dfc9a95..28175e6b1b8f2e 100644
--- a/PCbuild/python.props
+++ b/PCbuild/python.props
@@ -244,6 +244,9 @@
python3t
python3
+
+ abi3t-compat
+ python3t
.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index de9b0a77817a63..b479595192ec84 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -169,7 +169,16 @@ _Py_CheckPython3(void)
use that DLL */
if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, py3path, MAXPATHLEN)) {
wchar_t *p = wcsrchr(py3path, L'\\');
+
if (p) {
+#ifdef ABI3T_COMPAT_DLLNAME
+ wcscpy(p + 1, ABI3T_COMPAT_DLLNAME);
+ hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+ if (hPython3 != NULL) {
+ return 1;
+ }
+#endif
+
wcscpy(p + 1, PY3_DLLNAME);
hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (hPython3 != NULL) {
@@ -178,6 +187,13 @@ _Py_CheckPython3(void)
}
}
+#ifdef ABI3T_COMPAT_DLLNAME
+ hPython3 = LoadLibraryExW(ABI3T_COMPAT_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
+ if (hPython3 != NULL) {
+ return 1;
+ }
+#endif
+
/* If we can locate python3.dll in our application dir,
use that DLL */
hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
diff --git a/Tools/msi/core/core_files.wxs b/Tools/msi/core/core_files.wxs
index 145e1471247aa1..b481d17a7b9397 100644
--- a/Tools/msi/core/core_files.wxs
+++ b/Tools/msi/core/core_files.wxs
@@ -2,6 +2,9 @@
+
+
+