Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | # This file must be used with "source bin/activate" *from bash* |
michael@0 | 2 | # you cannot run it directly |
michael@0 | 3 | |
michael@0 | 4 | deactivate () { |
michael@0 | 5 | unset pydoc |
michael@0 | 6 | |
michael@0 | 7 | # reset old environment variables |
michael@0 | 8 | if [ -n "$_OLD_VIRTUAL_PATH" ] ; then |
michael@0 | 9 | PATH="$_OLD_VIRTUAL_PATH" |
michael@0 | 10 | export PATH |
michael@0 | 11 | unset _OLD_VIRTUAL_PATH |
michael@0 | 12 | fi |
michael@0 | 13 | if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then |
michael@0 | 14 | PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" |
michael@0 | 15 | export PYTHONHOME |
michael@0 | 16 | unset _OLD_VIRTUAL_PYTHONHOME |
michael@0 | 17 | fi |
michael@0 | 18 | |
michael@0 | 19 | # This should detect bash and zsh, which have a hash command that must |
michael@0 | 20 | # be called to get it to forget past commands. Without forgetting |
michael@0 | 21 | # past commands the $PATH changes we made may not be respected |
michael@0 | 22 | if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then |
michael@0 | 23 | hash -r 2>/dev/null |
michael@0 | 24 | fi |
michael@0 | 25 | |
michael@0 | 26 | if [ -n "$_OLD_VIRTUAL_PS1" ] ; then |
michael@0 | 27 | PS1="$_OLD_VIRTUAL_PS1" |
michael@0 | 28 | export PS1 |
michael@0 | 29 | unset _OLD_VIRTUAL_PS1 |
michael@0 | 30 | fi |
michael@0 | 31 | |
michael@0 | 32 | unset VIRTUAL_ENV |
michael@0 | 33 | if [ ! "$1" = "nondestructive" ] ; then |
michael@0 | 34 | # Self destruct! |
michael@0 | 35 | unset -f deactivate |
michael@0 | 36 | fi |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | # unset irrelevant variables |
michael@0 | 40 | deactivate nondestructive |
michael@0 | 41 | |
michael@0 | 42 | VIRTUAL_ENV="__VIRTUAL_ENV__" |
michael@0 | 43 | export VIRTUAL_ENV |
michael@0 | 44 | |
michael@0 | 45 | _OLD_VIRTUAL_PATH="$PATH" |
michael@0 | 46 | PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH" |
michael@0 | 47 | export PATH |
michael@0 | 48 | |
michael@0 | 49 | # unset PYTHONHOME if set |
michael@0 | 50 | # this will fail if PYTHONHOME is set to the empty string (which is bad anyway) |
michael@0 | 51 | # could use `if (set -u; : $PYTHONHOME) ;` in bash |
michael@0 | 52 | if [ -n "$PYTHONHOME" ] ; then |
michael@0 | 53 | _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" |
michael@0 | 54 | unset PYTHONHOME |
michael@0 | 55 | fi |
michael@0 | 56 | |
michael@0 | 57 | if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then |
michael@0 | 58 | _OLD_VIRTUAL_PS1="$PS1" |
michael@0 | 59 | if [ "x__VIRTUAL_PROMPT__" != x ] ; then |
michael@0 | 60 | PS1="__VIRTUAL_PROMPT__$PS1" |
michael@0 | 61 | else |
michael@0 | 62 | if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then |
michael@0 | 63 | # special case for Aspen magic directories |
michael@0 | 64 | # see http://www.zetadev.com/software/aspen/ |
michael@0 | 65 | PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" |
michael@0 | 66 | else |
michael@0 | 67 | PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" |
michael@0 | 68 | fi |
michael@0 | 69 | fi |
michael@0 | 70 | export PS1 |
michael@0 | 71 | fi |
michael@0 | 72 | |
michael@0 | 73 | alias pydoc="python -m pydoc" |
michael@0 | 74 | |
michael@0 | 75 | # This should detect bash and zsh, which have a hash command that must |
michael@0 | 76 | # be called to get it to forget past commands. Without forgetting |
michael@0 | 77 | # past commands the $PATH changes we made may not be respected |
michael@0 | 78 | if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then |
michael@0 | 79 | hash -r 2>/dev/null |
michael@0 | 80 | fi |