| OLD | NEW |
| (Empty) |
| 1 Virtualenv | |
| 2 ========== | |
| 3 | |
| 4 `Mailing list <http://groups.google.com/group/python-virtualenv>`_ | | |
| 5 `Issues <https://github.com/pypa/virtualenv/issues>`_ | | |
| 6 `Github <https://github.com/pypa/virtualenv>`_ | | |
| 7 `PyPI <https://pypi.python.org/pypi/virtualenv/>`_ | | |
| 8 User IRC: #pypa | |
| 9 Dev IRC: #pypa-dev | |
| 10 | |
| 11 Introduction | |
| 12 ------------ | |
| 13 | |
| 14 ``virtualenv`` is a tool to create isolated Python environments. | |
| 15 | |
| 16 The basic problem being addressed is one of dependencies and versions, | |
| 17 and indirectly permissions. Imagine you have an application that | |
| 18 needs version 1 of LibFoo, but another application requires version | |
| 19 2. How can you use both these applications? If you install | |
| 20 everything into ``/usr/lib/python2.7/site-packages`` (or whatever your | |
| 21 platform's standard location is), it's easy to end up in a situation | |
| 22 where you unintentionally upgrade an application that shouldn't be | |
| 23 upgraded. | |
| 24 | |
| 25 Or more generally, what if you want to install an application *and | |
| 26 leave it be*? If an application works, any change in its libraries or | |
| 27 the versions of those libraries can break the application. | |
| 28 | |
| 29 Also, what if you can't install packages into the global | |
| 30 ``site-packages`` directory? For instance, on a shared host. | |
| 31 | |
| 32 In all these cases, ``virtualenv`` can help you. It creates an | |
| 33 environment that has its own installation directories, that doesn't | |
| 34 share libraries with other virtualenv environments (and optionally | |
| 35 doesn't access the globally installed libraries either). | |
| 36 | |
| 37 .. comment: split here | |
| 38 | |
| 39 .. toctree:: | |
| 40 :maxdepth: 2 | |
| 41 | |
| 42 installation | |
| 43 userguide | |
| 44 reference | |
| 45 development | |
| 46 changes | |
| 47 | |
| 48 .. warning:: | |
| 49 | |
| 50 Python bugfix releases 2.6.8, 2.7.3, 3.1.5 and 3.2.3 include a change that | |
| 51 will cause "import random" to fail with "cannot import name urandom" on any | |
| 52 virtualenv created on a Unix host with an earlier release of Python | |
| 53 2.6/2.7/3.1/3.2, if the underlying system Python is upgraded. This is due to | |
| 54 the fact that a virtualenv uses the system Python's standard library but | |
| 55 contains its own copy of the Python interpreter, so an upgrade to the system | |
| 56 Python results in a mismatch between the version of the Python interpreter | |
| 57 and the version of the standard library. It can be fixed by removing | |
| 58 ``$ENV/bin/python`` and re-running virtualenv on the same target directory | |
| 59 with the upgraded Python. | |
| 60 | |
| 61 Other Documentation and Links | |
| 62 ----------------------------- | |
| 63 | |
| 64 * `Blog announcement of virtualenv`__. | |
| 65 | |
| 66 .. __: http://blog.ianbicking.org/2007/10/10/workingenv-is-dead-long-live-virt
ualenv/ | |
| 67 | |
| 68 * James Gardner has written a tutorial on using `virtualenv with | |
| 69 Pylons | |
| 70 <http://wiki.pylonshq.com/display/pylonscookbook/Using+a+Virtualenv+Sandbox>`_
. | |
| 71 | |
| 72 * Chris Perkins created a `showmedo video including virtualenv | |
| 73 <http://showmedo.com/videos/video?name=2910000&fromSeriesID=291>`_. | |
| 74 | |
| 75 * Doug Hellmann's `virtualenvwrapper`_ is a useful set of scripts to make | |
| 76 your workflow with many virtualenvs even easier. `His initial blog post on it`
__. | |
| 77 He also wrote `an example of using virtualenv to try IPython`__. | |
| 78 | |
| 79 .. _virtualenvwrapper: https://pypi.python.org/pypi/virtualenvwrapper/ | |
| 80 .. __: http://www.doughellmann.com/articles/CompletelyDifferent-2008-05-virtua
lenvwrapper/index.html | |
| 81 .. __: http://www.doughellmann.com/articles/CompletelyDifferent-2008-02-ipytho
n-and-virtualenv/index.html | |
| 82 | |
| 83 * `Pew`_ is another wrapper for virtualenv that makes use of a different | |
| 84 activation technique. | |
| 85 | |
| 86 .. _Pew: https://pypi.python.org/pypi/pew/ | |
| 87 | |
| 88 * `Using virtualenv with mod_wsgi | |
| 89 <http://code.google.com/p/modwsgi/wiki/VirtualEnvironments>`_. | |
| 90 | |
| 91 * `virtualenv commands | |
| 92 <https://github.com/thisismedium/virtualenv-commands>`_ for some more | |
| 93 workflow-related tools around virtualenv. | |
| 94 | |
| 95 * PyCon US 2011 talk: `Reverse-engineering Ian Bicking's brain: inside pip and v
irtualenv | |
| 96 <http://pyvideo.org/video/568/reverse-engineering-ian-bicking--39-s-brain--ins
i>`_. | |
| 97 By the end of the talk, you'll have a good idea exactly how pip | |
| 98 and virtualenv do their magic, and where to go looking in the source | |
| 99 for particular behaviors or bug fixes. | |
| 100 | |
| 101 Compare & Contrast with Alternatives | |
| 102 ------------------------------------ | |
| 103 | |
| 104 There are several alternatives that create isolated environments: | |
| 105 | |
| 106 * ``workingenv`` (which I do not suggest you use anymore) is the | |
| 107 predecessor to this library. It used the main Python interpreter, | |
| 108 but relied on setting ``$PYTHONPATH`` to activate the environment. | |
| 109 This causes problems when running Python scripts that aren't part of | |
| 110 the environment (e.g., a globally installed ``hg`` or ``bzr``). It | |
| 111 also conflicted a lot with Setuptools. | |
| 112 | |
| 113 * `virtual-python | |
| 114 <http://peak.telecommunity.com/DevCenter/EasyInstall#creating-a-virtual-python
>`_ | |
| 115 is also a predecessor to this library. It uses only symlinks, so it | |
| 116 couldn't work on Windows. It also symlinks over the *entire* | |
| 117 standard library and global ``site-packages``. As a result, it | |
| 118 won't see new additions to the global ``site-packages``. | |
| 119 | |
| 120 This script only symlinks a small portion of the standard library | |
| 121 into the environment, and so on Windows it is feasible to simply | |
| 122 copy these files over. Also, it creates a new/empty | |
| 123 ``site-packages`` and also adds the global ``site-packages`` to the | |
| 124 path, so updates are tracked separately. This script also installs | |
| 125 Setuptools automatically, saving a step and avoiding the need for | |
| 126 network access. | |
| 127 | |
| 128 * `zc.buildout <http://pypi.python.org/pypi/zc.buildout>`_ doesn't | |
| 129 create an isolated Python environment in the same style, but | |
| 130 achieves similar results through a declarative config file that sets | |
| 131 up scripts with very particular packages. As a declarative system, | |
| 132 it is somewhat easier to repeat and manage, but more difficult to | |
| 133 experiment with. ``zc.buildout`` includes the ability to setup | |
| 134 non-Python systems (e.g., a database server or an Apache instance). | |
| 135 | |
| 136 I *strongly* recommend anyone doing application development or | |
| 137 deployment use one of these tools. | |
| OLD | NEW |