Bug 739275

Summary: pip-python not playing nice with virtualenv
Product: [Fedora] Fedora Reporter: Jorge Gallegos <kad>
Component: python-pipAssignee: Tim Flink <tflink>
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 15CC: metherid, tflink
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-17 23:03:12 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jorge Gallegos 2011-09-17 05:28:15 UTC
Description of problem:

pip is supposed to be able to create a virtualenv in one go with the -E option (or work with an existing virtualenv), however this doesn't work as it throws an import error about peak. Creating a virtualenv separately and then using that v-env pip script works. The pip package is a bit outdated (current version is 1.0.2), but I'm not sure if packaging the newest version would fix this issue. It would help nonetheless.


Version-Release number of selected component (if applicable):

Name        : python-pip
Arch        : noarch
Version     : 0.8.3
Release     : 1.fc15

Name        : python-virtualenv
Arch        : noarch
Version     : 1.5.1
Release     : 2.fc15


How reproducible:
Always.

Steps to Reproduce:
1. Try to install anything with /usr/bin/pip-python -E <path>
2.
3.
  
Actual results:
$ /usr/bin/pip-python --version
pip 0.8.3 from /usr/lib/python2.7/site-packages (python 2.7)
$ /usr/bin/pip-python -E /tmp/venv install bottle
Creating new virtualenv environment in /tmp/venv
  New python executable in /tmp/venv/bin/python
  Installing setuptools...done.....................
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 16, in <module>
    exit = run()
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 11, in run
    import pip
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 9, in <module>
    from pip.basecommand import command_dict, load_command, load_all_commands, command_names
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 12, in <module>
    from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
  File "/usr/lib/python2.7/site-packages/pip/baseparser.py", line 5, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 668, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2195, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1776, in declare_namespace
    __import__(parent)
ImportError: No module named peak


Expected results:
A virtual environment in /tmp/venv with the requested package installed (in the example above: bottle)

Additional info:

This works, however:

$ /usr/bin/virtualenv /tmp/venv
New python executable in /tmp/venv/bin/python
Installing setuptools............................done.

$ /usr/bin/pip-python -E /tmp/venv install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    
Installing collected packages: bottle
  Running setup.py install for bottle
    
Successfully installed bottle
Cleaning up...


But if you use the --no-site-packages, it b0rks:


$ /usr/bin/virtualenv --no-site-packages /tmp/venv
New python executable in /tmp/venv/bin/python
Installing setuptools............................done.

$ /usr/bin/pip-python -E /tmp/venv install bottle
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 16, in <module>
    exit = run()
  File "/usr/lib/python2.7/site-packages/pip/runner.py", line 11, in run
    import pip
  File "/usr/lib/python2.7/site-packages/pip/__init__.py", line 9, in <module>
    from pip.basecommand import command_dict, load_command, load_all_commands, command_names
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 12, in <module>
    from pip.baseparser import parser, ConfigOptionParser, UpdatingDefaultsHelpFormatter
  File "/usr/lib/python2.7/site-packages/pip/baseparser.py", line 5, in <module>
    import pkg_resources
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 668, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2691, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2195, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 1776, in declare_namespace
    __import__(parent)
ImportError: No module named peak

Strangely enough, using the virtualenv's pip script works even with --no-site-packages, and the version is older:

$ /tmp/venv/bin/pip --version
pip 0.8.1 from /tmp/venv/lib/python2.7/site-packages/pip-0.8.1-py2.7.egg (python 2.7)

$ /tmp/venv/bin/pip freeze
wsgiref==0.1.2

$ /tmp/venv/bin/pip install bottle
Downloading/unpacking bottle
  Downloading bottle-0.9.6.tar.gz (45Kb): 45Kb downloaded
  Running setup.py egg_info for package bottle
    
Installing collected packages: bottle
  Running setup.py install for bottle
    
Successfully installed bottle
Cleaning up...

$ /tmp/venv/bin/pip freeze
bottle==0.9.6
wsgiref==0.1.2

Comment 1 Tim Flink 2011-09-17 23:03:12 UTC
Actually, the -E option is known to be broken and will be removed from the next release of pip [1]. Their rationale is that recent versions of virtualenv all have a version of pip installed and it's better to just activate the virtualenv before installing packages instead of running an external version of pip on them.

Since there is no fix available from upstream and they are removing the -E feature, I'm closing this as CANTFIX.

If you're interested in the newer pip on fedora 15, I can make an f15 build available outside of yum when I update f16 but at this point, I'm not planning to update the f15 version from 0.8.3 because there were significant changes from 0.8.3 -> 1.0.x.

[1] http://www.pip-installer.org/en/latest/news.html#develop-unreleased

Comment 2 Jorge Gallegos 2011-09-18 00:43:59 UTC
Interesting, I didn't know they were dropping -E, but yeah I agree it makes sense. I have no urgency/need to use a newer version of pip in fedora 15, and even so I could just use a virtualenv and upgrade that pip :)

Thanks for the clarification!