1# This file must be used with "source bin/activate" *from bash*
2# you cannot run it directly
3
4deactivate () {
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    # 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
23
24    if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25        PS1="${_OLD_VIRTUAL_PS1:-}"
26        export PS1
27        unset _OLD_VIRTUAL_PS1
28    fi
29
30    unset VIRTUAL_ENV
31    unset VIRTUAL_ENV_PROMPT
32    if [ ! "${1:-}" = "nondestructive" ] ; then
33    # Self destruct!
34        unset -f deactivate
35    fi
36}
37
38# unset irrelevant variables
39deactivate nondestructive
40
41VIRTUAL_ENV="__VENV_DIR__"
42export VIRTUAL_ENV
43
44_OLD_VIRTUAL_PATH="$PATH"
45PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH"
46export PATH
47
48# unset PYTHONHOME if set
49# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
50# could use `if (set -u; : $PYTHONHOME) ;` in bash
51if [ -n "${PYTHONHOME:-}" ] ; then
52    _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
53    unset PYTHONHOME
54fi
55
56if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
57    _OLD_VIRTUAL_PS1="${PS1:-}"
58    PS1="__VENV_PROMPT__${PS1:-}"
59    export PS1
60    VIRTUAL_ENV_PROMPT="__VENV_PROMPT__"
61    export VIRTUAL_ENV_PROMPT
62fi
63
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
66# past commands the $PATH changes we made may not be respected
67if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
68    hash -r 2> /dev/null
69fi
70