I can install pysvn site-wide using the binary package. For example, in Ubuntu:
$ sudo apt-get install python-svn
There are a number of ways to handle this.
Allow access to the global site packages from within the virtualenv. Pass the --system-site-packages
option to virtualenv
when creating the virtual environment.
Or, use the toggleglobalsitepackages
command (from virtualenvwrapper) to allow access to global site packages.
(test1)$ toggleglobalsitepackages
Enabled global site-packages
(test1)$ python -c "import pysvn; print 'ok'"
ok
(test1)$ toggleglobalsitepackages
Disabled global site-packages
(test1)$ python -c "import pysvn; print 'ok'"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pysvn
Use easy_install to install the package in to the virtualenv using a binary installer. For example, on Windows the process might look like this:
easy_install example_installer.msi
Verify that you can install the installer site-wide, by double-clicking and running the installer in gui mode (then uninstal using the Windows Add/Remove Programs control panel). If you can install it site-wide, then easy_install can probably install it in to a virtualenv.
However, the pysvn binary installer is not structured properly for easy_install. If you try this with the Windows pysvn binary installer you get this error:
error: py27-pysvn-svn185-1.7.9-1572.exe is not a valid distutils Windows .exe
Use the add2virtualenv
command from virtualenvwrapper. This adds a .pth file to the virtualenv's site-packages directory, which gives the virtualenv access to the specified directories.
Note that you must specify the parent directory, instead of the specific package. That is, instead of
add2virtualenv /usr/lib/python2.7/dist-packages/pysvn
It should be
add2virtualenv /usr/lib/python2.7/dist-packages
See this question: add2virtualenv (virtualenv wrapper) does not work with scipy
To find the directory where a package is installed, do this:
$ python
>>> import pysvn
>>> pysvn.__file__
'/usr/lib/python2.7/dist-packages/pysvn/__init__.pyc'
The problem is, this includes all the packages in the specified directory, not just pysvn. So, it has the same drawback as toggleglobalsitepackages
.
Symlink the install directory in to the virtualenv's site-packages.
A convenient way to get to the virtualenv's site-packages directory is to use virtualenvwrapper's cdsitepackages
command
cdsitepackages
ln -s /usr/lib/python2.7/dist-packages/pysvn pysvn
On Windows, try Option 1 (easy_install from binary installer). If that fails, install globally and allow the virtualenv to access it by using virtualenvwrapper-win's toggleglobalsitepackages
command, or by passing the --system-site-packages
option to virtualenv.
On systems that support symlinking, such as Linux and OS X, use Option 3. It allows you to access the specific packages you need without allowing access to the whole global site packages.