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/Lib/venv/__init__.py b/Lib/venv/__init__.py index 21f82125f5a7c4..002f4ebc988a3b 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -358,6 +358,9 @@ def setup_python(self, context): exe_t = f'3.{sys.version_info[1]}t' python_exe = os.path.join(dirname, f'python{exe_t}{exe_d}.exe') pythonw_exe = os.path.join(dirname, f'pythonw{exe_t}{exe_d}.exe') + if not os.path.isfile(python_exe): + python_exe = os.path.join(dirname, f'python{exe_d}.exe') + pythonw_exe = os.path.join(dirname, f'pythonw{exe_d}.exe') link_sources = { 'python.exe': python_exe, f'python{exe_d}.exe': python_exe, diff --git a/Misc/NEWS.d/next/Build/2026-05-01-12-01-54.gh-issue-148690.oTtYk-.rst b/Misc/NEWS.d/next/Build/2026-05-01-12-01-54.gh-issue-148690.oTtYk-.rst new file mode 100644 index 00000000000000..6845bad2b278de --- /dev/null +++ b/Misc/NEWS.d/next/Build/2026-05-01-12-01-54.gh-issue-148690.oTtYk-.rst @@ -0,0 +1,4 @@ +Windows free-threaded builds now output to a different default path with +default filenames, for example, ``PCbuild/amd64t/python.exe`` rather than +``PCbuild/amd64/python3.15t.exe``. The ``PC/layout`` script has been updated +to ensure compatibility of generated layouts. diff --git a/Misc/NEWS.d/next/Windows/2026-05-01-12-03-39.gh-issue-148690.TMV8dU.rst b/Misc/NEWS.d/next/Windows/2026-05-01-12-03-39.gh-issue-148690.TMV8dU.rst new file mode 100644 index 00000000000000..1fa30f10e0e3dc --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2026-05-01-12-03-39.gh-issue-148690.TMV8dU.rst @@ -0,0 +1,3 @@ +Non-freethreaded builds on Windows now support extensions linked to +``python3t.dll``, and will include a copy of that library in normal installs +that references the non-freethreaded runtime. diff --git a/PC/layout/main.py b/PC/layout/main.py index 8543e7c56e1c41..3566b8bd873874 100644 --- a/PC/layout/main.py +++ b/PC/layout/main.py @@ -127,7 +127,10 @@ def get_tcltk_lib(ns): def get_layout(ns): def in_build(f, dest="", new_name=None, no_lib=False): n, _, x = f.rpartition(".") - n = new_name or n + if new_name and new_name.endswith(f".{x}"): + n = new_name.rpartition(".")[0] + else: + n = new_name or n src = ns.build / f if ns.debug and src not in REQUIRED_DLLS: if not "_d." in src.name: @@ -161,11 +164,12 @@ def in_build(f, dest="", new_name=None, no_lib=False): source = "python_uwp.exe" sourcew = "pythonw_uwp.exe" elif ns.include_freethreaded: - source = "python{}t.exe".format(VER_DOT) - sourcew = "pythonw{}t.exe".format(VER_DOT) if not ns.include_alias: alias = [] aliasw = [] + if (VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4) < (3, 15, 0, 0xB0): + source = "python{}t.exe".format(VER_DOT) + sourcew = "pythonw{}t.exe".format(VER_DOT) alias.extend([ "python{}t".format(VER_DOT), "python{}t".format(VER_MAJOR) if ns.include_alias3 else None, @@ -196,6 +200,8 @@ 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) + if (VER_MAJOR, VER_MINOR, VER_MICRO, VER_FIELD4) >= (3, 15, 0, 0xB0): + yield from in_build(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..62312acf248b91 100644 --- a/PCbuild/_testcapi.vcxproj +++ b/PCbuild/_testcapi.vcxproj @@ -146,6 +146,10 @@ {885d4898-d08d-4091-9c40-c700cfe3fc5a} false + + {947BB5F5-6025-4A4F-8182-1B175469F8D2} + false + diff --git a/PCbuild/_testlimitedcapi.vcxproj b/PCbuild/_testlimitedcapi.vcxproj index 935467dfcb3283..3d70517fbe31e8 100644 --- a/PCbuild/_testlimitedcapi.vcxproj +++ b/PCbuild/_testlimitedcapi.vcxproj @@ -129,6 +129,10 @@ {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..09a989d38648df 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}" @@ -168,6 +171,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_remote_debugging", "_remot EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "_zstd", "_zstd.vcxproj", "{07029B86-F3E9-443E-86FB-78AA6D47FED1}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited_35", "xxlimited_35.vcxproj", "{FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM = Debug|ARM @@ -984,6 +989,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 @@ -1785,6 +1822,38 @@ Global {07029B86-F3E9-443E-86FB-78AA6D47FED1}.Release|Win32.Build.0 = Release|Win32 {07029B86-F3E9-443E-86FB-78AA6D47FED1}.Release|x64.ActiveCfg = Release|x64 {07029B86-F3E9-443E-86FB-78AA6D47FED1}.Release|x64.Build.0 = Release|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|ARM.ActiveCfg = Debug|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|ARM.Build.0 = Debug|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|ARM64.Build.0 = Debug|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|Win32.ActiveCfg = Debug|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|Win32.Build.0 = Debug|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|x64.ActiveCfg = Debug|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Debug|x64.Build.0 = Debug|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|ARM.ActiveCfg = PGInstrument|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|ARM.Build.0 = PGInstrument|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|ARM64.ActiveCfg = PGInstrument|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|ARM64.Build.0 = PGInstrument|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|Win32.Build.0 = PGInstrument|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|x64.ActiveCfg = PGInstrument|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGInstrument|x64.Build.0 = PGInstrument|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|ARM.ActiveCfg = PGUpdate|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|ARM.Build.0 = PGUpdate|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|ARM64.ActiveCfg = PGUpdate|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|ARM64.Build.0 = PGUpdate|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|Win32.Build.0 = PGUpdate|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|x64.ActiveCfg = PGUpdate|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.PGUpdate|x64.Build.0 = PGUpdate|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|ARM.ActiveCfg = Release|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|ARM.Build.0 = Release|ARM + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|ARM64.ActiveCfg = Release|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|ARM64.Build.0 = Release|ARM64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|Win32.ActiveCfg = Release|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|Win32.Build.0 = Release|Win32 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|x64.ActiveCfg = Release|x64 + {FB868EA7-F93A-4D9B-BE78-CA4E9BA14FFF}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props index f79608e1d58dbc..7435c53e3fdcf9 100644 --- a/PCbuild/pyproject.props +++ b/PCbuild/pyproject.props @@ -9,6 +9,7 @@ $(OutDir)\ $(MSBuildThisFileDirectory)obj\ $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\ + $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)t_$(Configuration)\$(ProjectName)\ $(IntDir.Replace(`\\`, `\`)) $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_frozen\ $(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\zlib-ng\ @@ -42,6 +43,10 @@ + <_DebugPreprocessorDefinition>NDEBUG; <_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG; <_PyStatsPreprocessorDefinition>PyStats; @@ -49,15 +54,14 @@ <_PlatformPreprocessorDefinition>_WIN32; <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64; <_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition) - <_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)$(PyDebugExt)"; <_FreeThreadedPreprocessorDefinition Condition="$(DisableGil) == 'true'">Py_GIL_DISABLED=1; <_PymallocHugepagesPreprocessorDefinition Condition="$(UsePymallocHugepages) == 'true'">PYMALLOC_USE_HUGEPAGES=1; + <_PyUsingPgoPreprocessorDefinition Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1; $(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) + WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)$(_FreeThreadedPreprocessorDefinition)$(_PymallocHugepagesPreprocessorDefinition)$(_PyUsingPgoPreprocessorDefinition)%(PreprocessorDefinitions) MaxSpeed true diff --git a/PCbuild/python.props b/PCbuild/python.props index 3ad8d81dfc9a95..998ae6efb7ce94 100644 --- a/PCbuild/python.props +++ b/PCbuild/python.props @@ -43,7 +43,7 @@ $([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\)) $(PySourcePath)\ - + $(PySourcePath)PCbuild\win32\ $(Py_OutDir)\win32\ $(PySourcePath)PCbuild\amd64\ @@ -52,11 +52,34 @@ $(Py_OutDir)\arm32\ $(PySourcePath)PCbuild\arm64\ $(Py_OutDir)\arm64\ + $(PySourcePath)PCbuild\win32t\ + $(Py_OutDir)\win32t\ + $(PySourcePath)PCbuild\amd64t\ + $(Py_OutDir)\amd64t\ + $(PySourcePath)PCbuild\arm32t\ + $(Py_OutDir)\arm32t\ + $(PySourcePath)PCbuild\arm64t\ + $(Py_OutDir)\arm64t\ + + + $(BuildPath32) $(BuildPath64) $(BuildPathArm32) $(BuildPathArm64) $(PySourcePath)PCbuild\$(ArchName)\ + + + + + $(BuildPath32t) + $(BuildPath64t) + $(BuildPathArm32t) + $(BuildPathArm64t) + $(PySourcePath)PCbuild\$(ArchName)t\ + + + $(BuildPath)\ $(BuildPath)instrumented\ @@ -232,18 +255,17 @@ $([msbuild]::Add($(Field3Value), 9000)) - python$(MajorVersionNumber).$(MinorVersionNumber)t python $(BuildPath)$(PyExeName)$(PyDebugExt).exe - pythonw$(MajorVersionNumber).$(MinorVersionNumber)t pythonw python$(MajorVersionNumber)$(MinorVersionNumber)t$(PyDebugExt) python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt) + - python3t python3 + python3t .cp$(MajorVersionNumber)$(MinorVersionNumber)-win32 diff --git a/PCbuild/python3dll.vcxproj b/PCbuild/python3dll.vcxproj index 235ea1cf9d33fb..3d8ac1b23532c1 100644 --- a/PCbuild/python3dll.vcxproj +++ b/PCbuild/python3dll.vcxproj @@ -75,7 +75,7 @@ - $(Py3DllName) + python3 DynamicLibrary diff --git a/PCbuild/python3tdll.vcxproj b/PCbuild/python3tdll.vcxproj new file mode 100644 index 00000000000000..796712cca3146c --- /dev/null +++ b/PCbuild/python3tdll.vcxproj @@ -0,0 +1,110 @@ + + + + + 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 + + + + 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/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index fae4a90b4536fc..f820c3dd64f58c 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -618,7 +618,10 @@ - + + PY3_DLLNAME=L"$(Py3DllName)";%(PreprocessorDefinitions) + ABI3T_DLLNAME=L"$(Abi3tDllName)";%(PreprocessorDefinitions) + diff --git a/PCbuild/readme.txt b/PCbuild/readme.txt index b98a956034c537..c291b7f86325f2 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 + (not installed 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/rt.bat b/PCbuild/rt.bat index f1e0607393405b..d5c9a24f292327 100644 --- a/PCbuild/rt.bat +++ b/PCbuild/rt.bat @@ -32,6 +32,7 @@ setlocal set pcbuild=%~dp0 set pyname=python set suffix= +set suffix1= set qmode= set dashO= set regrtestargs=--fast-ci @@ -41,8 +42,7 @@ set exe= if "%~1"=="-O" (set dashO=-O) & shift & goto CheckOpts if "%~1"=="-q" (set qmode=yes) & shift & goto CheckOpts if "%~1"=="-d" (set suffix=_d) & shift & goto CheckOpts -rem HACK: Need some way to infer the version number in this script -if "%~1"=="--disable-gil" (set pyname=python3.15t) & shift & goto CheckOpts +if "%~1"=="--disable-gil" (set suffix1=t) & shift & goto CheckOpts if "%~1"=="-win32" (set prefix=%pcbuild%win32) & shift & goto CheckOpts if "%~1"=="-x64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts if "%~1"=="-amd64" (set prefix=%pcbuild%amd64) & shift & goto CheckOpts @@ -52,7 +52,7 @@ if "%~1"=="-p" (call :SetPlatform %~2) & shift & shift & goto CheckOpts if NOT "%~1"=="" (set regrtestargs=%regrtestargs% %~1) & shift & goto CheckOpts if not defined prefix set prefix=%pcbuild%amd64 -set exe=%prefix%\%pyname%%suffix%.exe +set exe=%prefix%%suffix1%\%pyname%%suffix%.exe set cmd="%exe%" %dashO% -m test %regrtestargs% if defined qmode goto Qmode @@ -60,7 +60,7 @@ echo Deleting .pyc files ... "%exe%" "%pcbuild%rmpyc.py" echo Cleaning _pth files ... -if exist %prefix%\*._pth del %prefix%\*._pth +if exist %prefix%%suffix1%\*._pth del %prefix%%suffix1%\*._pth echo on %cmd% diff --git a/PCbuild/xxlimited.vcxproj b/PCbuild/xxlimited.vcxproj index 093e6920c0b76c..f0c3616600148f 100644 --- a/PCbuild/xxlimited.vcxproj +++ b/PCbuild/xxlimited.vcxproj @@ -104,6 +104,9 @@ {885d4898-d08d-4091-9c40-c700cfe3fc5a} + + {947BB5F5-6025-4A4F-8182-1B175469F8D2} + diff --git a/PCbuild/xxlimited_35.vcxproj b/PCbuild/xxlimited_35.vcxproj index 3f4d4463f24af0..bfaf4e253664d4 100644 --- a/PCbuild/xxlimited_35.vcxproj +++ b/PCbuild/xxlimited_35.vcxproj @@ -104,6 +104,9 @@ {885d4898-d08d-4091-9c40-c700cfe3fc5a} + + {947BB5F5-6025-4A4F-8182-1B175469F8D2} + diff --git a/PCbuild/zlib-ng.vcxproj b/PCbuild/zlib-ng.vcxproj index de1698ae718473..ffe8e70f2dbbc7 100644 --- a/PCbuild/zlib-ng.vcxproj +++ b/PCbuild/zlib-ng.vcxproj @@ -219,13 +219,15 @@ $([System.IO.File]::ReadAllText('$(zlibNgDir)\zlib.h.in').Replace('@ZLIB_SYMBOL_PREFIX@', '')) - + + $([System.IO.File]::ReadAllText('$(zlibNgDir)\zlib-ng.h.in').Replace('@ZLIB_SYMBOL_PREFIX@', '')) - + + prefix); if (config->prefix) { wcscpy_s(py3path, MAXPATHLEN, config->prefix); - if (py3path[0] && _Py_add_relfile(py3path, L"DLLs\\" PY3_DLLNAME, MAXPATHLEN) >= 0) { + if (py3path[0] && _Py_add_relfile(py3path, L"DLLs\\" PY3_DLLNAME L".dll", MAXPATHLEN) >= 0) { hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); } } return hPython3 != NULL; #undef MAXPATHLEN +#endif /* PY3_DLLNAME */ +} + +/* To support extensions that can load with both abi3 and abi3t, we also need to + * preload python3t.dll. Due to 3.15 still supporting intermingled layouts, the + * check is a bit more complicated on that version as we need to try loading + * from a subdirectory first in case the adjacent python3t.dll is meant for + * python315t.dll (and we are python315.dll). + * ABI3T_DLLNAME is undefined for free-threaded builds, and so this function is + * a no-op (we assume that _Py_CheckPython3 has already been called). + */ +static int +_Py_CheckPython3t(void) +{ +#ifndef ABI3T_DLLNAME + return 1; +#else +#if PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==15 + #define ABI3T_COMPAT_DLLNAME L"abi3t-compat\\" ABI3T_DLLNAME L".dll" +#endif + static int python3t_checked = 0; + static HANDLE hPython3t; + #define MAXPATHLEN 512 + wchar_t py3path[MAXPATHLEN+1]; + if (python3t_checked) { + return hPython3t != NULL; + } + python3t_checked = 1; + + /* If there is a python3t.dll [in the abi3t-compat dir] next to the + python3y.dll, 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); + hPython3t = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + if (hPython3t == NULL) +#endif + { + wcscpy(p + 1, ABI3T_DLLNAME L".dll"); + hPython3t = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS); + } + if (hPython3t) { + return 1; + } + } + } + + /* If we can locate python3.dll in our application dir, + use that DLL */ +#ifdef ABI3T_COMPAT_DLLNAME + hPython3t = LoadLibraryExW(ABI3T_COMPAT_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); + #undef ABI3T_COMPAT_DLLNAME + if (hPython3t == NULL) +#endif + { + hPython3t = LoadLibraryExW(ABI3T_DLLNAME L".dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR); + } + return hPython3t != NULL; + #undef MAXPATHLEN +#endif /* ABI3T_DLLNAME */ } + #endif /* Py_ENABLE_SHARED */ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, @@ -210,6 +278,7 @@ dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix, #ifdef Py_ENABLE_SHARED _Py_CheckPython3(); + _Py_CheckPython3t(); #endif /* Py_ENABLE_SHARED */ wchar_t *wpathname = PyUnicode_AsWideCharString(pathname, NULL); 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..8b21501078ea2e 100644 --- a/Tools/msi/core/core_files.wxs +++ b/Tools/msi/core/core_files.wxs @@ -2,6 +2,9 @@ + + + @@ -19,6 +22,9 @@ + + + diff --git a/Tools/msi/freethreaded/freethreaded_files.wxs b/Tools/msi/freethreaded/freethreaded_files.wxs index 0707e77b5e9ab2..fdbcaea38eb317 100644 --- a/Tools/msi/freethreaded/freethreaded_files.wxs +++ b/Tools/msi/freethreaded/freethreaded_files.wxs @@ -29,7 +29,7 @@ - + @@ -37,68 +37,72 @@ - + - + - + - + - + - + + - + - + - + - - + + - + - + - + - + - + - + @@ -111,16 +115,16 @@ - + - + - + @@ -132,16 +136,16 @@ - + - + - + @@ -151,21 +155,21 @@ - + - + - - + + - - + + diff --git a/Tools/msi/msi.props b/Tools/msi/msi.props index 372c4823bce07f..097af60715448f 100644 --- a/Tools/msi/msi.props +++ b/Tools/msi/msi.props @@ -122,6 +122,30 @@ + + + build + + + build + + + build + + + build_t + + + build_t + + + build_t + + src @@ -131,6 +155,7 @@ redist + build32 @@ -140,6 +165,15 @@ buildarm64 + + build32t + + + build64t + + + buildarm64t +