Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 802d405

Browse files
authored
gh-126084: Fix venvwlauncher.exe to run pythonw.exe (GH-126088)
1 parent 9effa0f commit 802d405

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Lib/test/test_venv.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,27 @@ def test_venv_same_path(self):
872872
else:
873873
self.assertFalse(same_path(path1, path2))
874874

875+
# gh-126084: venvwlauncher should run pythonw, not python
876+
@requireVenvCreate
877+
@unittest.skipUnless(os.name == 'nt', 'only relevant on Windows')
878+
def test_venvwlauncher(self):
879+
"""
880+
Test that the GUI launcher runs the GUI python.
881+
"""
882+
rmtree(self.env_dir)
883+
venv.create(self.env_dir)
884+
exename = self.exe
885+
# Retain the debug suffix if present
886+
if "python" in exename and not "pythonw" in exename:
887+
exename = exename.replace("python", "pythonw")
888+
envpyw = os.path.join(self.env_dir, self.bindir, exename)
889+
try:
890+
subprocess.check_call([envpyw, "-c", "import sys; "
891+
"assert sys._base_executable.endswith('%s')" % exename])
892+
except subprocess.CalledProcessError:
893+
self.fail("venvwlauncher.exe did not run %s" % exename)
894+
895+
875896
@requireVenvCreate
876897
class EnsurePipTest(BaseTest):
877898
"""Test venv module installation of pip."""
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix venvwlauncher to launch pythonw instead of python so no extra console
2+
window is created.

PCbuild/venvwlauncher.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
<PropertyGroup Label="UserMacros" />
9393
<ItemDefinitionGroup>
9494
<ClCompile>
95-
<PreprocessorDefinitions>EXENAME=L"$(PyExeName)$(PyDebugExt).exe";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
95+
<PreprocessorDefinitions>EXENAME=L"$(PyWExeName)$(PyDebugExt).exe";_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
9696
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
9797
</ClCompile>
9898
<ResourceCompile>

0 commit comments

Comments
 (0)