updating some of the activate scripts to be more dynamic. #370

Closed
wants to merge 1 commit into
from
View
@@ -2212,21 +2212,21 @@ def convert(s):
##file activate.sh
ACTIVATE_SH = convert("""
-eJytVVFvokAQfudXTLEPtTlLeo9tvMSmJpq02hSvl7u2wRUG2QR2DSxSe7n/frOACEVNLlceRHa+
-nfl25pvZDswCnoDPQ4QoTRQsENIEPci4CsBMZBq7CAsuLOYqvmYKTTj3YxnBgiXBudGBjUzBZUJI
-BXEqgCvweIyuCjeG4eF2F5x14bcB9KQiQQWrjSddI1/oQIx6SYYeoFjzWIoIhYI1izlbhJjkKO7D
-M/QEmKfO9O7WeRo/zr4P7pyHwWxkwitcgwpQ5Ej96OX+PmiFwLeVjFUOrNYKaq1Nud3nR2n8nI2m
-k9H0friPTGVsUdptaxGrTEfpNVFEskxpXtUkkCkl1UNF9cgLBkx48J4EXyALuBtAwNYIjF5kcmUU
-abMKmMq1ULoiRbgsDEkTSsKSGFCJ6Z8vY/2xYiSacmtyAfCDdCNTVZoVF8vSTQOoEwSnOrngBkws
-MYGMBMg8/bMBLSYKS7pYEXP0PqT+ZmBT0Xuy+Pplj5yn4aM9nk72JD8/Wi+Gr98sD9eWSMOwkapD
-BbUv91XSvmyVkICt2tmXR4tWmrcUCsjWOpw87YidEC8i0gdTSOFhouJUNxR+4NYBG0MftoCTD9F7
-2rTtxG3oPwY1b2HncYwhrlmj6Wq924xtGDWqfdNxap+OYxplEurnMVo9RWks+rH8qKEtx7kZT5zJ
-4H7oOFclrN6uFe+d+nW2aIUsSgs/42EIPuOhXq+jEo3S6tX6w2ilNkDnIpHCWdEQhFgwj9pkk7FN
-l/y5eQvRSIQ5+TrL05lewxWpt/Lbhes5cJF3mLET1MGhcKCF+40tNWnUulxrpojwDo2sObdje3Bz
-N3QeHqf3D7OjEXMVV8LN3ZlvuzoWHqiUcNKHtwNd0IbvPGKYYM31nPKCgkUILw3KL+Y8l7aO1ArS
-Ad37nIU0fCj5NE5gQCuC5sOSu+UdI2NeXg/lFk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PaOXTfZaShpIXUU6wLNfR6LkF+tqdGEHqng00qoCcGIyGOLCw+DiFo4wrHqbJgXn4z
+iZjll0oeQikESkXXjpOmafONKpxDqybOKkeKuUpJTB2iszjlwzwVIE43WtgH+zydvsCRQ26z1M4c
+tL4LzO+f/FUYNLq3JGREZndqy47WOIE5NJbZgq2Z/ynXwSdcBf95Dfz7FXBs/GPF/gKR6KRx
""")
##file activate.fish
@@ -2265,10 +2265,14 @@ def convert(s):
##file activate.bat
ACTIVATE_BAT = convert("""
-eJx9UdEKgjAUfW6wfxjiIH+hEDKUFHSKLCMI7kNOEkIf9P9pTJ3OLJ/03HPPPed4Es9XS9qqwqgT
-PbGKKOdXL4aAFS7A4gvAwgijuiKlqOpGlATS2NeMLE+TjJM9RkQ+SmqAXLrBo1LLIeLdiWlD6jZt
-r7VNubWkndkXaxg5GO3UaOOKS6drO3luDDiO5my3iA0YAKGzPRV1ack8cOdhysI0CYzIPzjSiH5X
-0QcvC8Lfaj0emsVKYF2rhL5L3fCkVjV76kShi59NHwDniAHzkgDgqBcwOgTMx+gDQQqXCw==
+eJx9Ul1LwzAUfTa/4hJWWEGLD+LDxkTB4oR9FFcHQmHUJnWBmoQkWn3xt3sbt9HVal/Se+/JOeee
+9poXWwWqLMlolBghHaziFNb3D+njzWwTL9ZQC7cFqUDyGiohOeSSNbUzucD6BazOC26J/nRbJeGs
+AFqyidJcDjMapPE8CbK1MC6W79Fz7jJ6mtE6o+G4ZFFthOMI62hOduOiUpYPQ4recsbAbVH82arq
+zXHQOdpSpW/q3HB0zoThhVPmE5zyfcsd2MII7druxKtWxoGyY9B+Y2Wjhi1C7uZsbH8xfZ5FEfqg
+V1e/l0BDRV5VXRHf60UzXnE03cFjtw9ORAmMl5g1g81ydrvZR5M8LOdJCkMC+DQ89KczCXpgASUh
+8MryHR5JpXIH4iOuLt8gGdxRPwnJiR/0CEyCvdAJCUn7+rAWkqnaRh+XFyEcYH6xtodj0qd0ulxM
+l/O4veAfENQ+vDeLevnW+J8Mb9LpUYJYd/PDVje9HjP+4h5LWmStPznIVv5T2/EeSUbx4pZ8A8VS
+C1k=
""")
##file deactivate.bat
@@ -1,26 +1,33 @@
-@echo off
-set "VIRTUAL_ENV=__VIRTUAL_ENV__"
-
-if defined _OLD_VIRTUAL_PROMPT (
- set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
-) else (
- if not defined PROMPT (
- set "PROMPT=$P$G"
- )
- set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
-)
-set "PROMPT=__VIRTUAL_WINPROMPT__ %PROMPT%"
-
-if not defined _OLD_VIRTUAL_PYTHONHOME (
- set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
-)
-set PYTHONHOME=
-
-if defined _OLD_VIRTUAL_PATH (
- set "PATH=%_OLD_VIRTUAL_PATH%"
-) else (
- set "_OLD_VIRTUAL_PATH=%PATH%"
-)
-set "PATH=%VIRTUAL_ENV%\__BIN_NAME__;%PATH%"
-
-:END
+@echo off
+::Print SET VIRTUAL_ENV with no new line and no trailing spaces
+python -c "fd=open(\"%TEMP%\VirtEnv.bat\",\"w\");fd.write(\"SET VIRTUAL_ENV=\");fd.close()"
+::add the absolute path of the parent directory to the set script
+python -c "import os; print os.path.abspath(\"%~dp0\..\")">>%TEMP%\VirtEnv.bat
+::call the set script
+call %TEMP%\VirtEnv.bat
+::delete the set script
+del %TEMP%\VirtEnv.bat
+
+if defined _OLD_VIRTUAL_PROMPT (
+ set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
+) else (
+ if not defined PROMPT (
+ set "PROMPT=$P$G"
+ )
+ set "_OLD_VIRTUAL_PROMPT=%PROMPT%"
+)
+set "PROMPT=(windows.x64) %PROMPT%"
+
+if not defined _OLD_VIRTUAL_PYTHONHOME (
+ set "_OLD_VIRTUAL_PYTHONHOME=%PYTHONHOME%"
+)
+set PYTHONHOME=
+
+if defined _OLD_VIRTUAL_PATH (
+ set "PATH=%_OLD_VIRTUAL_PATH%"
+) else (
+ set "_OLD_VIRTUAL_PATH=%PATH%"
+)
+set "PATH=%VIRTUAL_ENV%\Scripts;%PATH%"
+
+:END
@@ -39,8 +39,10 @@ deactivate () {
# unset irrelevant variables
deactivate nondestructive
-VIRTUAL_ENV="__VIRTUAL_ENV__"
+pushd $(dirname ${BASH_ARGV[0]})/.. > /dev/null
+VIRTUAL_ENV=$(pwd)
export VIRTUAL_ENV
+popd > /dev/null
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/__BIN_NAME__:$PATH"
@@ -0,0 +1,46 @@
+# This file must be used with "source bin/activate.csh" *from csh*.
+# You cannot run it directly.
+# Created by Davide Di Blasi <davidedb@gmail.com>.
+
+alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; test "\!:*" != "nondestructive" && unalias deactivate && unalias pydoc'
+
+# Unset irrelevant variables.
+deactivate nondestructive
+
+
+set called=($_)
+pushd `dirname $called[2]`/.. > /dev/null
+setenv VIRTUAL_ENV `pwd`
+popd > /dev/null
+
+set _OLD_VIRTUAL_PATH="$PATH"
+setenv PATH "$VIRTUAL_ENV/__BIN_NAME__:$PATH"
+
+
+
+if ("__VIRTUAL_PROMPT__" != "") then
+ set env_name = "__VIRTUAL_PROMPT__"
+else
+ if (`basename "$VIRTUAL_ENV"` == "__") then
+ # special case for Aspen magic directories
+ # see http://www.zetadev.com/software/aspen/
+ set env_name = `basename \`dirname "$VIRTUAL_ENV"\``
+ else
+ set env_name = `basename "$VIRTUAL_ENV"`
+ endif
+endif
+
+# Could be in a non-interactive environment,
+# in which case, $prompt is undefined and we wouldn't
+# care about the prompt anyway.
+if ( $?prompt ) then
+ set _OLD_VIRTUAL_PROMPT="$prompt"
+ set prompt = "[$env_name] $prompt"
+endif
+
+unset env_name
+
+alias pydoc python -m pydoc
+
+rehash
+