https://github.com/python/cpython/commit/2a378dba987e125521b678364f0cd44b92dd5d52
commit: 2a378dba987e125521b678364f0cd44b92dd5d52
branch: main
author: Julien <[email protected]>
committer: vsajip <[email protected]>
date: 2024-10-19T18:34:41+01:00
summary:

gh-125398: Convert paths in venv activate script when using Git Bash under 
Windows (GH-125399)

* Convert paths in venv activate script when using Git Bash under Windows

With https://github.com/python/cpython/pull/112508 the check to converts paths 
when running on Windows was changed from using the non-posix environment 
variable `$OSTYPE` to using `uname` instead.

However this missed the fact that when running under Git Bash on Windows, uname 
reports `MINGW*` (`$OSTYPE` is still `msys`).

This results in `$PATH` being set to something like 
`D:\a\github-actions-shells\github-actions-shells\venv/Scripts:…`, instead of 
`/d/a/github-actions-shells/github-actions-shells/venv/Scripts`.

Notably, the Git Bash is the bash shell that’s used for GitHub Actions Windows 
runners, and ships with VSCode.

files:
A Misc/NEWS.d/next/Library/2024-10-13-15-04-58.gh-issue-125398.UW7Ndv.rst
M Lib/venv/scripts/common/activate

diff --git a/Lib/venv/scripts/common/activate b/Lib/venv/scripts/common/activate
index 4593799b7e9b0e..44f137672e9d2e 100644
--- a/Lib/venv/scripts/common/activate
+++ b/Lib/venv/scripts/common/activate
@@ -38,8 +38,8 @@ deactivate nondestructive
 
 # on Windows, a path can contain colons and backslashes and has to be 
converted:
 case "$(uname)" in
-    CYGWIN*|MSYS*)
-        # transform D:\path\to\venv to /d/path/to/venv on MSYS
+    CYGWIN*|MSYS*|MINGW*)
+        # transform D:\path\to\venv to /d/path/to/venv on MSYS and MINGW
         # and to /cygdrive/d/path/to/venv on Cygwin
         VIRTUAL_ENV=$(cygpath "__VENV_DIR__")
         export VIRTUAL_ENV
diff --git 
a/Misc/NEWS.d/next/Library/2024-10-13-15-04-58.gh-issue-125398.UW7Ndv.rst 
b/Misc/NEWS.d/next/Library/2024-10-13-15-04-58.gh-issue-125398.UW7Ndv.rst
new file mode 100644
index 00000000000000..a188b35e1fbdbc
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-10-13-15-04-58.gh-issue-125398.UW7Ndv.rst
@@ -0,0 +1 @@
+Fix the conversion of the :envvar:`!VIRTUAL_ENV` path in the activate script 
in :mod:`venv` when running in Git Bash for Windows.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to