Skip to content

gh-126084: Fix venvwlauncher to run pythonw #126088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 29, 2024
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
21 changes: 21 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,27 @@ def test_venv_same_path(self):
else:
self.assertFalse(same_path(path1, path2))

# gh-126084: venvwlauncher should run pythonw, not python
@requireVenvCreate
@unittest.skipUnless(os.name == 'nt', 'only relevant on Windows')
def test_venvwlauncher(self):
"""
Test that the GUI launcher runs the GUI python.
"""
rmtree(self.env_dir)
venv.create(self.env_dir)
exename = self.exe
# Retain the debug suffix if present
if "python" in exename and not "pythonw" in exename:
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])
except subprocess.CalledProcessError:
self.fail("venvwlauncher.exe did not run %s" % exename)


@requireVenvCreate
class EnsurePipTest(BaseTest):
"""Test venv module installation of pip."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix venvwlauncher to launch pythonw instead of python so no extra console
window is created.
2 changes: 1 addition & 1 deletion PCbuild/venvwlauncher.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<PreprocessorDefinitions>EXENAME=L"$(PyExeName)$(PyDebugExt).exe";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>EXENAME=L"$(PyWExeName)$(PyDebugExt).exe";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<ResourceCompile>
Expand Down
Loading