From b7c5939fd1262c1106261b1f949434fffa6e4038 Mon Sep 17 00:00:00 2001 From: Zabolekar Date: Wed, 12 Apr 2023 12:45:26 +0200 Subject: [PATCH 1/4] fix activate script not working in Cygwin --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 13289182400109..cb1cf8bcc7c877 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 From 11ad8e5c31d9381e91ce058a33f7402c3380828a Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Wed, 12 Apr 2023 10:49:22 +0000 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst diff --git a/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst b/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst new file mode 100644 index 00000000000000..0199f8fc9db5b1 --- /dev/null +++ b/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst @@ -0,0 +1 @@ +fix activate script not working in Cygwin From 559f7ade59a87dee50e09a859e2d3713dcc399e8 Mon Sep 17 00:00:00 2001 From: Zabolekar Date: Wed, 12 Apr 2023 18:30:39 +0200 Subject: [PATCH 3/4] add test to ensure that the `activate` script never contains CR LF --- Lib/test/test_venv.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 4e18dfc23c40c2..43bcc57306f0b8 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -611,6 +611,20 @@ 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. + """ + 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.""" From 53e5e4ea89353537644258b18dd0b53f15bff054 Mon Sep 17 00:00:00 2001 From: Steve Dower Date: Wed, 12 Apr 2023 19:46:03 +0100 Subject: [PATCH 4/4] Apply suggestions from code review --- Lib/test/test_venv.py | 3 ++- .../Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 43bcc57306f0b8..23328431a7aad8 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -614,7 +614,8 @@ def test_zippath_from_non_installed_posix(self): 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. + 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) diff --git a/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst b/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst index 0199f8fc9db5b1..1fee99da240378 100644 --- a/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst +++ b/Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst @@ -1 +1 @@ -fix activate script not working in Cygwin +Fix virtual environment :file:`activate` script having incorrect line endings for Cygwin.