diff options
Diffstat (limited to 'Lib/venv/scripts')
-rw-r--r-- | Lib/venv/scripts/nt/Activate.ps1 | 34 | ||||
-rw-r--r-- | Lib/venv/scripts/nt/Deactivate.ps1 | 19 | ||||
-rw-r--r-- | Lib/venv/scripts/nt/activate.bat | 31 | ||||
-rw-r--r-- | Lib/venv/scripts/nt/deactivate.bat | 17 | ||||
-rw-r--r-- | Lib/venv/scripts/nt/pydoc.py | 4 | ||||
-rw-r--r-- | Lib/venv/scripts/posix/activate | 76 | ||||
-rwxr-xr-x | Lib/venv/scripts/posix/pydoc | 5 |
7 files changed, 186 insertions, 0 deletions
diff --git a/Lib/venv/scripts/nt/Activate.ps1 b/Lib/venv/scripts/nt/Activate.ps1 new file mode 100644 index 00000000000..1c5ef98726a --- /dev/null +++ b/Lib/venv/scripts/nt/Activate.ps1 @@ -0,0 +1,34 @@ +$env:VIRTUAL_ENV="__VENV_DIR__"
+
+# Revert to original values
+if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
+ copy-item function:_OLD_VIRTUAL_PROMPT function:prompt
+ remove-item function:_OLD_VIRTUAL_PROMPT
+}
+
+if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) {
+ copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME
+ remove-item env:_OLD_VIRTUAL_PYTHONHOME
+}
+
+if (Test-Path env:_OLD_VIRTUAL_PATH) {
+ copy-item env:_OLD_VIRTUAL_PATH env:PATH
+ remove-item env:_OLD_VIRTUAL_PATH
+}
+
+# Set the prompt to include the env name
+copy-item function:prompt function:_OLD_VIRTUAL_PROMPT
+function prompt {
+ Write-Host -NoNewline -ForegroundColor Green '[__VENV_NAME__]'
+ _OLD_VIRTUAL_PROMPT
+}
+
+# Clear PYTHONHOME
+if (Test-Path env:PYTHONHOME) {
+ copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME
+ remove-item env:PYTHONHOME
+}
+
+# Add the venv to the PATH
+copy-item env:PATH env:_OLD_VIRTUAL_PATH
+$env:PATH = "$env:VIRTUAL_ENV\__VENV_BIN_NAME__;$env:PATH"
diff --git a/Lib/venv/scripts/nt/Deactivate.ps1 b/Lib/venv/scripts/nt/Deactivate.ps1 new file mode 100644 index 00000000000..3d1e96bc8cd --- /dev/null +++ b/Lib/venv/scripts/nt/Deactivate.ps1 @@ -0,0 +1,19 @@ +# Revert to original values
+if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
+ copy-item function:_OLD_VIRTUAL_PROMPT function:prompt
+ remove-item function:_OLD_VIRTUAL_PROMPT
+}
+
+if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) {
+ copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME
+ remove-item env:_OLD_VIRTUAL_PYTHONHOME
+}
+
+if (Test-Path env:_OLD_VIRTUAL_PATH) {
+ copy-item env:_OLD_VIRTUAL_PATH env:PATH
+ remove-item env:_OLD_VIRTUAL_PATH
+}
+
+if (Test-Path env:VIRTUAL_ENV) {
+ remove-item env:VIRTUAL_ENV
+}
diff --git a/Lib/venv/scripts/nt/activate.bat b/Lib/venv/scripts/nt/activate.bat new file mode 100644 index 00000000000..c45e65a26f5 --- /dev/null +++ b/Lib/venv/scripts/nt/activate.bat @@ -0,0 +1,31 @@ +@echo off
+set VIRTUAL_ENV=__VENV_DIR__
+
+if not defined PROMPT (
+ set PROMPT=$P$G
+)
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set PROMPT=%_OLD_VIRTUAL_PROMPT%
+)
+
+if defined _OLD_VIRTUAL_PYTHONHOME (
+ set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
+)
+
+set _OLD_VIRTUAL_PROMPT=%PROMPT%
+set PROMPT=__VENV_NAME__%PROMPT%
+
+if defined PYTHONHOME (
+ set _OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%
+ set PYTHONHOME=
+)
+
+if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%; goto SKIPPATH
+
+set _OLD_VIRTUAL_PATH=%PATH%
+
+:SKIPPATH
+set PATH=%VIRTUAL_ENV%\__VENV_BIN_NAME__;%PATH%
+
+:END
diff --git a/Lib/venv/scripts/nt/deactivate.bat b/Lib/venv/scripts/nt/deactivate.bat new file mode 100644 index 00000000000..62da5b13080 --- /dev/null +++ b/Lib/venv/scripts/nt/deactivate.bat @@ -0,0 +1,17 @@ +@echo off
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set PROMPT=%_OLD_VIRTUAL_PROMPT%
+)
+set _OLD_VIRTUAL_PROMPT=
+
+if defined _OLD_VIRTUAL_PYTHONHOME (
+ set PYTHONHOME=%_OLD_VIRTUAL_PYTHONHOME%
+ set _OLD_VIRTUAL_PYTHONHOME=
+)
+
+if defined _OLD_VIRTUAL_PATH set PATH=%_OLD_VIRTUAL_PATH%
+
+set _OLD_VIRTUAL_PATH=
+
+:END
diff --git a/Lib/venv/scripts/nt/pydoc.py b/Lib/venv/scripts/nt/pydoc.py new file mode 100644 index 00000000000..dbf2db71b49 --- /dev/null +++ b/Lib/venv/scripts/nt/pydoc.py @@ -0,0 +1,4 @@ +#!__VENV_PYTHON__ +if __name__ == '__main__': + import sys, pydoc + sys.exit(pydoc.cli()) diff --git a/Lib/venv/scripts/posix/activate b/Lib/venv/scripts/posix/activate new file mode 100644 index 00000000000..c241450c0b0 --- /dev/null +++ b/Lib/venv/scripts/posix/activate @@ -0,0 +1,76 @@ +# This file must be used with "source bin/activate" *from bash* +# you cannot run it directly + +deactivate () { + # reset old environment variables + if [ -n "$_OLD_VIRTUAL_PATH" ] ; then + PATH="$_OLD_VIRTUAL_PATH" + export PATH + unset _OLD_VIRTUAL_PATH + fi + if [ -n "$_OLD_VIRTUAL_PYTHONHOME" ] ; then + PYTHONHOME="$_OLD_VIRTUAL_PYTHONHOME" + export PYTHONHOME + unset _OLD_VIRTUAL_PYTHONHOME + fi + + # This should detect bash and zsh, which have a hash command that must + # be called to get it to forget past commands. Without forgetting + # past commands the $PATH changes we made may not be respected + if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then + hash -r + fi + + if [ -n "$_OLD_VIRTUAL_PS1" ] ; then + PS1="$_OLD_VIRTUAL_PS1" + export PS1 + unset _OLD_VIRTUAL_PS1 + fi + + unset VIRTUAL_ENV + if [ ! "$1" = "nondestructive" ] ; then + # Self destruct! + unset -f deactivate + fi +} + +# unset irrelavent variables +deactivate nondestructive + +VIRTUAL_ENV="__VENV_DIR__" +export VIRTUAL_ENV + +_OLD_VIRTUAL_PATH="$PATH" +PATH="$VIRTUAL_ENV/__VENV_BIN_NAME__:$PATH" +export PATH + +# unset PYTHONHOME if set +# this will fail if PYTHONHOME is set to the empty string (which is bad anyway) +# could use `if (set -u; : $PYTHONHOME) ;` in bash +if [ -n "$PYTHONHOME" ] ; then + _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME" + unset PYTHONHOME +fi + +if [ -z "$VIRTUAL_ENV_DISABLE_PROMPT" ] ; then + _OLD_VIRTUAL_PS1="$PS1" + if [ "x__VENV_NAME__" != x ] ; then + PS1="__VENV_NAME__$PS1" + else + if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then + # special case for Aspen magic directories + # see http://www.zetadev.com/software/aspen/ + PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1" + else + PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1" + fi + fi + export PS1 +fi + +# This should detect bash and zsh, which have a hash command that must +# be called to get it to forget past commands. Without forgetting +# past commands the $PATH changes we made may not be respected +if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then + hash -r +fi diff --git a/Lib/venv/scripts/posix/pydoc b/Lib/venv/scripts/posix/pydoc new file mode 100755 index 00000000000..92337711289 --- /dev/null +++ b/Lib/venv/scripts/posix/pydoc @@ -0,0 +1,5 @@ +#!__VENV_PYTHON__ +if __name__ == '__main__': + import sys, pydoc + sys.exit(pydoc.cli()) + |