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.
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.
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.
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!