Skip to content

gh-103088: fix activate script not working in Cygwin #103470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ Lib/test/test_importlib/resources/data01/* noeol
Lib/test/test_importlib/resources/namespacedata01/* 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
[attr]dos text eol=crlf

Expand Down
15 changes: 15 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,21 @@ def test_zippath_from_non_installed_posix(self):
out, err = check_output(cmd)
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
class EnsurePipTest(BaseTest):
"""Test venv module installation of pip."""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix virtual environment :file:`activate` script having incorrect line endings for Cygwin.