Skip to content

Commit bc23530

Browse files
authored
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.
1 parent 1310d2c commit bc23530

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lib/test/test_venv.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ def test_executable_symlinks(self):
500500

501501
# gh-124651: test quoted strings
502502
@unittest.skipIf(os.name == 'nt', 'contains invalid characters on Windows')
503+
@unittest.skipIf(sys.platform == 'cygwin', 'fail to locate cygpython DLL')
503504
def test_special_chars_bash(self):
504505
"""
505506
Test that the template strings are quoted properly (bash)
@@ -714,6 +715,12 @@ def test_zippath_from_non_installed_posix(self):
714715
os.mkdir(bindir)
715716
python_exe = os.path.basename(sys.executable)
716717
shutil.copy2(sys.executable, os.path.join(bindir, python_exe))
718+
if sys.platform == 'cygwin':
719+
# Copy libpython DLL
720+
exe_path = os.path.dirname(sys.executable)
721+
libpython_dll = sysconfig.get_config_var('DLLLIBRARY')
722+
shutil.copy2(os.path.join(exe_path, libpython_dll),
723+
os.path.join(bindir, libpython_dll))
717724
libdir = os.path.join(non_installed_dir, platlibdir, self.lib[1])
718725
os.makedirs(libdir)
719726
landmark = os.path.join(libdir, "os.py")

Lib/venv/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,14 @@ def setup_python(self, context):
319319
if not os.path.islink(path):
320320
os.chmod(path, 0o755)
321321

322+
if not self.symlinks and sys.platform == 'cygwin':
323+
# Copy libpython DLL
324+
libpython_dll = sysconfig.get_config_var('DLLLIBRARY')
325+
if not os.path.exists(os.path.join(binpath, libpython_dll)):
326+
exe_path = os.path.dirname(sys.executable)
327+
shutil.copy(os.path.join(exe_path, libpython_dll),
328+
os.path.join(binpath, libpython_dll))
329+
322330
else:
323331
def setup_python(self, context):
324332
"""

0 commit comments

Comments
 (0)