]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-149879: Fix test_venv on Cygwin (#150483)
authorVictor Stinner <vstinner@python.org>
Tue, 26 May 2026 16:32:13 +0000 (18:32 +0200)
committerGitHub <noreply@github.com>
Tue, 26 May 2026 16:32:13 +0000 (18:32 +0200)
In copy mode, venv now also copies the cygpython DLL.

Fix test_zippath_from_non_installed_posix(): copy also the cygpython
DLL.

Lib/test/test_venv.py
Lib/venv/__init__.py

index 9d2960664abfad514557cb9365c4b9c139fedfbb..1ff5d7cf0c51dd8260bfcfbf64ab7a1f62b7a39e 100644 (file)
@@ -500,6 +500,7 @@ class BasicTest(BaseTest):
 
     # gh-124651: test quoted strings
     @unittest.skipIf(os.name == 'nt', 'contains invalid characters on Windows')
+    @unittest.skipIf(sys.platform == 'cygwin', 'fail to locate cygpython DLL')
     def test_special_chars_bash(self):
         """
         Test that the template strings are quoted properly (bash)
@@ -714,6 +715,12 @@ class BasicTest(BaseTest):
         os.mkdir(bindir)
         python_exe = os.path.basename(sys.executable)
         shutil.copy2(sys.executable, os.path.join(bindir, python_exe))
+        if sys.platform == 'cygwin':
+            # Copy libpython DLL
+            exe_path = os.path.dirname(sys.executable)
+            libpython_dll = sysconfig.get_config_var('DLLLIBRARY')
+            shutil.copy2(os.path.join(exe_path, libpython_dll),
+                         os.path.join(bindir, libpython_dll))
         libdir = os.path.join(non_installed_dir, platlibdir, self.lib[1])
         os.makedirs(libdir)
         landmark = os.path.join(libdir, "os.py")
index 0653a43a8b17766525e2cf05364048eca1fc259e..bd2762d55ef696104275efc22439aeb9b7c66ffa 100644 (file)
@@ -319,6 +319,14 @@ class EnvBuilder:
                     if not os.path.islink(path):
                         os.chmod(path, 0o755)
 
+            if not self.symlinks and sys.platform == 'cygwin':
+                # Copy libpython DLL
+                libpython_dll = sysconfig.get_config_var('DLLLIBRARY')
+                if not os.path.exists(os.path.join(binpath, libpython_dll)):
+                    exe_path = os.path.dirname(sys.executable)
+                    shutil.copy(os.path.join(exe_path, libpython_dll),
+                                os.path.join(binpath, libpython_dll))
+
     else:
         def setup_python(self, context):
             """