11# This file must be used with "source bin/activate" *from bash*
2- # you cannot run it directly
2+ # You cannot run it directly
33
44deactivate () {
55 # reset old environment variables
@@ -14,12 +14,10 @@ deactivate () {
1414 unset _OLD_VIRTUAL_PYTHONHOME
1515 fi
1616
17- # This should detect bash and zsh, which have a hash command that must
18- # be called to get it to forget past commands. Without forgetting
19- # past commands the $PATH changes we made may not be respected
20- if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21- hash -r 2> /dev/null
22- fi
17+ # Call hash to forget past locations. Without forgetting
18+ # past locations the $PATH changes we made may not be respected.
19+ # See "man bash" for more details. hash is usually a builtin of your shell
20+ hash -r 2> /dev/null
2321
2422 if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
2523 PS1="${_OLD_VIRTUAL_PS1:-}"
@@ -38,13 +36,27 @@ deactivate () {
3836# unset irrelevant variables
3937deactivate nondestructive
4038
41- VIRTUAL_ENV="__VENV_DIR__"
42- export VIRTUAL_ENV
39+ # on Windows, a path can contain colons and backslashes and has to be converted:
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
4352
4453_OLD_VIRTUAL_PATH="$PATH"
45- PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
54+ PATH="$VIRTUAL_ENV/" __VENV_BIN_NAME__" :$PATH"
4655export PATH
4756
57+ VIRTUAL_ENV_PROMPT=__VENV_PROMPT__
58+ export VIRTUAL_ENV_PROMPT
59+
4860# unset PYTHONHOME if set
4961# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
5062# could use `if (set -u; : $PYTHONHOME) ;` in bash
5567
5668if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
5769 _OLD_VIRTUAL_PS1="${PS1:-}"
58- PS1="__VENV_PROMPT__${PS1:-}"
70+ PS1="(" __VENV_PROMPT__") ${PS1:-}"
5971 export PS1
60- VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
61- export VIRTUAL_ENV_PROMPT
6272fi
6373
64- # This should detect bash and zsh, which have a hash command that must
65- # be called to get it to forget past commands. Without forgetting
74+ # Call hash to forget past commands. Without forgetting
6675# past commands the $PATH changes we made may not be respected
67- if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
68- hash -r 2> /dev/null
69- fi
76+ hash -r 2> /dev/null
0 commit comments