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 # 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 38 deactivate nondestructive 39 40 VIRTUAL_ENV="__VENV_DIR__" 41 export VIRTUAL_ENV 42 43 _OLD_VIRTUAL_PATH="$PATH" 44 PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH" 45 export 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 50 if [ -n "$PYTHONHOME" ] ; then 51 _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" 52 unset PYTHONHOME 53 fi 54 55 if [ -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 69 fi 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 74 if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then 75 hash -r 76 fi 77