Skip to content

Commit 2b6e877

Browse files
authored
gh-103088: Fix virtual environment activate script not working in Cygwin (GH-103470)
1 parent 7f3c106 commit 2b6e877

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Lib/test/test_importlib/resources/data01/* noeol
3232
Lib/test/test_importlib/resources/namespacedata01/* noeol
3333
Lib/test/xmltestdata/* noeol
3434

35+
# Shell scripts should have LF even on Windows because of Cygwin
36+
Lib/venv/scripts/common/activate text eol=lf
37+
3538
# CRLF files
3639
[attr]dos text eol=crlf
3740

Lib/test/test_venv.py

+15
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,21 @@ def test_zippath_from_non_installed_posix(self):
611611
out, err = check_output(cmd)
612612
self.assertTrue(zip_landmark.encode() in out)
613613

614+
def test_activate_shell_script_has_no_dos_newlines(self):
615+
"""
616+
Test that the `activate` shell script contains no CR LF.
617+
This is relevant for Cygwin, as the Windows build might have
618+
converted line endings accidentally.
619+
"""
620+
venv_dir = pathlib.Path(self.env_dir)
621+
rmtree(venv_dir)
622+
[[scripts_dir], *_] = self.ENV_SUBDIRS
623+
script_path = venv_dir / scripts_dir / "activate"
624+
venv.create(venv_dir)
625+
with open(script_path, 'rb') as script:
626+
for line in script:
627+
self.assertFalse(line.endswith(b'\r\n'), line)
628+
614629
@requireVenvCreate
615630
class EnsurePipTest(BaseTest):
616631
"""Test venv module installation of pip."""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix virtual environment :file:`activate` script having incorrect line endings for Cygwin.

0 commit comments

Comments
 (0)