]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-126084: Fix venvwlauncher.exe to run pythonw.exe (GH-126088)
authorChristian Ullrich <chris@chrullrich.net>
Tue, 29 Oct 2024 19:52:52 +0000 (20:52 +0100)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2024 19:52:52 +0000 (19:52 +0000)
Lib/test/test_venv.py
Misc/NEWS.d/next/Windows/2024-10-29-09-39-06.gh-issue-126084.3wAL8o.rst [new file with mode: 0644]
PCbuild/venvwlauncher.vcxproj

index 6b2127bd31e40ab2cc9441274a1f4a5965a58319..0b09010c69d4eac2565c06694811d9b4a076ef99 100644 (file)
@@ -872,6 +872,27 @@ class BasicTest(BaseTest):
                 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."""
diff --git a/Misc/NEWS.d/next/Windows/2024-10-29-09-39-06.gh-issue-126084.3wAL8o.rst b/Misc/NEWS.d/next/Windows/2024-10-29-09-39-06.gh-issue-126084.3wAL8o.rst
new file mode 100644 (file)
index 0000000..319053d
--- /dev/null
@@ -0,0 +1,2 @@
+Fix venvwlauncher to launch pythonw instead of python so no extra console
+window is created.
index 1b61718201367fd996c5e032e04183f4791294c4..db7128272f06db0d343530fc4f55baebc6f29e79 100644 (file)
@@ -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>