Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 325379 - Scripts generated by python.eclass's python_generate_wrapper_scripts() are not compatible with virtualenv
Summary: Scripts generated by python.eclass's python_generate_wrapper_scripts() are no...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-24 17:39 UTC by Mike Nerone
Modified: 2011-01-25 16:34 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to python.eclass so that wrapper scripts handle virtualenvs correctly (?) (python_eclass_virtual_env.patch,4.84 KB, patch)
2010-06-24 17:42 UTC, Mike Nerone
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Nerone 2010-06-24 17:39:07 UTC
When a virtualenv environment has been activated ("source bin/activate" in the virtualenv), PATH is modified so that the virtualenv's python executable is found first, thereby causing any executed python scripts to run in the virtualenv's context.

The wrapper scripts generated by python_generate_wrapper_scripts() break this by ignoring the virtualenv and instead deriving a different path to the python executable (in an attempt to honor eselect). This makes virtualenvs, a staple of python development, very difficult to use in Gentoo.

The failure can be demonstrated by simply following the basic pylons tutorial at http://pylonshq.com/docs/en/0.9.7/tutorials/quickwiki_tutorial/ :

================================
$ virtualenv testenv
New python executable in testenv/bin/python2.6
Also creating executable in testenv/bin/python
Installing setuptools............done.        
$ source testenv/bin/activate
(testenv)$ easy_install QuickWiki==0.1.6
Searching for QuickWiki==0.1.6          
<SNIP: Successful installation of QuickWiki into the "testenv" virtualenv>
Finished processing dependencies for QuickWiki==0.1.6
(testenv)$ paster make-config QuickWiki test.ini
Must install QuickWiki
install_dir /usr/lib/python2.6/site-packages/
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/usr/lib/python2.6/site-packages/test-easy-install-12302.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /usr/lib/python2.6/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  http://packages.python.org/distribute/easy_install.html

Please make the appropriate changes for your system and try again.
================================

As seen above, paster first fails to recognize that QuickWiki is installed in the virtualenv even though that virtualenv is activated. It then wrongly attempts to install it to system directories instead of into the virtualenv. This is all caused by the fact that the wrapper script fails to honor the activated virtualenv.
Comment 1 Mike Nerone 2010-06-24 17:42:14 UTC
Created attachment 236421 [details, diff]
Patch to python.eclass so that wrapper scripts handle virtualenvs correctly (?)

This is a patch to python.eclass that I believe will result in wrapper scripts that handle the virtualenv situation sanely and successfully. So far, it works for me.
Comment 2 Mike Nerone 2010-06-24 17:44:10 UTC
BTW, the patch isn't as big as it looks. All that's new is one block of code + two lines. The rest of the diff is caused by indentation changes.
Comment 3 Mike Nerone 2011-01-25 05:11:56 UTC
Testing would seem to indicate that this problem got fixed along the way (along with making many other improvements) since I opened this bug. I think this can be closed. Thanks, devs!