]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-103088: Fix virtual environment activate script not working in Cygwin (GH-103470)
authorStanislav Syekirin <syekirin@gmail.com>
Wed, 12 Apr 2023 20:11:50 +0000 (22:11 +0200)
committerGitHub <noreply@github.com>
Wed, 12 Apr 2023 20:11:50 +0000 (21:11 +0100)
.gitattributes
Lib/test/test_venv.py
Misc/NEWS.d/next/Windows/2023-04-12-10-49-21.gh-issue-103088.Yjj-qJ.rst [new file with mode: 0644]

index 132891824001093a014b23da501fe2272a121972..cb1cf8bcc7c877c117b1eab093947d496da3d3c1 100644 (file)
@@ -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
 
index 4e18dfc23c40c279ffb159764e46aa0d20e009f0..23328431a7aad8da8ea1f488b5eeaa0f0e6ad20f 100644 (file)
@@ -611,6 +611,21 @@ class BasicTest(BaseTest):
         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."""
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 (file)
index 0000000..1fee99d
--- /dev/null
@@ -0,0 +1 @@
+Fix virtual environment :file:`activate` script having incorrect line endings for Cygwin.