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/layout/main.py b/PC/layout/main.py
index 8543e7c56e1c41..bba9086589ab0f 100644
--- a/PC/layout/main.py
+++ b/PC/layout/main.py
@@ -196,6 +196,7 @@ def in_build(f, dest="", new_name=None, no_lib=False):
yield from in_build(FREETHREADED_PYTHON_STABLE_DLL_NAME)
else:
yield from in_build(PYTHON_STABLE_DLL_NAME)
+ yield from in_build(f"abi3t-compat\\{FREETHREADED_PYTHON_STABLE_DLL_NAME}")
found_any = False
for dest, src in rglob(ns.build, "vcruntime*.dll"):
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/_remote_debugging.vcxproj b/PCbuild/_remote_debugging.vcxproj
index 0e86ce9f4c918c..b58e172906dfc6 100644
--- a/PCbuild/_remote_debugging.vcxproj
+++ b/PCbuild/_remote_debugging.vcxproj
@@ -125,6 +125,10 @@
{885d4898-d08d-4091-9c40-c700cfe3fc5a}
false
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+ false
+
diff --git a/PCbuild/_testcapi.vcxproj b/PCbuild/_testcapi.vcxproj
index 68707a54ff6b87..4725787c59aad3 100644
--- a/PCbuild/_testcapi.vcxproj
+++ b/PCbuild/_testcapi.vcxproj
@@ -142,10 +142,14 @@
{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}
false
-
+
{885d4898-d08d-4091-9c40-c700cfe3fc5a}
false
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+ false
+
diff --git a/PCbuild/_testlimitedcapi.vcxproj b/PCbuild/_testlimitedcapi.vcxproj
index 935467dfcb3283..af11527d43d3ae 100644
--- a/PCbuild/_testlimitedcapi.vcxproj
+++ b/PCbuild/_testlimitedcapi.vcxproj
@@ -125,10 +125,14 @@
{cf7ac3d1-e2df-41d2-bea6-1e2556cdea26}
false
-
+
{885d4898-d08d-4091-9c40-c700cfe3fc5a}
false
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+ false
+
diff --git a/PCbuild/pcbuild.proj b/PCbuild/pcbuild.proj
index 7a5327bf016cea..bb7d8042176d8f 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..b77f3f30d7a977 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}") = "python3tdll", "python3tdll.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 f79608e1d58dbc..271f39f4400427 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -49,7 +49,9 @@
<_PlatformPreprocessorDefinition>_WIN32;
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition)
- <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)$(PyDebugExt)";
+ <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"python3$(PyDebugExt)";
+ <_Abi3tCompatDllNamePreprocessorDefinition Condition="$(DisableGil) != 'true'">ABI3T_COMPAT_DLLNAME=L"abi3t-compat\\python3t$(PyDebugExt)";
+ <_Abi3tDllNamePreprocessorDefinition Condition="$(DisableGil) != 'true'">ABI3T_DLLNAME=L"python3t$(PyDebugExt)";
<_FreeThreadedPreprocessorDefinition Condition="$(DisableGil) == 'true'">Py_GIL_DISABLED=1;
<_PymallocHugepagesPreprocessorDefinition Condition="$(UsePymallocHugepages) == 'true'">PYMALLOC_USE_HUGEPAGES=1;
@@ -58,6 +60,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)$(_Abi3tDllNamePreprocessorDefinition)%(PreprocessorDefinitions)
MaxSpeed
true
diff --git a/PCbuild/python.props b/PCbuild/python.props
index 3ad8d81dfc9a95..709a2e6bc57099 100644
--- a/PCbuild/python.props
+++ b/PCbuild/python.props
@@ -241,9 +241,6 @@
python$(MajorVersionNumber)$(MinorVersionNumber)t$(PyDebugExt)
python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)
-
- python3t
- python3
.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32
diff --git a/PCbuild/python3dll.vcxproj b/PCbuild/python3dll.vcxproj
index 235ea1cf9d33fb..6f715eb5773752 100644
--- a/PCbuild/python3dll.vcxproj
+++ b/PCbuild/python3dll.vcxproj
@@ -75,7 +75,7 @@
- $(Py3DllName)
+ python3
DynamicLibrary
@@ -89,6 +89,9 @@
<_ProjectFileVersion>10.0.30319.1
+
+ $(BuildPath)abi3t-compat\
+
PYTHON_DLL_NAME="$(PyDllName)";%(PreprocessorDefinitions)
diff --git a/PCbuild/python3tdll.vcxproj b/PCbuild/python3tdll.vcxproj
new file mode 100644
index 00000000000000..0aa3de80fccc9e
--- /dev/null
+++ b/PCbuild/python3tdll.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}
+ python3tdll
+ Win32Proj
+ false
+
+
+
+
+ python3t
+ DynamicLibrary
+
+
+
+
+
+
+
+
+
+
+ <_ProjectFileVersion>10.0.30319.1
+
+
+ $(BuildPath)abi3t-compat\
+
+
+
+ PYTHON_DLL_NAME="$(PyDllName)";%(PreprocessorDefinitions)
+ false
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/PCbuild/python3tdll.vcxproj.filters b/PCbuild/python3tdll.vcxproj.filters
new file mode 100644
index 00000000000000..37510e3c7398f2
--- /dev/null
+++ b/PCbuild/python3tdll.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/readme.txt b/PCbuild/readme.txt
index b98a956034c537..3f41be7cff7570 100644
--- a/PCbuild/readme.txt
+++ b/PCbuild/readme.txt
@@ -160,6 +160,10 @@ pyshellext
pyshellext.dll, the shell extension deployed with the launcher
python3dll
python3.dll, the PEP 384 Stable ABI dll
+ (missing on free-threaded builds)
+python3tdll
+ python3t.dll, the PEP 803 free-threading Stable ABI dll
+ (built from the same source as python3.dll)
xxlimited
builds an example module that makes use of the PEP 384 Stable ABI,
see Modules\xxlimited.c
diff --git a/PCbuild/xxlimited.vcxproj b/PCbuild/xxlimited.vcxproj
index 093e6920c0b76c..3de2ee1a18a32b 100644
--- a/PCbuild/xxlimited.vcxproj
+++ b/PCbuild/xxlimited.vcxproj
@@ -101,9 +101,12 @@
-
+
{885d4898-d08d-4091-9c40-c700cfe3fc5a}
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+
diff --git a/PCbuild/xxlimited_35.vcxproj b/PCbuild/xxlimited_35.vcxproj
index 3f4d4463f24af0..c1115fc0c3f811 100644
--- a/PCbuild/xxlimited_35.vcxproj
+++ b/PCbuild/xxlimited_35.vcxproj
@@ -101,9 +101,12 @@
-
+
{885d4898-d08d-4091-9c40-c700cfe3fc5a}
+
+ {947BB5F5-6025-4A4F-8182-1B175469F8D2}
+
diff --git a/Python/dynload_win.c b/Python/dynload_win.c
index de9b0a77817a63..84b0a94f69dd58 100644
--- a/Python/dynload_win.c
+++ b/Python/dynload_win.c
@@ -169,22 +169,53 @@ _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) {
return 1;
}
+
+#ifdef ABI3T_DLLNAME
+ wcscpy(p + 1, ABI3T_DLLNAME);
+ hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
+ if (hPython3 != NULL) {
+ return 1;
+ }
+#endif
}
}
/* If we can locate python3.dll in our application dir,
use that DLL */
+#ifdef ABI3T_COMPAT_DLLNAME
+ hPython3 = LoadLibraryExW(ABI3T_COMPAT_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
+ if (hPython3 != NULL) {
+ return 1;
+ }
+#endif
+
hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
if (hPython3 != NULL) {
return 1;
}
+#ifdef ABI3T_DLLNAME
+ hPython3 = LoadLibraryExW(ABI3T_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
+ if (hPython3 != NULL) {
+ return 1;
+ }
+#endif
+
/* For back-compat, also search {sys.prefix}\DLLs, though
that has not been a normal install layout for a while */
PyInterpreterState *interp = _PyInterpreterState_GET();
diff --git a/Tools/msi/common.wxs b/Tools/msi/common.wxs
index 54fa749ab17cdd..73da474e4181f1 100644
--- a/Tools/msi/common.wxs
+++ b/Tools/msi/common.wxs
@@ -75,6 +75,12 @@
+
+
+
+
+
+
diff --git a/Tools/msi/core/core_files.wxs b/Tools/msi/core/core_files.wxs
index 145e1471247aa1..a55b47ff2aa6dc 100644
--- a/Tools/msi/core/core_files.wxs
+++ b/Tools/msi/core/core_files.wxs
@@ -2,6 +2,9 @@
+
+
+