Debian Codegraph @

Lib/venv/scripts/common/activate

raw
1 # This file must be used with "source bin/activate" *from bash*
2 # You cannot run it directly
3
4 deactivate () {
5 # reset old environment variables
6 if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7 PATH="${_OLD_VIRTUAL_PATH:-}"
8 export PATH
9 unset _OLD_VIRTUAL_PATH
10 fi
11 if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12 PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13 export PYTHONHOME
14 unset _OLD_VIRTUAL_PYTHONHOME
15 fi
16
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 || true
21
22 if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
23 PS1="${_OLD_VIRTUAL_PS1:-}"
24 export PS1
25 unset _OLD_VIRTUAL_PS1
26 fi
27
28 unset VIRTUAL_ENV
29 unset VIRTUAL_ENV_PROMPT
30 if [ ! "${1:-}" = "nondestructive" ] ; then
31 # Self destruct!
32 unset -f deactivate
33 fi
34 }
35
36 # unset irrelevant variables
37 deactivate nondestructive
38
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
52
53 _OLD_VIRTUAL_PATH="$PATH"
54 PATH="$VIRTUAL_ENV/"__VENV_BIN_NAME__":$PATH"
55 export PATH
56
57 VIRTUAL_ENV_PROMPT=__VENV_PROMPT__
58 export VIRTUAL_ENV_PROMPT
59
60 # unset PYTHONHOME if set
61 # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
62 # could use `if (set -u; : $PYTHONHOME) ;` in bash
63 if [ -n "${PYTHONHOME:-}" ] ; then
64 _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
65 unset PYTHONHOME
66 fi
67
68 if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
69 _OLD_VIRTUAL_PS1="${PS1:-}"
70 PS1="("__VENV_PROMPT__") ${PS1:-}"
71 export PS1
72 fi
73
74 # Call hash to forget past commands. Without forgetting
75 # past commands the $PATH changes we made may not be respected
76 hash -r 2> /dev/null || true