michael@0: # This file must be used with "source bin/activate" *from bash* michael@0: # you cannot run it directly michael@0: michael@0: deactivate () { michael@0: unset pydoc michael@0: michael@0: # reset old environment variables michael@0: if [ -n "$_OLD_VIRTUAL_PATH" ] ; then michael@0: PATH="$_OLD_VIRTUAL_PATH" michael@0: export PATH michael@0: unset _OLD_VIRTUAL_PATH michael@0: fi michael@0: if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then michael@0: PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" michael@0: export PYTHONHOME michael@0: unset _OLD_VIRTUAL_PYTHONHOME michael@0: fi michael@0: michael@0: # This should detect bash and zsh, which have a hash command that must michael@0: # be called to get it to forget past commands. Without forgetting michael@0: # past commands the $PATH changes we made may not be respected michael@0: if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then michael@0: hash -r 2>/dev/null michael@0: fi michael@0: michael@0: if [ -n "$_OLD_VIRTUAL_PS1" ] ; then michael@0: PS1="$_OLD_VIRTUAL_PS1" michael@0: export PS1 michael@0: unset _OLD_VIRTUAL_PS1 michael@0: fi michael@0: michael@0: unset VIRTUAL_ENV michael@0: if [ ! "$1" = "nondestructive" ] ; then michael@0: # Self destruct! michael@0: unset -f deactivate michael@0: fi michael@0: } michael@0: michael@0: # unset irrelevant variables michael@0: deactivate nondestructive michael@0: michael@0: VIRTUAL_ENV="__VIRTUAL_ENV__" michael@0: export VIRTUAL_ENV michael@0: michael@0: _OLD_VIRTUAL_PATH="$PATH" michael@0: PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH" michael@0: export PATH michael@0: michael@0: # unset PYTHONHOME if set michael@0: # this will fail if PYTHONHOME is set to the empty string (which is bad anyway) michael@0: # could use `if (set -u; : $PYTHONHOME) ;` in bash michael@0: if [ -n "$PYTHONHOME" ] ; then michael@0: _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" michael@0: unset PYTHONHOME michael@0: fi michael@0: michael@0: if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then michael@0: _OLD_VIRTUAL_PS1="$PS1" michael@0: if [ "x__VIRTUAL_PROMPT__" != x ] ; then michael@0: PS1="__VIRTUAL_PROMPT__$PS1" michael@0: else michael@0: if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then michael@0: # special case for Aspen magic directories michael@0: # see http://www.zetadev.com/software/aspen/ michael@0: PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" michael@0: else michael@0: PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" michael@0: fi michael@0: fi michael@0: export PS1 michael@0: fi michael@0: michael@0: alias pydoc="python -m pydoc" michael@0: michael@0: # This should detect bash and zsh, which have a hash command that must michael@0: # be called to get it to forget past commands. Without forgetting michael@0: # past commands the $PATH changes we made may not be respected michael@0: if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then michael@0: hash -r 2>/dev/null michael@0: fi