From: Victor Stinner Date: Tue, 26 May 2026 16:32:13 +0000 (+0200) Subject: gh-149879: Fix test_venv on Cygwin (#150483) X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=bc235304dfe5f018a87e1d73ca1ad2912f4ab999;p=thirdparty%2FPython%2Fcpython.git gh-149879: Fix test_venv on Cygwin (#150483) In copy mode, venv now also copies the cygpython DLL. Fix test_zippath_from_non_installed_posix(): copy also the cygpython DLL. --- diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 9d2960664abf..1ff5d7cf0c51 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -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") diff --git a/Lib/venv/__init__.py b/Lib/venv/__init__.py index 0653a43a8b17..bd2762d55ef6 100644 --- a/Lib/venv/__init__.py +++ b/Lib/venv/__init__.py @@ -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): """