python/virtualenv/virtualenv_embedded/activate.sh

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/python/virtualenv/virtualenv_embedded/activate.sh	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,80 @@
     1.4 +# This file must be used with "source bin/activate" *from bash*
     1.5 +# you cannot run it directly
     1.6 +
     1.7 +deactivate () {
     1.8 +    unset pydoc
     1.9 +
    1.10 +    # reset old environment variables
    1.11 +    if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
    1.12 +        PATH="$_OLD_VIRTUAL_PATH"
    1.13 +        export PATH
    1.14 +        unset _OLD_VIRTUAL_PATH
    1.15 +    fi
    1.16 +    if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then
    1.17 +        PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME"
    1.18 +        export PYTHONHOME
    1.19 +        unset _OLD_VIRTUAL_PYTHONHOME
    1.20 +    fi
    1.21 +
    1.22 +    # This should detect bash and zsh, which have a hash command that must
    1.23 +    # be called to get it to forget past commands.  Without forgetting
    1.24 +    # past commands the $PATH changes we made may not be respected
    1.25 +    if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
    1.26 +        hash -r 2>/dev/null
    1.27 +    fi
    1.28 +
    1.29 +    if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
    1.30 +        PS1="$_OLD_VIRTUAL_PS1"
    1.31 +        export PS1
    1.32 +        unset _OLD_VIRTUAL_PS1
    1.33 +    fi
    1.34 +
    1.35 +    unset VIRTUAL_ENV
    1.36 +    if [ ! "$1" = "nondestructive" ] ; then
    1.37 +    # Self destruct!
    1.38 +        unset -f deactivate
    1.39 +    fi
    1.40 +}
    1.41 +
    1.42 +# unset irrelevant variables
    1.43 +deactivate nondestructive
    1.44 +
    1.45 +VIRTUAL_ENV="__VIRTUAL_ENV__"
    1.46 +export VIRTUAL_ENV
    1.47 +
    1.48 +_OLD_VIRTUAL_PATH="$PATH"
    1.49 +PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH"
    1.50 +export PATH
    1.51 +
    1.52 +# unset PYTHONHOME if set
    1.53 +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
    1.54 +# could use `if (set -u; : $PYTHONHOME) ;` in bash
    1.55 +if [ -n "$PYTHONHOME" ] ; then
    1.56 +    _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
    1.57 +    unset PYTHONHOME
    1.58 +fi
    1.59 +
    1.60 +if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then
    1.61 +    _OLD_VIRTUAL_PS1="$PS1"
    1.62 +    if [ "x__VIRTUAL_PROMPT__" != x ] ; then
    1.63 +        PS1="__VIRTUAL_PROMPT__$PS1"
    1.64 +    else
    1.65 +    if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
    1.66 +        # special case for Aspen magic directories
    1.67 +        # see http://www.zetadev.com/software/aspen/
    1.68 +        PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
    1.69 +    else
    1.70 +        PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
    1.71 +    fi
    1.72 +    fi
    1.73 +    export PS1
    1.74 +fi
    1.75 +
    1.76 +alias pydoc="python -m pydoc"
    1.77 +
    1.78 +# This should detect bash and zsh, which have a hash command that must
    1.79 +# be called to get it to forget past commands.  Without forgetting
    1.80 +# past commands the $PATH changes we made may not be respected
    1.81 +if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
    1.82 +    hash -r 2>/dev/null
    1.83 +fi

mercurial