PBR

python setup.py install doesn't install requirements that are also setup_requires.

Bug #1341341 reported by Dave Tucker
22
This bug affects 5 people
Affects Status Importance Assigned to Milestone
PBR
Fix Released
High
Unassigned

Bug Description

Given the template setup.py:

    setup(
        setup_requires=['pbr'],
        pbr=True,
    )

And a requirements.txt of:

    pbr>=0.6,<1.0
    # other packages go here

pbr is first downloaded by setuptools and installed to ./pbr-0.9.0-py2.7.egg

This is correct according to the description of setup_requires - http://pythonhosted.org//setuptools/setuptools.html

When pip processes install_requires:

    Requirement already satisfied (use --upgrade to upgrade): pbr>=0.6,<1.0 in ./pbr-0.9.0-py2.7.egg

which may be so, but it's not in site-packages and not in the pythonpath and as such an application that uses `pbr.version` will error out with:

    ImportError: No module named pbr.version

Of course, the workaround is:

    pip install -r requirements.txt && python setup.py install

But I think it would be good if manually installing requirements.txt was not necessary

Environment:
- Python 2.7.8
- pip (1.5.6)
- setuptools (5.4.1)
- virtualenv (1.11.5)
- Mac OS X 10.9.2

Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

After a package is installed you can use pkg_resources.get_distribution(name).version to find the version. Can you use that as a work-around, since the underlying problem here is really with setuptools?

Changed in pbr:
status: New → Incomplete
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

This is actually a setuptools behavior, and I think it's fixed. If pbr is not available in a virtualenv when python-openstackclient is installed, it is installed after python-openstackclient and its dependencies are installed. I verified this by running "tox -e pep8 -r; ./.tox/pep8/bin/pip show pbr"

Changed in pbr:
status: Incomplete → Invalid
Revision history for this message
Romain Hardouin (romain-hardouin) wrote :

I encountered the same issue with the latest setuptools version when using keystonemiddleware:

- keystonemiddleware 1.2.0
- python-keystoneclient 0.11.2
- setuptools 7.0
- pip 1.5.6
- Python 2.7.8

    File "/.../local/lib/python2.7/site-packages/keystonemiddleware/auth_token.py", line 175, in <module>
       from keystoneclient import access
    File "/.../local/lib/python2.7/site-packages/keystoneclient/__init__.py", line 25, in <module>
        import pbr.version
    ImportError: No module named pbr.version

This is not a blocking issue because the aforementioned workaround still works but maybe we could reopen this ticket?

Changed in pbr:
status: Invalid → Confirmed
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

I'm still not able to reproduce this. What version is "the latest setuptools"? What OS are you using?

Revision history for this message
Romain Hardouin (romain-hardouin) wrote :

Hi Doug :)

In my previous comment I put "setuptools 7.0", do you need more information?
Regarding the OS it's under Debian sid.
I can make other checks if you need.

Note that "tox -e pep8 -r; ./.tox/pep8/bin/pip show pbr" works.
It fails when running "python setup.py install".

Revision history for this message
Robert Collins (lifeless) wrote :

Ok, so this happens because:
python setup.py install triggers easy_install
that installs the eggs and adds to PYTHONPATH
we then invoke pip to install deps, and the eggs from PYTHONPATH are found by pip's 'what is installed' checks, and thus not installed.

This will be fixed when we stop calling pip install.

In the mean time, just don't use python setup.py install: we don't support that in the OpenStack ecosystem, and have stated that pip install ., or pip install -e ., are the appropriate ways to install packages.

Changed in pbr:
importance: Undecided → High
summary: - pbr does not install pbr
+ python setup.py install doesn't install requirements that are also
+ setup_requires.
Revision history for this message
Robert Collins (lifeless) wrote :

I believe this is fixed now, since we don't call pip install anymore. If it still occurs, please do reopen and we'll see about determining the minimum version of setuptools that we can be compatible with.

Changed in pbr:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.