gh-148690: Build Windows freethreaded binaries into separate directory and include python3t.dll on GIL-enabled (GH-149218)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
Steve Dower
2026-05-04 17:45:08 +01:00
committed by GitHub
parent 9846407eaf
commit 10f950c9bb
32 changed files with 488 additions and 78 deletions
+2
View File
@@ -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)
+5
View File
@@ -8,6 +8,8 @@ import os.path
import shlex
import shutil
import subprocess
import sysconfig
import sys
import unittest
from test import support
@@ -62,6 +64,9 @@ class BaseTests:
env['CPYTHON_TEST_LIMITED'] = '1'
if abi3t:
env['CPYTHON_TEST_ABI3T'] = '1'
if support.MS_WINDOWS and sysconfig.is_python_build():
env['CPYTHON_EXTRA_INCDIRS'] = os.path.split(sysconfig.get_config_h_filename())[0]
env['CPYTHON_EXTRA_LIBDIRS'] = os.path.split(sys.executable)[0]
env['CPYTHON_TEST_EXT_NAME'] = extension_name
env['TEST_INTERNAL_C_API'] = str(int(self.TEST_INTERNAL_C_API))
if support.verbose:
+10 -12
View File
@@ -1,7 +1,6 @@
# gh-91321: Build a basic C test extension to check that the Python C API is
# compatible with C and does not emit C compiler warnings.
import os
import platform
import shlex
import sys
import sysconfig
@@ -66,6 +65,8 @@ def main():
limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", ""))
abi3t = bool(os.environ.get("CPYTHON_TEST_ABI3T", ""))
internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0")))
incdirs = os.environ.get("CPYTHON_EXTRA_INCDIRS", "")
libdirs = os.environ.get("CPYTHON_EXTRA_LIBDIRS", "")
sources = [SOURCE]
@@ -106,19 +107,16 @@ def main():
if internal:
cflags.append('-DTEST_INTERNAL_C_API=1')
# On Windows, add PCbuild\amd64\ to include and library directories
# Add additional include and library directories, typically for in-tree
# testing where not all directories are inferred
include_dirs = []
library_dirs = []
if support.MS_WINDOWS:
srcdir = sysconfig.get_config_var('srcdir')
machine = platform.uname().machine
pcbuild = os.path.join(srcdir, 'PCbuild', machine)
if os.path.exists(pcbuild):
# pyconfig.h is generated in PCbuild\amd64\
include_dirs.append(pcbuild)
# python313.lib is generated in PCbuild\amd64\
library_dirs.append(pcbuild)
print(f"Add PCbuild directory: {pcbuild}")
if incdirs:
print("Add incdirs:", incdirs)
include_dirs.extend(incdirs.split(os.pathsep))
if libdirs:
print("Add libdirs:", libdirs)
library_dirs.extend(libdirs.split(os.pathsep))
# Display information to help debugging
for env_name in ('CC', 'CFLAGS', 'CPPFLAGS'):
+4
View File
@@ -6,6 +6,7 @@ import shlex
import shutil
import subprocess
import sys
import sysconfig
import unittest
from test import support
@@ -50,6 +51,9 @@ class BaseTests:
env['CPYTHON_TEST_CPP_STD'] = std
if limited:
env['CPYTHON_TEST_LIMITED'] = '1'
if support.MS_WINDOWS and sysconfig.is_python_build():
env['CPYTHON_EXTRA_INCDIRS'] = os.path.split(sysconfig.get_config_h_filename())[0]
env['CPYTHON_EXTRA_LIBDIRS'] = os.path.split(sys.executable)[0]
env['CPYTHON_TEST_EXT_NAME'] = extension_name
env['TEST_INTERNAL_C_API'] = str(int(self.TEST_INTERNAL_C_API))
if extra_cflags:
+10 -12
View File
@@ -1,7 +1,6 @@
# gh-91321: Build a basic C++ test extension to check that the Python C API is
# compatible with C++ and does not emit C++ compiler warnings.
import os
import platform
import shlex
import sys
import sysconfig
@@ -48,6 +47,8 @@ def main():
module_name = os.environ["CPYTHON_TEST_EXT_NAME"]
limited = bool(os.environ.get("CPYTHON_TEST_LIMITED", ""))
internal = bool(int(os.environ.get("TEST_INTERNAL_C_API", "0")))
incdirs = os.environ.get("CPYTHON_EXTRA_INCDIRS", "")
libdirs = os.environ.get("CPYTHON_EXTRA_LIBDIRS", "")
cppflags = list(CPPFLAGS)
cppflags.append(f'-DMODULE_NAME={module_name}')
@@ -90,19 +91,16 @@ def main():
if extra_cflags:
cppflags.extend(shlex.split(extra_cflags))
# On Windows, add PCbuild\amd64\ to include and library directories
# Add additional include and library directories, typically for in-tree
# testing where not all directories are inferred
include_dirs = []
library_dirs = []
if support.MS_WINDOWS:
srcdir = sysconfig.get_config_var('srcdir')
machine = platform.uname().machine
pcbuild = os.path.join(srcdir, 'PCbuild', machine)
if os.path.exists(pcbuild):
# pyconfig.h is generated in PCbuild\amd64\
include_dirs.append(pcbuild)
# python313.lib is generated in PCbuild\amd64\
library_dirs.append(pcbuild)
print(f"Add PCbuild directory: {pcbuild}")
if incdirs:
print("Add incdirs:", incdirs)
include_dirs.extend(incdirs.split(os.pathsep))
if libdirs:
print("Add libdirs:", libdirs)
library_dirs.extend(libdirs.split(os.pathsep))
# Display information to help debugging
for env_name in ('CC', 'CXX', 'CFLAGS', 'CPPFLAGS', 'CXXFLAGS'):
+3
View File
@@ -358,6 +358,9 @@ class EnvBuilder:
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,
@@ -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.
@@ -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.
+9 -3
View File
@@ -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 get_layout(ns):
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 get_layout(ns):
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"):
+3 -1
View File
@@ -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
+4
View File
@@ -128,6 +128,10 @@
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="python3tdll.vcxproj">
<Project>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+4
View File
@@ -146,6 +146,10 @@
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="python3tdll.vcxproj">
<Project>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+4
View File
@@ -129,6 +129,10 @@
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="python3tdll.vcxproj">
<Project>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+2
View File
@@ -61,6 +61,8 @@
</Projects>
<!-- python3.dll -->
<Projects Include="python3dll.vcxproj" />
<!-- python3t.dll -->
<Projects Include="python3tdll.vcxproj" />
<!-- py[w].exe -->
<Projects Include="pylauncher.vcxproj;pywlauncher.vcxproj" />
<!-- pyshellext.dll -->
+69
View File
@@ -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
+7 -3
View File
@@ -9,6 +9,7 @@
<OutDir Condition="!HasTrailingSlash($(OutDir))">$(OutDir)\</OutDir>
<Py_IntDir Condition="'$(Py_IntDir)' == ''">$(MSBuildThisFileDirectory)obj\</Py_IntDir>
<IntDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\$(ProjectName)\</IntDir>
<IntDir Condition="$(DisableGil) == 'true'">$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)t_$(Configuration)\$(ProjectName)\</IntDir>
<IntDir>$(IntDir.Replace(`\\`, `\`))</IntDir>
<GeneratedFrozenModulesDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)_frozen\</GeneratedFrozenModulesDir>
<GeneratedZlibNgDir>$(Py_IntDir)\$(MajorVersionNumber)$(MinorVersionNumber)$(ArchName)_$(Configuration)\zlib-ng\</GeneratedZlibNgDir>
@@ -42,6 +43,10 @@
</PropertyGroup>
<PropertyGroup>
<!--
We conditionally define preprocessor definitions here, and then include all
the properties *unconditionally* in the <PreprocessorDefinition> field below
-->
<_DebugPreprocessorDefinition>NDEBUG;</_DebugPreprocessorDefinition>
<_DebugPreprocessorDefinition Condition="$(Configuration) == 'Debug'">_DEBUG;</_DebugPreprocessorDefinition>
<_PyStatsPreprocessorDefinition>PyStats;</_PyStatsPreprocessorDefinition>
@@ -49,15 +54,14 @@
<_PlatformPreprocessorDefinition>_WIN32;</_PlatformPreprocessorDefinition>
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64'">_WIN64;</_PlatformPreprocessorDefinition>
<_PlatformPreprocessorDefinition Condition="$(Platform) == 'x64' and $(PlatformToolset) != 'ClangCL'">_M_X64;$(_PlatformPreprocessorDefinition)</_PlatformPreprocessorDefinition>
<_Py3NamePreprocessorDefinition>PY3_DLLNAME=L"$(Py3DllName)$(PyDebugExt)";</_Py3NamePreprocessorDefinition>
<_FreeThreadedPreprocessorDefinition Condition="$(DisableGil) == 'true'">Py_GIL_DISABLED=1;</_FreeThreadedPreprocessorDefinition>
<_PymallocHugepagesPreprocessorDefinition Condition="$(UsePymallocHugepages) == 'true'">PYMALLOC_USE_HUGEPAGES=1;</_PymallocHugepagesPreprocessorDefinition>
<_PyUsingPgoPreprocessorDefinition Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1;</_PyUsingPgoPreprocessorDefinition>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(PySourcePath)Include;$(PySourcePath)Include\internal;$(PySourcePath)Include\internal\mimalloc;$(PySourcePath)PC;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;$(_Py3NamePreprocessorDefinition)$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)$(_FreeThreadedPreprocessorDefinition)$(_PymallocHugepagesPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(SupportPGO)' and ($(Configuration) == 'PGInstrument' or $(Configuration) == 'PGUpdate')">_Py_USING_PGO=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;$(_PlatformPreprocessorDefinition)$(_DebugPreprocessorDefinition)$(_PyStatsPreprocessorDefinition)$(_PydPreprocessorDefinition)$(_FreeThreadedPreprocessorDefinition)$(_PymallocHugepagesPreprocessorDefinition)$(_PyUsingPgoPreprocessorDefinition)%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
+26 -4
View File
@@ -43,7 +43,7 @@
<PySourcePath Condition="'$(PySourcePath)' == ''">$([System.IO.Path]::GetFullPath($(MSBuildThisFileDirectory)\..\))</PySourcePath>
<PySourcePath Condition="!HasTrailingSlash($(PySourcePath))">$(PySourcePath)\</PySourcePath>
<!-- Directory where build outputs are put -->
<!-- Directories where build outputs are put -->
<BuildPath32 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32\</BuildPath32>
<BuildPath32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32\</BuildPath32>
<BuildPath64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\amd64\</BuildPath64>
@@ -52,11 +52,34 @@
<BuildPathArm32 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm32\</BuildPathArm32>
<BuildPathArm64 Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm64\</BuildPathArm64>
<BuildPathArm64 Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm64\</BuildPathArm64>
<BuildPath32t Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\win32t\</BuildPath32t>
<BuildPath32t Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\win32t\</BuildPath32t>
<BuildPath64t Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\amd64t\</BuildPath64t>
<BuildPath64t Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\amd64t\</BuildPath64t>
<BuildPathArm32t Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm32t\</BuildPathArm32t>
<BuildPathArm32t Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm32t\</BuildPathArm32t>
<BuildPathArm64t Condition="'$(Py_OutDir)' == ''">$(PySourcePath)PCbuild\arm64t\</BuildPathArm64t>
<BuildPathArm64t Condition="'$(Py_OutDir)' != ''">$(Py_OutDir)\arm64t\</BuildPathArm64t>
</PropertyGroup>
<PropertyGroup Condition="$(DisableGil) != 'true'">
<BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm32'">$(BuildPathArm32)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm64'">$(BuildPathArm64)</BuildPath>
<BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCbuild\$(ArchName)\</BuildPath>
</PropertyGroup>
<PropertyGroup Condition="$(DisableGil) == 'true'">
<!-- Directory where build outputs are put -->
<BuildPath Condition="'$(ArchName)' == 'win32'">$(BuildPath32t)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'amd64'">$(BuildPath64t)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm32'">$(BuildPathArm32t)</BuildPath>
<BuildPath Condition="'$(ArchName)' == 'arm64'">$(BuildPathArm64t)</BuildPath>
<BuildPath Condition="'$(BuildPath)' == ''">$(PySourcePath)PCbuild\$(ArchName)t\</BuildPath>
</PropertyGroup>
<PropertyGroup>
<BuildPath Condition="!HasTrailingSlash($(BuildPath))">$(BuildPath)\</BuildPath>
<BuildPath Condition="$(Configuration) == 'PGInstrument'">$(BuildPath)instrumented\</BuildPath>
@@ -232,18 +255,17 @@
<Field3Value Condition="$(UseTestMarker) == 'true'">$([msbuild]::Add($(Field3Value), 9000))</Field3Value>
<!-- Name and full path of the resulting python.exe binary -->
<PyExeName Condition="$(DisableGil) == 'true'">python$(MajorVersionNumber).$(MinorVersionNumber)t</PyExeName>
<PyExeName Condition="$(PyExeName) == ''">python</PyExeName>
<PythonExe Condition="'$(PythonExe)' == ''">$(BuildPath)$(PyExeName)$(PyDebugExt).exe</PythonExe>
<PyWExeName Condition="$(DisableGil) == 'true'">pythonw$(MajorVersionNumber).$(MinorVersionNumber)t</PyWExeName>
<PyWExeName Condition="$(PyWExeName) == ''">pythonw</PyWExeName>
<!-- The name of the resulting pythonXY.dll (without the extension) -->
<PyDllName Condition="$(DisableGil) == 'true'">python$(MajorVersionNumber)$(MinorVersionNumber)t$(PyDebugExt)</PyDllName>
<PyDllName Condition="$(PyDllName) == ''">python$(MajorVersionNumber)$(MinorVersionNumber)$(PyDebugExt)</PyDllName>
<!-- The name of the resulting pythonX.dll (without the extension) -->
<Py3DllName Condition="$(DisableGil) == 'true'">python3t</Py3DllName>
<Py3DllName Condition="$(Py3DllName) == ''">python3</Py3DllName>
<Abi3tDllName Condition="$(Abi3tDllName) == ''">python3t</Abi3tDllName>
<!-- The version and platform tag to include in .pyd filenames -->
<PydTag Condition="$(ArchName) == 'win32'">.cp$(MajorVersionNumber)$(MinorVersionNumber)-win32</PydTag>
+1 -1
View File
@@ -75,7 +75,7 @@
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetName>$(Py3DllName)</TargetName>
<TargetName>python3</TargetName>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+110
View File
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM">
<Configuration>PGInstrument</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|ARM64">
<Configuration>PGInstrument</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|Win32">
<Configuration>PGInstrument</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGInstrument|x64">
<Configuration>PGInstrument</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM">
<Configuration>PGUpdate</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|ARM64">
<Configuration>PGUpdate</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|Win32">
<Configuration>PGUpdate</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="PGUpdate|x64">
<Configuration>PGUpdate</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</ProjectGuid>
<RootNamespace>python3tdll</RootNamespace>
<Keyword>Win32Proj</Keyword>
<SupportPGO>false</SupportPGO>
</PropertyGroup>
<Import Project="python.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration">
<TargetName>python3t</TargetName>
<ConfigurationType>DynamicLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="pyproject.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>PYTHON_DLL_NAME="$(PyDllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BufferSecurityCheck>false</BufferSecurityCheck>
</ClCompile>
<Link>
<NoEntryPoint>true</NoEntryPoint>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\PC\python3dll.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
+23
View File
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\PC\python3dll.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\PC\python_nt.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>
+4 -1
View File
@@ -618,7 +618,10 @@
<ClCompile Include="..\Python\critical_section.c" />
<ClCompile Include="..\Python\crossinterp.c" />
<ClCompile Include="..\Python\dynamic_annotations.c" />
<ClCompile Include="..\Python\dynload_win.c" />
<ClCompile Include="..\Python\dynload_win.c">
<PreprocessorDefinitions Condition="$(DisableGil) != 'true'">PY3_DLLNAME=L"$(Py3DllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>ABI3T_DLLNAME=L"$(Abi3tDllName)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<ClCompile Include="..\Python\errors.c" />
<ClCompile Include="..\Python\fileutils.c" />
<ClCompile Include="..\Python\flowgraph.c" />
+4
View File
@@ -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
+4 -4
View File
@@ -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%
+3
View File
@@ -104,6 +104,9 @@
<ProjectReference Include="python3dll.vcxproj">
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
</ProjectReference>
<ProjectReference Include="python3tdll.vcxproj">
<Project>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+3
View File
@@ -104,6 +104,9 @@
<ProjectReference Include="python3dll.vcxproj">
<Project>{885d4898-d08d-4091-9c40-c700cfe3fc5a}</Project>
</ProjectReference>
<ProjectReference Include="python3tdll.vcxproj">
<Project>{947BB5F5-6025-4A4F-8182-1B175469F8D2}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
+4 -2
View File
@@ -219,13 +219,15 @@
<PropertyGroup>
<Text>$([System.IO.File]::ReadAllText('$(zlibNgDir)\zlib.h.in').Replace('@ZLIB_SYMBOL_PREFIX@', ''))</Text>
</PropertyGroup>
<WriteLinesToFile File="$(IntDir)zlib.h" Lines="$(Text)" />
<MakeDir Directories="$(GeneratedZlibNgDir)" />
<WriteLinesToFile File="$(GeneratedZlibNgDir)zlib.h" Lines="$(Text)" />
</Target>
<Target Name="_EnsureZlibNgH" Inputs="$(zlibNgDir)\zlib-ng.h.in" Outputs="$(IntDir)zlib-ng.h">
<PropertyGroup>
<Text>$([System.IO.File]::ReadAllText('$(zlibNgDir)\zlib-ng.h.in').Replace('@ZLIB_SYMBOL_PREFIX@', ''))</Text>
</PropertyGroup>
<WriteLinesToFile File="$(IntDir)zlib-ng.h" Lines="$(Text)" />
<MakeDir Directories="$(GeneratedZlibNgDir)" />
<WriteLinesToFile File="$(GeneratedZlibNgDir)zlib-ng.h" Lines="$(Text)" />
</Target>
<Target Name="_EnsureZlibNgHeaders" BeforeTargets="PrepareForBuild"
+76 -4
View File
@@ -151,11 +151,16 @@ static char *GetPythonImport (HINSTANCE hModule)
to this python DLL is loaded, not a python3.dll that might be on the path
by chance.
Return whether the DLL was found.
On free-threaded builds, PY3_DLLNAME is undefined and this is a no-op.
_Py_CheckPython3t will check for python3t.dll in that case.
*/
extern HMODULE PyWin_DLLhModule;
static int
_Py_CheckPython3(void)
{
#ifndef PY3_DLLNAME
return 1;
#else
static int python3_checked = 0;
static HANDLE hPython3;
#define MAXPATHLEN 512
@@ -169,10 +174,11 @@ _Py_CheckPython3(void)
use that DLL */
if (PyWin_DLLhModule && GetModuleFileNameW(PyWin_DLLhModule, py3path, MAXPATHLEN)) {
wchar_t *p = wcsrchr(py3path, L'\\');
if (p) {
wcscpy(p + 1, PY3_DLLNAME);
wcscpy(p + 1, PY3_DLLNAME L".dll");
hPython3 = LoadLibraryExW(py3path, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
if (hPython3 != NULL) {
if (hPython3) {
return 1;
}
}
@@ -180,7 +186,7 @@ _Py_CheckPython3(void)
/* If we can locate python3.dll in our application dir,
use that DLL */
hPython3 = LoadLibraryExW(PY3_DLLNAME, NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
hPython3 = LoadLibraryExW(PY3_DLLNAME L".dll", NULL, LOAD_LIBRARY_SEARCH_APPLICATION_DIR);
if (hPython3 != NULL) {
return 1;
}
@@ -192,13 +198,78 @@ _Py_CheckPython3(void)
assert(config->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).
*/
static int
_Py_CheckPython3t(void)
{
#ifndef ABI3T_DLLNAME
return 1;
#else
#if defined(PY3_DLLNAME) && PY_MAJOR_VERSION==3 && PY_MINOR_VERSION==15
/* GIL-enabled builds of 3.15 might have a python3t.dll adjacent that is for
a free-threaded build. So we first check in a subdirectory in that case.
If it's not there, we'll look adjacent. */
#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 +281,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);
+6
View File
@@ -75,6 +75,12 @@
</Fragment>
<!-- Top-level directories -->
<Fragment>
<DirectoryRef Id="InstallDirectory">
<Directory Id="abi3t_compat" Name="abi3t-compat" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="InstallDirectory">
<Directory Id="DLLs" Name="DLLs">
+6
View File
@@ -2,6 +2,9 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="core_dll">
<Component Id="python_abi3tcompat.dll" Directory="abi3t_compat" Guid="*">
<File Id="python_abi3tcompat.dll" Name="python$(var.MajorVersionNumber)t.dll" KeyPath="yes" />
</Component>
<Component Id="python_stable.dll" Directory="InstallDirectory" Guid="*">
<File Id="python_stable.dll" Name="python$(var.MajorVersionNumber).dll" KeyPath="yes" />
</Component>
@@ -19,6 +22,9 @@
</Fragment>
<Fragment>
<ComponentGroup Id="core_dll_d">
<Component Id="python_abi3tcompat_d.dll" Directory="abi3t_compat" Guid="*">
<File Id="python_abi3tcompat_d.dll" Name="python$(var.MajorVersionNumber)t_d.dll" KeyPath="yes" />
</Component>
<Component Id="python_stable_d.dll" Directory="InstallDirectory" Guid="*">
<File Id="python_stable_d.dll" Name="python$(var.MajorVersionNumber)_d.dll" KeyPath="yes" />
</Component>
+34 -30
View File
@@ -29,7 +29,7 @@
<ComponentGroup Id="freethreaded_exe">
<Component Id="freethreaded_python.exe" Directory="InstallDirectory" Guid="$(var.FreethreadedPythonExeComponentGuid)">
<File Name="python$(var.ShortVersion)t.exe" KeyPath="yes" />
<File Name="python$(var.ShortVersion)t.exe" Source="!(bindpath.build_t)\python.exe" KeyPath="yes" />
<RegistryKey Root="HKMU" Key="[FREETHREADED_REGISTRYKEY]">
<RegistryValue Key="InstallPath" Type="string" Value="[InstallDirectory]" KeyPath="no" />
@@ -37,68 +37,72 @@
</RegistryKey>
</Component>
<Component Id="freethreaded_pythonw.exe" Directory="InstallDirectory" Guid="$(var.FreethreadedPythonwExeComponentGuid)">
<File Name="pythonw$(var.ShortVersion)t.exe" KeyPath="yes" />
<File Name="pythonw$(var.ShortVersion)t.exe" Source="!(bindpath.build_t)\pythonw.exe" KeyPath="yes" />
<RegistryKey Root="HKMU" Key="[FREETHREADED_REGISTRYKEY]">
<RegistryValue Key="InstallPath" Name="WindowedExecutablePath" Type="string" Value="[#pythonw$(var.ShortVersion)t.exe]" KeyPath="no" />
</RegistryKey>
</Component>
<Component Id="freethreaded_python_stable.dll" Directory="InstallDirectory" Guid="*">
<File Id="freethreaded_python_stable.dll" Name="python$(var.MajorVersionNumber)t.dll" KeyPath="yes" />
<File Id="freethreaded_python_stable.dll" Name="python$(var.MajorVersionNumber)t.dll" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)t.dll" KeyPath="yes" />
</Component>
<Component Id="freethreaded_python.dll" Directory="InstallDirectory" Guid="*">
<File Id="freethreaded_python.dll" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.dll" KeyPath="yes" />
<File Id="freethreaded_python.dll" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.dll" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.dll" KeyPath="yes" />
</Component>
<Component Id="freethreaded_python_stable.lib" Directory="libs" Guid="*">
<File Id="freethreaded_python_stable.lib" Name="python$(var.MajorVersionNumber)t.lib" KeyPath="yes" />
<File Id="freethreaded_python_stable.lib" Name="python$(var.MajorVersionNumber)t.lib" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)t.lib" KeyPath="yes" />
</Component>
<Component Id="freethreaded_python.lib" Directory="libs" Guid="*">
<File Id="freethreaded_python.lib" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.lib" KeyPath="yes" />
<File Id="freethreaded_python.lib" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.lib" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.lib" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="freethreaded_symbols">
<Component Id="freethreaded_python_dll.pdb" Directory="InstallDirectory" Guid="*">
<File Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.pdb" KeyPath="yes" />
<File Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.pdb" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t.pdb" KeyPath="yes" />
</Component>
<!--
Renaming the PDB like this will break automatic connection by debuggers,
but short of making people stop using this installer there's no real option.
-->
<Component Id="freethreaded_python.pdb" Directory="InstallDirectory" Guid="*">
<File Name="python$(var.ShortVersion)t.pdb" />
<File Name="python$(var.ShortVersion)t.pdb" Source="!(bindpath.build_t)\python.pdb" />
</Component>
<Component Id="freethreaded_pythonw.pdb" Directory="InstallDirectory" Guid="*">
<File Name="pythonw$(var.ShortVersion)t.pdb" />
<File Name="pythonw$(var.ShortVersion)t.pdb" Source="!(bindpath.build_t)\pythonw.pdb" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="freethreaded_dll_d">
<Component Id="freethreaded_python_stable_d.dll" Directory="InstallDirectory" Guid="*">
<File Id="freethreaded_python_stable_d.dll" Name="python$(var.MajorVersionNumber)t_d.dll" KeyPath="yes" />
<File Id="freethreaded_python_stable_d.dll" Name="python$(var.MajorVersionNumber)t_d.dll" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)t_d.dll" KeyPath="yes" />
</Component>
<Component Id="freethreaded_python_d.dll" Directory="InstallDirectory" Guid="*">
<File Id="freethreaded_python_d.dll" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.dll" KeyPath="yes" />
<File Id="freethreaded_python_d.pdb" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.pdb" KeyPath="no" />
<File Id="freethreaded_python_d.dll" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.dll" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.dll" KeyPath="yes" />
<File Id="freethreaded_python_d.pdb" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.pdb" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.pdb" KeyPath="no" />
</Component>
<Component Id="freethreaded_python_stable_d.lib" Directory="libs" Guid="*">
<File Id="freethreaded_python_stable_d.lib" Name="python$(var.MajorVersionNumber)t_d.lib" KeyPath="yes" />
<File Id="freethreaded_python_stable_d.lib" Name="python$(var.MajorVersionNumber)t_d.lib" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)t_d.lib" KeyPath="yes" />
</Component>
<Component Id="freethreaded_python_d.lib" Directory="libs" Guid="*">
<File Id="freethreaded_python_d.lib" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.lib" KeyPath="yes" />
<File Id="freethreaded_python_d.lib" Name="python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.lib" Source="!(bindpath.build_t)\python$(var.MajorVersionNumber)$(var.MinorVersionNumber)t_d.lib" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="freethreaded_exe_d">
<Component Id="freethreaded_python_d.exe" Directory="InstallDirectory" Guid="*">
<File Name="python$(var.ShortVersion)t_d.exe" />
<File Name="python$(var.ShortVersion)t_d.exe" Source="!(bindpath.build_t)python_d.exe" />
</Component>
<Component Id="freethreaded_python_d.pdb" Directory="InstallDirectory" Guid="*">
<File Name="python$(var.ShortVersion)t_d.pdb" />
<File Name="python$(var.ShortVersion)t_d.pdb" Source="!(bindpath.build_t)python_d.pdb" />
</Component>
<Component Id="freethreaded_pythonw_d.exe" Directory="InstallDirectory" Guid="*">
<File Name="pythonw$(var.ShortVersion)t_d.exe" />
<File Name="pythonw$(var.ShortVersion)t_d.exe" Source="!(bindpath.build_t)pythonw_d.exe" />
</Component>
<Component Id="freethreaded_pythonw_d.pdb" Directory="InstallDirectory" Guid="*">
<File Name="pythonw$(var.ShortVersion)t_d.pdb" />
<File Name="pythonw$(var.ShortVersion)t_d.pdb" Source="!(bindpath.build_t)pythonw_d.pdb" />
</Component>
</ComponentGroup>
</Fragment>
@@ -111,16 +115,16 @@
<?foreach ext in $(var.exts)?>
<Component Id="freethreaded_$(var.ext).pyd" Directory="DLLs" Guid="*">
<File Name="$(var.ext)$(var.FreethreadedPydTag).pyd" KeyPath="yes" />
<File Name="$(var.ext)$(var.FreethreadedPydTag).pyd" Source="!(bindpath.build_t)\$(var.ext)$(var.FreethreadedPydTag).pyd" KeyPath="yes" />
</Component>
<?endforeach ?>
<Component Id="venvlaunchert.exe" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvlaunchert.exe" KeyPath="yes" />
<File Name="venvlaunchert.exe" Source="!(bindpath.build_t)\venvlaunchert.exe" KeyPath="yes" />
</Component>
<Component Id="venvwlaunchert.exe" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvwlaunchert.exe" KeyPath="yes" />
<File Name="venvwlaunchert.exe" Source="!(bindpath.build_t)\venvwlaunchert.exe" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
@@ -132,16 +136,16 @@
<?foreach ext in $(var.exts)?>
<Component Id="freethreaded_$(var.ext).pdb" Directory="DLLs" Guid="*">
<File Name="$(var.ext)$(var.FreethreadedPydTag).pdb" />
<File Name="$(var.ext)$(var.FreethreadedPydTag).pdb" Source="!(bindpath.build_t)\$(var.ext)$(var.FreethreadedPydTag).pdb" />
</Component>
<?endforeach ?>
<Component Id="venvlaunchert.pdb" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvlaunchert.pdb" KeyPath="yes" />
<File Name="venvlaunchert.pdb" Source="!(bindpath.build_t)\venvlaunchert.pdb" KeyPath="yes" />
</Component>
<Component Id="venvwlaunchert.pdb" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvwlaunchert.pdb" KeyPath="yes" />
<File Name="venvwlaunchert.pdb" Source="!(bindpath.build_t)\venvwlaunchert.pdb" KeyPath="yes" />
</Component>
</ComponentGroup>
</Fragment>
@@ -151,21 +155,21 @@
<?foreach ext in $(var.exts)?>
<Component Id="freethreaded_$(var.ext)_d.pyd" Directory="DLLs" Guid="*">
<File Name="$(var.ext)_d$(var.FreethreadedPydTag).pyd" />
<File Name="$(var.ext)_d$(var.FreethreadedPydTag).pyd" Source="!(bindpath.build_t)\$(var.ext)_d$(var.FreethreadedPydTag).pyd" />
</Component>
<Component Id="freethreaded_$(var.ext)_d.pdb" Directory="DLLs" Guid="*">
<File Name="$(var.ext)_d$(var.FreethreadedPydTag).pdb" />
<File Name="$(var.ext)_d$(var.FreethreadedPydTag).pdb" Source="!(bindpath.build_t)\$(var.ext)_d$(var.FreethreadedPydTag).pdb" />
</Component>
<?endforeach ?>
<Component Id="venvlaunchert_d.exe" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvlaunchert_d.exe" KeyPath="yes" />
<File Name="venvlaunchert_d.pdb" />
<File Name="venvlaunchert_d.exe" Source="!(bindpath.build_t)\venvlaunchert_d.exe" KeyPath="yes" />
<File Name="venvlaunchert_d.pdb" Source="!(bindpath.build_t)\venvlaunchert_d.pdb" />
</Component>
<Component Id="venvwlaunchert_d.exe" Directory="Lib_venv_scripts_nt__freethreaded" Guid="*">
<File Name="venvwlaunchert_d.exe" KeyPath="yes" />
<File Name="venvwlaunchert_d.pdb" />
<File Name="venvwlaunchert_d.exe" Source="!(bindpath.build_t)\venvwlaunchert_d.exe" KeyPath="yes" />
<File Name="venvwlaunchert_d.pdb" Source="!(bindpath.build_t)\venvwlaunchert_d.pdb" />
</Component>
</ComponentGroup>
</Fragment>
+34
View File
@@ -122,6 +122,30 @@
<LinkerBindInputPaths Include="$(PGOBuildPath);$(BuildPath)">
<BindName></BindName>
</LinkerBindInputPaths>
<!--
This looks repetitive, but we need to make sure that we override any
environment variable that changes the paths for free-threading so that
the binds are correct. Otherwise, we'd rely on defaults.
-->
<LinkerBindInputPaths Include="$(BuildPath32)" Condition="$(Platform) == 'x86'">
<BindName>build</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath64)" Condition="$(Platform) == 'x64'">
<BindName>build</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPathARM64)" Condition="$(Platform) == 'ARM64'">
<BindName>build</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath32t)" Condition="$(Platform) == 'x86'">
<BindName>build_t</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath64t)" Condition="$(Platform) == 'x64'">
<BindName>build_t</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPathARM64t)" Condition="$(Platform) == 'ARM64'">
<BindName>build_t</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(PySourcePath)">
<BindName>src</BindName>
</LinkerBindInputPaths>
@@ -131,6 +155,7 @@
<LinkerBindInputPaths Include="$(CRTRedist)">
<BindName>redist</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath32)">
<BindName>build32</BindName>
</LinkerBindInputPaths>
@@ -140,6 +165,15 @@
<LinkerBindInputPaths Include="$(BuildPathARM64)">
<BindName>buildarm64</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath32t)">
<BindName>build32t</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPath64t)">
<BindName>build64t</BindName>
</LinkerBindInputPaths>
<LinkerBindInputPaths Include="$(BuildPathARM64t)">
<BindName>buildarm64t</BindName>
</LinkerBindInputPaths>
</ItemGroup>
<Target Name="_ValidateMsiProps" BeforeTargets="PrepareForBuild">
+7 -1
View File
@@ -145,10 +145,15 @@ def compile_c_extension(
str(MOD_DIR.parent.parent.parent / "Parser" / "lexer"),
str(MOD_DIR.parent.parent.parent / "Parser" / "tokenizer"),
]
library_dirs: list[str] = []
if sys.platform == "win32":
# HACK: The location of pyconfig.h has moved within our build, and
# setuptools hasn't updated for it yet. So add the path manually for now
include_dirs.append(pathlib.Path(sysconfig.get_config_h_filename()).parent)
include_dirs.append(str(pathlib.Path(sysconfig.get_config_h_filename()).parent))
if sysconfig.is_python_build():
# HACK: Our output directory for free-threaded builds has moved, and so
# tests running in-tree require our sys.executable directory for libs
library_dirs.append(str(pathlib.Path(sys.executable).parent))
extension = Extension(
extension_name,
sources=[generated_source_path],
@@ -161,6 +166,7 @@ def compile_c_extension(
fixup_build_ext(cmd)
cmd.build_lib = str(source_file_path.parent)
cmd.include_dirs = include_dirs
cmd.library_dirs = library_dirs
if build_dir:
cmd.build_temp = build_dir
cmd.ensure_finalized()