https://github.com/python/cpython/commit/bc235304dfe5f018a87e1d73ca1ad2912f4ab999
commit: bc235304dfe5f018a87e1d73ca1ad2912f4ab999
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-05-26T18:32:13+02:00
summary:
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.
files:
M Lib/test/test_venv.py
M Lib/venv/__init__.py
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py
index 9d2960664abfad5..1ff5d7cf0c51dd8 100644
--- a/Lib/test/test_venv.py
+++ b/Lib/test/test_venv.py
@@ -500,6 +500,7 @@ def test_executable_symlinks(self):
# 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 @@ def test_zippath_from_non_installed_posix(self):
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 0653a43a8b17766..bd2762d55ef6961 100644
--- a/Lib/venv/__init__.py
+++ b/Lib/venv/__init__.py
@@ -319,6 +319,14 @@ def setup_python(self, context):
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):
"""
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]