PageRenderTime 26ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/docs/source/install.rst

https://bitbucket.org/dyim42/virtualenvwrapper
ReStructuredText | 320 lines | 226 code | 94 blank | 0 comment | 0 complexity | e70a35fda06d1a1ed600f59bc2f22c2c MD5 | raw file
  1. ============
  2. Installation
  3. ============
  4. .. _supported-shells:
  5. Supported Shells
  6. ================
  7. virtualenvwrapper is a set of shell *functions* defined in Bourne
  8. shell compatible syntax. Its automated tests run under these
  9. shells on OS X and Linux:
  10. * ``bash``
  11. * ``ksh``
  12. * ``zsh``
  13. It may work with other shells, so if you find that it does work with a
  14. shell not listed here please let me know. If you can modify it to
  15. work with another shell without completely rewriting it, then send a pull
  16. request through the `bitbucket project page`_. If you write a clone to
  17. work with an incompatible shell, let me know and I will link to it
  18. from this page.
  19. .. _bitbucket project page: https://bitbucket.org/dhellmann/virtualenvwrapper/
  20. Windows Command Prompt
  21. ----------------------
  22. David Marble has ported virtualenvwrapper to Windows batch scripts,
  23. which can be run under Microsoft Windows Command Prompt. This is also
  24. a separately distributed re-implementation. You can download
  25. `virtualenvwrapper-win`_ from PyPI.
  26. .. _virtualenvwrapper-win: http://pypi.python.org/pypi/virtualenvwrapper-win
  27. MSYS
  28. ----
  29. It is possible to use virtualenv wrapper under `MSYS
  30. <http://www.mingw.org/wiki/MSYS>`_ with a native Windows Python
  31. installation. In order to make it work, you need to define an extra
  32. environment variable named ``MSYS_HOME`` containing the root path to
  33. the MSYS installation.
  34. ::
  35. export WORKON_HOME=$HOME/.virtualenvs
  36. export MSYS_HOME=/c/msys/1.0
  37. source /usr/local/bin/virtualenvwrapper.sh
  38. or::
  39. export WORKON_HOME=$HOME/.virtualenvs
  40. export MSYS_HOME=C:\msys\1.0
  41. source /usr/local/bin/virtualenvwrapper.sh
  42. Depending on your MSYS setup, you may need to install the `MSYS mktemp
  43. binary`_ in the ``MSYS_HOME/bin`` folder.
  44. .. _MSYS mktemp binary: http://sourceforge.net/projects/mingw/files/MSYS/mktemp/
  45. PowerShell
  46. ----------
  47. Guillermo López-Anglada has ported virtualenvwrapper to run under
  48. Microsoft's PowerShell. We have agreed that since it is not compatible
  49. with the rest of the extensions, and is largely a re-implementation
  50. (rather than an adaptation), it should be distributed separately. You
  51. can download virtualenvwrapper-powershell_ from PyPI.
  52. .. _virtualenvwrapper-powershell: http://pypi.python.org/pypi/virtualenvwrapper-powershell/2.7.1
  53. .. _supported-versions:
  54. Python Versions
  55. ===============
  56. virtualenvwrapper is tested under Python 2.6-3.3.
  57. .. _install-basic:
  58. Basic Installation
  59. ==================
  60. virtualenvwrapper should be installed into the same global
  61. site-packages area where virtualenv is installed. You may need
  62. administrative privileges to do that. The easiest way to install it
  63. is using pip_::
  64. $ pip install virtualenvwrapper
  65. or::
  66. $ sudo pip install virtualenvwrapper
  67. .. warning::
  68. virtualenv lets you create many different Python environments. You
  69. should only ever install virtualenv and virtualenvwrapper on your
  70. base Python installation (i.e. NOT while a virtualenv is active)
  71. so that the same release is shared by all Python environments that
  72. depend on it.
  73. An alternative to installing it into the global site-packages is to
  74. add it to `your user local directory
  75. <http://docs.python.org/install/index.html#alternate-installation-the-home-scheme>`__
  76. (usually `~/.local`).
  77. ::
  78. $ pip install --install-option="--user" virtualenvwrapper
  79. .. _install-shell-config:
  80. Shell Startup File
  81. ==================
  82. Add three lines to your shell startup file (``.bashrc``, ``.profile``,
  83. etc.) to set the location where the virtual environments should live,
  84. the location of your development project directories, and the location
  85. of the script installed with this package::
  86. export WORKON_HOME=$HOME/.virtualenvs
  87. export PROJECT_HOME=$HOME/Devel
  88. source /usr/local/bin/virtualenvwrapper.sh
  89. After editing it, reload the startup file (e.g., run ``source
  90. ~/.bashrc``).
  91. .. _install-lazy-loader:
  92. Lazy Loading
  93. ------------
  94. An alternative initialization script is provided for loading
  95. virtualenvwrapper lazily. Instead of sourcing ``virtualenvwrapper.sh``
  96. directly, use ``virtualenvwrapper_lazy.sh``. If
  97. ``virtualenvwrapper.sh`` is not on your ``$PATH``, set
  98. ``VIRTUALENVWRAPPER_SCRIPT`` to point to it.
  99. ::
  100. export WORKON_HOME=$HOME/.virtualenvs
  101. export PROJECT_HOME=$HOME/Devel
  102. export VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
  103. source /usr/local/bin/virtualenvwrapper_lazy.sh
  104. .. warning::
  105. When the lazy-loading version of the startup script is used,
  106. tab-completion of arguments to virtualenvwrapper commands (such as
  107. environment names) is not enabled until after the first command has
  108. been run. For example, tab completion of environments does not work
  109. for the first instance of :ref:`command-workon`.
  110. Quick-Start
  111. ===========
  112. 1. Run: ``workon``
  113. 2. A list of environments, empty, is printed.
  114. 3. Run: ``mkvirtualenv temp``
  115. 4. A new environment, ``temp`` is created and activated.
  116. 5. Run: ``workon``
  117. 6. This time, the ``temp`` environment is included.
  118. Configuration
  119. =============
  120. virtualenvwrapper can be customized by changing environment
  121. variables. Set the variables in your shell startup file *before*
  122. loading ``virtualenvwrapper.sh``.
  123. .. _variable-WORKON_HOME:
  124. Location of Environments
  125. ------------------------
  126. The variable ``WORKON_HOME`` tells virtualenvwrapper where to place
  127. your virtual environments. The default is ``$HOME/.virtualenvs``. If
  128. the directory does not exist when virtualenvwrapper is loaded, it will
  129. be created automatically.
  130. .. _variable-PROJECT_HOME:
  131. Location of Project Directories
  132. -------------------------------
  133. The variable ``PROJECT_HOME`` tells virtualenvwrapper where to place
  134. your project working directories. The variable must be set and the
  135. directory created before :ref:`command-mkproject` is used.
  136. .. seealso::
  137. * :ref:`project-management`
  138. .. _variable-VIRTUALENVWRAPPER_PROJECT_FILENAME:
  139. Project Linkage Filename
  140. ------------------------
  141. The variable ``VIRTUALENVWRAPPER_PROJECT_FILENAME`` tells
  142. virtualenvwrapper how to name the file linking a virtualenv to a
  143. project working directory. The default is ``.project``.
  144. .. seealso::
  145. * :ref:`project-management`
  146. .. _variable-VIRTUALENVWRAPPER_HOOK_DIR:
  147. Location of Hook Scripts
  148. ------------------------
  149. The variable ``VIRTUALENVWRAPPER_HOOK_DIR`` tells virtualenvwrapper
  150. where the :ref:`user-defined hooks <scripts>` should be placed. The
  151. default is ``$WORKON_HOME``.
  152. .. seealso::
  153. * :ref:`scripts`
  154. .. _variable-VIRTUALENVWRAPPER_LOG_FILE:
  155. Location of Hook Logs
  156. ---------------------
  157. The variable ``VIRTUALENVWRAPPER_LOG_FILE`` tells virtualenvwrapper
  158. where the logs for the hook loader should be written. The default is
  159. to not log from the hooks.
  160. .. _variable-VIRTUALENVWRAPPER_VIRTUALENV:
  161. .. _variable-VIRTUALENVWRAPPER_VIRTUALENV_ARGS:
  162. .. _variable-VIRTUALENVWRAPPER_PYTHON:
  163. Python Interpreter, virtualenv, and $PATH
  164. -----------------------------------------
  165. During startup, ``virtualenvwrapper.sh`` finds the first ``python``
  166. and ``virtualenv`` programs on the ``$PATH`` and remembers them to use
  167. later. This eliminates any conflict as the ``$PATH`` changes,
  168. enabling interpreters inside virtual environments where
  169. virtualenvwrapper is not installed or where different versions of
  170. virtualenv are installed. Because of this behavior, it is important
  171. for the ``$PATH`` to be set **before** sourcing
  172. ``virtualenvwrapper.sh``. For example::
  173. export PATH=/usr/local/bin:$PATH
  174. source /usr/local/bin/virtualenvwrapper.sh
  175. To override the ``$PATH`` search, set the variable
  176. ``VIRTUALENVWRAPPER_PYTHON`` to the full path of the interpreter to
  177. use and ``VIRTUALENVWRAPPER_VIRTUALENV`` to the full path of the
  178. ``virtualenv`` binary to use. Both variables *must* be set before
  179. sourcing ``virtualenvwrapper.sh``. For example::
  180. export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
  181. export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
  182. source /usr/local/bin/virtualenvwrapper.sh
  183. Default Arguments for virtualenv
  184. --------------------------------
  185. If the application identified by ``VIRTUALENVWRAPPER_VIRTUALENV``
  186. needs arguments, they can be set in
  187. ``VIRTUALENVWRAPPER_VIRTUALENV_ARGS``. The same variable can be used
  188. to set default arguments to be passed to ``virtualenv``. For example,
  189. set the value to ``--no-site-packages`` to ensure that all new
  190. environments are isolated from the system ``site-packages`` directory.
  191. ::
  192. export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
  193. Temporary Files
  194. ---------------
  195. virtualenvwrapper creates temporary files in ``$TMPDIR``. If the
  196. variable is not set, it uses ``/tmp``. To change the location of
  197. temporary files just for virtualenvwrapper, set
  198. ``VIRTUALENVWRAPPER_TMPDIR``.
  199. Site-wide Configuration
  200. -----------------------
  201. Most UNIX systems include the ability to change the configuration for
  202. all users. This typically takes one of two forms: editing the
  203. *skeleton* files for new accounts or editing the global startup file
  204. for a shell.
  205. Editing the skeleton files for new accounts means that each new user
  206. will have their private startup files preconfigured to load
  207. virtualenvwrapper. They can disable it by commenting out or removing
  208. those lines. Refer to the documentation for the shell and operating
  209. system to identify the appropriate file to edit.
  210. Modifying the global startup file for a given shell means that all
  211. users of that shell will have virtualenvwrapper enabled, and they
  212. cannot disable it. Refer to the documentation for the shell to
  213. identify the appropriate file to edit.
  214. Upgrading to 2.9
  215. ================
  216. Version 2.9 includes the features previously delivered separately by
  217. ``virtualenvwrapper.project``. If you have an older verison of the
  218. project extensions installed, remove them before upgrading.
  219. Upgrading from 1.x
  220. ==================
  221. The shell script containing the wrapper functions has been renamed in
  222. the 2.x series to reflect the fact that shells other than bash are
  223. supported. In your startup file, change ``source
  224. /usr/local/bin/virtualenvwrapper_bashrc`` to ``source
  225. /usr/local/bin/virtualenvwrapper.sh``.
  226. .. _pip: http://pypi.python.org/pypi/pip