8000 [3.12] gh-112507: Detect Cygwin and MSYS with `uname` instead of `$OS… · python/cpython@4eb1421 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4eb1421

Browse files
authored
[3.12] gh-112507: Detect Cygwin and MSYS with uname instead of $OSTYPE (GH-112508) (GH-130674)
(cherry picked from commit d7b5f10)
1 parent aa91a11 commit 4eb1421

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

Lib/venv/scripts/common/activate

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,26 @@ deactivate () {
3737
deactivate nondestructive
3838

3939
# on Windows, a path can contain colons and backslashes and has to be converted:
40-
if [ "${OSTYPE:-}" = "cygwin" ] || [ "${OSTYPE:-}" = "msys" ] ; then
41-
# transform D:\path\to\venv to /d/path/to/venv on MSYS
42-
# and to /cygdrive/d/path/to/venv on Cygwin
43-
export VIRTUAL_ENV=$(cygpath __VENV_DIR__)
44-
else
45-
# use the path as-is
46-
export VIRTUAL_ENV=__VENV_DIR__
47-
fi
40+
case "$(uname)" in
41+
CYGWIN*|MSYS*|MINGW*)
42+
# transform D:\path\to\venv to /d/path/to/venv on MSYS and MINGW
43+
# and to /cygdrive/d/path/to/venv on Cygwin
44+
VIRTUAL_ENV=$(cygpath __VENV_DIR__)
45+
export VIRTUAL_ENV
46+
;;
47+
*)
48+
# use the path as-is
49+
export VIRTUAL_ENV=__VENV_DIR__
50+
;;
51+
esac
4852

4953
_OLD_VIRTUAL_PATH="$PATH"
5054
PATH="$VIRTUAL_ENV/"__VENV_BIN_NAME__":$PATH"
5155
export PATH
5256

57+
VIRTUAL_ENV_PROMPT=__VENV_PROMPT__
58+
export VIRTUAL_ENV_PROMPT
59+
5360
# unset PYTHONHOME if set
5461
# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
5562
# could use `if (set -u; : $PYTHONHOME) ;` in bash
@@ -60,10 +67,8 @@ fi
6067

6168
if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
6269
_OLD_VIRTUAL_PS1="${PS1:-}"
63-
PS1=__VENV_PROMPT__"${PS1:-}"
70+
PS1="("__VENV_PROMPT__") ${PS1:-}"
6471
export PS1
65-
VIRTUAL_ENV_PROMPT=__VENV_PROMPT__
66-
export VIRTUAL_ENV_PROMPT
6772
fi
6873

6974
# Call hash to forget past commands. Without forgetting

0 commit comments

Comments
 (0)
0