gh-103088: Fix virtual environment activate script not working in Cygwin (GH-103470)

This commit is contained in:
Stanislav Syekirin 2023-04-12 22:11:50 +02:00 committed by GitHub
parent 7f3c106503
commit 2b6e877767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

3
.gitattributes vendored
View File

@ -32,6 +32,9 @@ Lib/test/test_importlib/resources/data01/* noeol
Lib/test/test_importlib/resources/namespacedata01/* noeol Lib/test/test_importlib/resources/namespacedata01/* noeol
Lib/test/xmltestdata/* noeol Lib/test/xmltestdata/* noeol
# Shell scripts should have LF even on Windows because of Cygwin
Lib/venv/scripts/common/activate text eol=lf
# CRLF files # CRLF files
[attr]dos text eol=crlf [attr]dos text eol=crlf

View File

@ -611,6 +611,21 @@ class BasicTest(BaseTest):
out, err = check_output(cmd) out, err = check_output(cmd)
self.assertTrue(zip_landmark.encode() in out) self.assertTrue(zip_landmark.encode() in out)
def test_activate_shell_script_has_no_dos_newlines(self):
"""
Test that the `activate` shell script contains no CR LF.
This is relevant for Cygwin, as the Windows build might have
converted line endings accidentally.
"""
venv_dir = pathlib.Path(self.env_dir)
rmtree(venv_dir)
[[scripts_dir], *_] = self.ENV_SUBDIRS
script_path = venv_dir / scripts_dir / "activate"
venv.create(venv_dir)
with open(script_path, 'rb') as script:
for line in script:
self.assertFalse(line.endswith(b'\r\n'), line)
@requireVenvCreate @requireVenvCreate
class EnsurePipTest(BaseTest): class EnsurePipTest(BaseTest):
"""Test venv module installation of pip.""" """Test venv module installation of pip."""

View File

@ -0,0 +1 @@
Fix virtual environment :file:`activate` script having incorrect line endings for Cygwin.