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 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 if [ ! "$1" = "nondestructive" ] ; then 32 # Self destruct! 33 unset -f deactivate 34 fi 35} 36 37# unset irrelevant variables 38deactivate nondestructive 39 40VIRTUAL_ENV="__VENV_DIR__" 41export VIRTUAL_ENV 42 43_OLD_VIRTUAL_PATH="$PATH" 44PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH" 45export PATH 46 47# unset PYTHONHOME if set 48# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) 49# could use `if (set -u; : $PYTHONHOME) ;` in bash 50if [ -n "${PYTHONHOME:-}" ] ; then 51 _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}" 52 unset PYTHONHOME 53fi 54 55if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then 56 _OLD_VIRTUAL_PS1="${PS1:-}" 57 if [ "x__VENV_PROMPT__" != x ] ; then 58 PS1="__VENV_PROMPT__${PS1:-}" 59 else 60 if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then 61 # special case for Aspen magic directories 62 # see http://www.zetadev.com/software/aspen/ 63 PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" 64 else 65 PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" 66 fi 67 fi 68 export PS1 69fi 70 71# This should detect bash and zsh, which have a hash command that must 72# be called to get it to forget past commands. Without forgetting 73# past commands the $PATH changes we made may not be respected 74if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then 75 hash -r 76fi 77