activate 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. # This file must be used with "source bin/activate" *from bash*
  5. # you cannot run it directly
  6. deactivate () {
  7. if [ -n "$_OLD_VIRTUAL_PATH" ] ; then
  8. PATH="$_OLD_VIRTUAL_PATH"
  9. export PATH
  10. unset _OLD_VIRTUAL_PATH
  11. fi
  12. # This should detect bash and zsh, which have a hash command that must
  13. # be called to get it to forget past commands. Without forgetting
  14. # past commands the $PATH changes we made may not be respected
  15. if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
  16. hash -r
  17. fi
  18. if [ -n "$_OLD_VIRTUAL_PS1" ] ; then
  19. PS1="$_OLD_VIRTUAL_PS1"
  20. export PS1
  21. unset _OLD_VIRTUAL_PS1
  22. fi
  23. PYTHONPATH="$_OLD_PYTHONPATH"
  24. export PYTHONPATH
  25. unset _OLD_PYTHONPATH
  26. unset CUDDLEFISH_ROOT
  27. unset VIRTUAL_ENV
  28. if [ ! "$1" = "nondestructive" ] ; then
  29. # Self destruct!
  30. unset deactivate
  31. fi
  32. }
  33. # unset irrelavent variables
  34. deactivate nondestructive
  35. _OLD_PYTHONPATH="$PYTHONPATH"
  36. _OLD_VIRTUAL_PATH="$PATH"
  37. VIRTUAL_ENV="`pwd`"
  38. if [ "x$OSTYPE" = "xmsys" ] ; then
  39. CUDDLEFISH_ROOT="`pwd -W | sed s,/,\\\\\\\\,g`"
  40. PATH="`pwd`/bin:$PATH"
  41. # msys will convert any env vars with PATH in it to use msys
  42. # form and will unconvert before launching
  43. PYTHONPATH="`pwd -W`/python-lib;$PYTHONPATH"
  44. else
  45. CUDDLEFISH_ROOT="$VIRTUAL_ENV"
  46. PYTHONPATH="$VIRTUAL_ENV/python-lib:$PYTHONPATH"
  47. PATH="$VIRTUAL_ENV/bin:$PATH"
  48. fi
  49. VIRTUAL_ENV="`pwd`"
  50. export CUDDLEFISH_ROOT
  51. export PYTHONPATH
  52. export PATH
  53. _OLD_VIRTUAL_PS1="$PS1"
  54. if [ "`basename \"$VIRTUAL_ENV\"`" = "__" ] ; then
  55. # special case for Aspen magic directories
  56. # see http://www.zetadev.com/software/aspen/
  57. PS1="[`basename \`dirname \"$VIRTUAL_ENV\"\``] $PS1"
  58. else
  59. PS1="(`basename \"$VIRTUAL_ENV\"`)$PS1"
  60. fi
  61. export PS1
  62. # This should detect bash and zsh, which have a hash command that must
  63. # be called to get it to forget past commands. Without forgetting
  64. # past commands the $PATH changes we made may not be respected
  65. if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then
  66. hash -r
  67. fi
  68. python -c "from jetpack_sdk_env import welcome; welcome()"