Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ def test_sysconfig(self):
self.assertEqual(out.strip(), expected, err)
for attr, expected in (
('executable', self.envpy()),
# Usually compare to sys.executable, but if we're running in our own
# venv then we really need to compare to our base executable
('_base_executable', sys._base_executable),
# Usually compare to sys.prefix, but if we're running in our own
# venv then we really need to compare to our base prefix
('base_prefix', sys.base_prefix),
):
with self.subTest(attr):
cmd[2] = f'import sys; print(sys.{attr})'
Expand Down Expand Up @@ -916,10 +916,10 @@ def test_venvwlauncher(self):
exename = exename.replace("python", "pythonw")
envpyw = os.path.join(self.env_dir, self.bindir, exename)
try:
subprocess.check_call([envpyw, "-c", "import sys; "
"assert sys._base_executable.endswith('%s')" % exename])
subprocess.check_call([envpyw, "-c", "import fnmatch, sys; "
"assert fnmatch.fnmatch(sys._base_executable, '**/pythonw*.exe')"])
except subprocess.CalledProcessError:
self.fail("venvwlauncher.exe did not run %s" % exename)
self.fail("venvwlauncher.exe did not run pythonw.exe")


@requireVenvCreate
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes virtual environment launchers on Windows free-threaded builds.
2 changes: 2 additions & 0 deletions PC/layout/support/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def public(f):
"venv",
"dev",
"html-doc",
"alias",
"install-json",
],
},
Expand All @@ -123,6 +124,7 @@ def public(f):
"html-doc",
"symbols",
"tests",
"alias",
"install-test-json",
],
},
Expand Down
5 changes: 3 additions & 2 deletions PC/layout/support/pymanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ def calculate_install_json(ns, *, for_embed=False, for_test=False):
if ns.include_freethreaded:
# Free-threaded distro comes with a tag suffix
TAG_SUFFIX = "t"
TARGET = f"python{VER_MAJOR}.{VER_MINOR}t.exe"
TARGETW = f"pythonw{VER_MAJOR}.{VER_MINOR}t.exe"
if not ns.include_alias:
TARGET = f"python{VER_MAJOR}.{VER_MINOR}t.exe"
TARGETW = f"pythonw{VER_MAJOR}.{VER_MINOR}t.exe"
DISPLAY_TAGS.append("free-threaded")
FILE_SUFFIX = f"t-{ns.arch}"

Expand Down
8 changes: 8 additions & 0 deletions PCbuild/python.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@
set PYTHONPATH=$(PySourcePath)Lib
"$(OutDir)$(PyExeName)$(PyDebugExt).exe" "$(PySourcePath)PC\validate_ucrtbase.py" $(UcrtName)' ContinueOnError="true" />
</Target>
<Target Name="CopyFreethreadedBinary" AfterTargets="AfterBuild"
Condition="$(DisableGil) == 'true' and $(Configuration) != 'PGInstrument'">
<Message Text="Duplicating $(TargetPath) to $(PyExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe for free-threaded compatibility" />
<Copy SourceFiles="$(TargetPath)"
DestinationFiles="$(OutDir)\$(PyExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe"
SkipUnchangedFiles="true"
UseHardLinksIfPossible="true" />
</Target>
<Target Name="GeneratePythonBat" AfterTargets="AfterBuild">
<PropertyGroup>
<_Content>@rem This script invokes the most recently built Python with all arguments
Expand Down
8 changes: 8 additions & 0 deletions PCbuild/pythonw.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,12 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<Target Name="CopyFreethreadedBinary" AfterTargets="AfterBuild"
Condition="$(DisableGil) == 'true' and $(Configuration) != 'PGInstrument'">
<Message Text="Duplicating $(TargetPath) to $(PyWExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe for free-threaded compatibility" />
<Copy SourceFiles="$(TargetPath)"
DestinationFiles="$(OutDir)\$(PyWExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe"
SkipUnchangedFiles="true"
UseHardLinksIfPossible="true" />
</Target>
</Project>
7 changes: 5 additions & 2 deletions PCbuild/venvlauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@
<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 Label="UserMacros">
<ExeName>$(PyExeName)$(PyDebugExt).exe</ExeName>
<ExeName Condition="$(DisableGil) == 'true'">$(PyExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe</ExeName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>EXENAME=L"$(PyExeName)$(PyDebugExt).exe";_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>EXENAME=L"$(ExeName)";_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<ResourceCompile>
Expand Down
7 changes: 5 additions & 2 deletions PCbuild/venvwlauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,13 @@
<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 Label="UserMacros">
<ExeName>$(PyWExeName)$(PyDebugExt).exe</ExeName>
<ExeName Condition="$(DisableGil) == 'true'">$(PyWExeName)$(MajorVersionNumber).$(MinorVersionNumber)t$(PyDebugExt).exe</ExeName>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>EXENAME=L"$(PyWExeName)$(PyDebugExt).exe";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>EXENAME=L"$(ExeName)";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<ResourceCompile>
Expand Down
Loading