https://github.com/python/cpython/commit/802d405ff1233a48004a7c9b302baa76291514d1
commit: 802d405ff1233a48004a7c9b302baa76291514d1
branch: main
author: Christian Ullrich <ch...@chrullrich.net>
committer: zooba <steve.do...@microsoft.com>
date: 2024-10-29T19:52:52Z
summary:

gh-126084: Fix venvwlauncher.exe to run pythonw.exe (GH-126088)

files:
A Misc/NEWS.d/next/Windows/2024-10-29-09-39-06.gh-issue-126084.3wAL8o.rst
M Lib/test/test_venv.py
M PCbuild/venvwlauncher.vcxproj

diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 6b2127bd31e40a..0b09010c69d4ea 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -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."""
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
index 00000000000000..319053d95db19e
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-10-29-09-39-06.gh-issue-126084.3wAL8o.rst
@@ -0,0 +1,2 @@
+Fix venvwlauncher to launch pythonw instead of python so no extra console
+window is created.
diff --git a/PCbuild/venvwlauncher.vcxproj b/PCbuild/venvwlauncher.vcxproj
index 1b61718201367f..db7128272f06db 100644
--- a/PCbuild/venvwlauncher.vcxproj
+++ b/PCbuild/venvwlauncher.vcxproj
@@ -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>

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to