pip install --link-system?
Last update on .
Just ran into the little wonder that is "pip install PIL", which results in a useless PIL (i.e. one without JPEG, PNG or TrueType support, but which imports, so doesn't trigger the "I don't have PIL code paths"). There's other cases with e.g. PostgreSQL drivers, or complex GUI libraries, where if you don't happen to have a toolchain installed you are out-of-luck on the install, and really, you'd rather just use the .deb file version anyway. What I'd really like is something like this:
pip install --link-system PIL psycopg2 pygame
where the 3 packages there would be looked up in the system Python corresponding to the Python in the virtualenv and links would be created from venv/lib/pythonX.Y/site-packages to the system-level packages (if it's more reliable, copy the files, I really don't mind).
Does something already do this elegantly/cleanly? I have a stupid little script that works for the few libraries I have (basically just imports them, printing out the paths, which I then script to create the links), but I really want something where I can just add a flag (or whatever) to the requirements file so that the whole thing is transparent (save that if the library isn't installed at the system level the user gets told to install it manually (or something)).
Comments are closed.
Pingbacks are closed.
Nick Coghlan on 02/06/2012 7:29 p.m. #
For PIL specifically, there's "pip install Pillow" (which, as far as I know, just fixes PIL's build problems without changing the module itself).
More generally, not yet: https://github.com/pypa/pip/issues/300
(includes a link to my own "venv_link.py" which sounds a lot like the one you wrote for yourself)
Anand Kumria on 02/06/2012 9:04 p.m. #
Martin Gaitan on 02/06/2012 9:07 p.m. #
I work with Doug Hellmann's virtualenvwrapper which adds a lot of sweets on top of virtualenv. Particulary you have the command add2virtualenv
for example, to link my apt-get installed PIL package into the virtualenv I do:
(myvirtualenv) $ add2virtualenv /usr/lib/python2.7/dist-packages/PIL
hynek on 02/07/2012 2:38 a.m. #
Back when I built my virtualenvs "on-demand" for deployments, I did exactly that: I "ln -s"'ed libs like psycopg2 from the system site-packages.
The only package I remember that was acting up was python-ldap – but I'm afraid such packages will be problem for pip as well.
Arruda on 02/07/2012 6:52 a.m. #
I've done a app that does that, its venv-dependencies.
You install it outside of an venv and then inside your env you call the cmd link_venv.py "module" "other_module"
See if it helps you out. =)
Scott Rubin on 02/07/2012 12:52 p.m. #
Why do you even need the --link-system option? It should just be the default setting. No extra option needed.
Mike Fletcher on 02/08/2012 9:02 a.m. #
Virtualenv's default is becoming --no-site-packages, so "include everything" is no longer the default (but can be enabled). The point here, however, is that we want an isolated environment with just a *few* site packages, i.e. it should not pick up system copies of PyOpenGL (which I'm developing/testing), but it *should* pick up system Pygame/PIL.