[SRU] AttributeError: 'Requirement' object has no attribute 'project_name'

Bug #1626258 reported by Felipe Reyes
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-pip (Debian)
Fix Released
Unknown
python-pip (Ubuntu)
Fix Released
High
Felipe Reyes
Xenial
Fix Released
High
Felipe Reyes
Yakkety
Fix Released
High
Felipe Reyes
Zesty
Fix Released
High
Felipe Reyes

Bug Description

[impact]

pip 8.1.1 (xenial) tries to access properties that were dropped from the Requirement class and when pip's code tries to access Requirement.project_name fails, this was fixed in 8.1.2.

Any user trying to install a package that triggers the pkg_resources.VersionConflict exception during will get the error "AttributeError: 'Requirement' object has no attribute 'project_name'"

[Test Case]

# wget https://pypi.python.org/packages/49/6f/183063f01aae1e025cf0130772b55848750a2f3a89bfa11b385b35d7329d/requests-2.10.0.tar.gz
# wget https://pypi.python.org/packages/2e/ad/e627446492cc374c284e82381215dcd9a0a87c4f6e90e9789afefe6da0ad/requests-2.11.1.tar.gz
# pip install requests-2.10.0.tar.gz
# pip install requests-2.11.1.tar.gz

Expected result:

pip installs requests 2.11.1

Actual result:

pip fails with the following exception

root@pip-x:/home/ubuntu# pip install requests-2.11.1.tar.gz
Processing ./requests-2.11.1.tar.gz
Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 328, in run
    wb.build(autobuilding=True)
  File "/usr/lib/python2.7/dist-packages/pip/wheel.py", line 748, in build
    self.requirement_set.prepare_files(self.finder)
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 360, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/lib/python2.7/dist-packages/pip/req/req_set.py", line 600, in _prepare_file
    req_to_install.check_if_exists()
  File "/usr/lib/python2.7/dist-packages/pip/req/req_install.py", line 1011, in check_if_exists
    self.req.project_name
AttributeError: 'Requirement' object has no attribute 'project_name'
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

[Regression Potential]

* None, this change is already part of 8.1.2, and most of the change is already part of the ubuntu package, there is just one last place where the code is accessing Requirement.project_name

[Other info]

From 8e236dd6a09bd2f70f9d4fc886da8c354d4c58f2 Mon Sep 17 00:00:00 2001
From: Donald Stufft <email address hidden>
Date: Wed, 11 Nov 2015 18:51:46 -0500
Subject: [PATCH] Update to use the Requirement class from packaging
https://github.com/pypa/pip/commit/8e236dd6a09bd2f70f9d4fc886da8c354d4c58f2

This SRU fixes autopkgtest, so the building process to get into -proposed doesn't block it.

Revision history for this message
Felipe Reyes (freyes) wrote :

Yakkety has pip 8.1.2, so devel series is ok, this just affects Xenial

Revision history for this message
Felipe Reyes (freyes) wrote :

Attaching debdiff for xenial

description: updated
summary: - AttributeError: 'Requirement' object has no attribute 'project_name'
+ [SRU] AttributeError: 'Requirement' object has no attribute
+ 'project_name'
Felipe Reyes (freyes)
tags: added: sts-sru
Louis Bouchard (louis)
Changed in python-pip (Ubuntu Xenial):
assignee: nobody → Felipe Reyes (freyes)
Changed in python-pip (Ubuntu):
status: New → Invalid
Changed in python-pip (Ubuntu Xenial):
status: New → In Progress
importance: Undecided → High
Revision history for this message
Felipe Reyes (freyes) wrote :

Updated patch to address louis' feedback (renamed patch to give a more meaningful name, add dep3 headers)

Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Hello Felipe, or anyone else affected,

Accepted python-pip into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-pip/8.1.1-2ubuntu0.3 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-pip (Ubuntu Xenial):
status: In Progress → Fix Committed
tags: added: verification-needed
Mathew Hodson (mhodson)
Changed in python-pip (Ubuntu):
importance: Undecided → High
status: Invalid → Fix Released
Revision history for this message
Bryan Quigley (bryanquigley) wrote :

Tested with python requests and an upgrade. Both with root and without, and both worked.

tags: added: verification-done
removed: verification-needed
Revision history for this message
Felipe Reyes (freyes) wrote :

It worked here too. Testing evidence can be found at http://pastebin.ubuntu.com/23244256/

Revision history for this message
Robie Basak (racb) wrote :

This is currently blocked by autopkgtest regressions in python-pip and python-virtualenv - see http://people.canonical.com/~ubuntu-archive/pending-sru.html

They look unrelated so I've requested retests for those in amd64 to see if that clears it.

Revision history for this message
Felipe Reyes (freyes) wrote : Re: [Bug 1626258] Re: [SRU] AttributeError: 'Requirement' object has no attribute 'project_name'

On Tue, 04 Oct 2016 16:20:17 -0000
Robie Basak <email address hidden> wrote:

> This is currently blocked by autopkgtest regressions in python-pip and
> python-virtualenv - see http://people.canonical.com/~ubuntu-archive
> /pending-sru.html
>
> They look unrelated so I've requested retests for those in amd64 to
> see if that clears it.

Indeed, the error is related to gcc wasn't installed.

    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.5m -I/tmp/autopkgtest.JkXi5S/autopkgtest_tmp/p3b/include/python3.5m -c src/public.c -o build/temp.linux-x86_64-3.5/src/public.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Revision history for this message
Felipe Reyes (freyes) wrote :

Running autopkgtests for python-pip 8.1.1-2ubuntu0.2 (the one currently -updates) shows the same problems in my local machine.

$ adt-run python-pip -U --apt-pocket=proposed --- qemu adt-xenial-amd64-cloud.img
...
adt-run [14:00:00]: test pip3-editable.sh: [-----------------------
Obtaining file:///tmp/autopkgtest.E3hCry/autopkgtest_tmp/stupid
Command "python setup.py egg_info" failed with error code 1 in /tmp/autopkgtest.E3hCry/autopkgtest_tmp/stupid/
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named 'setuptools'

    ----------------------------------------
adt-run [14:00:01]: test pip3-editable.sh: -----------------------]
adt-run [14:00:02]: test pip3-editable.sh: - - - - - - - - - - results - - - - - - - - - -
pip3-editable.sh FAIL non-zero exit status 1
adt-run [14:00:02]: test pip3-editable.sh: - - - - - - - - - - stderr - - - - - - - - - -
Command "python setup.py egg_info" failed with error code 1 in /tmp/autopkgtest.E3hCry/autopkgtest_tmp/stupid/
adt-run [14:00:03]: @@@@@@@@@@@@@@@@@@@@ summary
pip2-root.sh FAIL stderr: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-HXzoDE/world/
pip3-root.sh FAIL stderr: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-35cwmvo8/world/
pip2-user.sh FAIL stderr: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-QFrA_G/world/
pip3-user.sh FAIL stderr: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-lsx6jrsp/world/
pip3-editable.sh FAIL non-zero exit status 1
qemu-system-x86_64: terminating on signal 15 from pid 27975

full log at http://pastebin.ubuntu.com/23285399/

Revision history for this message
Felipe Reyes (freyes) wrote :

These are my findings:

1) debian/tests/*.sh scripts install a python package called 'world'[0], a new version of that package was uploaded in August 24th (version 4.0), this new version requires python >=3.4[1], so d/t/pip2-*.sh need to install world==3.1
2) pip tries to build a wheel during the installation of world using "python setup.py bdist_wheel", bdist_wheel is provided by python{,3}-wheel, which it is NOT a dependency of python{,3}-pip, it's in the "Recommends" section, so debian/tests/control needs to include "Restrictions: needs-recommends".

Having made the changes previously described I could run autopkgtest without errors:

autopkgtest [17:39:08]: test pip3-editable.sh: -----------------------]
autopkgtest [17:39:08]: test pip3-editable.sh: - - - - - - - - - - results - - - - - - - - - -
pip3-editable.sh PASS
autopkgtest [17:39:09]: @@@@@@@@@@@@@@@@@@@@ summary
pip2-root.sh PASS
pip3-root.sh PASS
pip2-user.sh PASS
pip3-user.sh PASS
pip3-editable.sh PASS

I'm attaching a new version of the patch that fixes these problems.

[0] https://pypi.python.org/pypi/world/
[1] require_python(0x30400f0)

Revision history for this message
Felipe Reyes (freyes) wrote :

Attaching debdiff for yakkety

Revision history for this message
Robie Basak (racb) wrote :

Thanks Felipe! So this needs a new upload. Subscribing ~ubuntu-sponsors, and marking verification-failed as the current version in proposed should not go any further.

Note that since 8.1.1-2ubuntu0.3 has been in proposed, that version number is now taken. A new upload will need 8.1.1-2ubuntu0.4.

tags: added: verification-failed
removed: verification-done
Changed in python-pip (Ubuntu Xenial):
status: Fix Committed → Triaged
Revision history for this message
Felipe Reyes (freyes) wrote :
Changed in python-pip (Ubuntu Yakkety):
status: Fix Released → In Progress
status: In Progress → Triaged
Changed in python-pip (Ubuntu Zesty):
status: New → Triaged
assignee: nobody → Felipe Reyes (freyes)
Revision history for this message
Felipe Reyes (freyes) wrote :
Revision history for this message
Felipe Reyes (freyes) wrote :
description: updated
Revision history for this message
Felipe Reyes (freyes) wrote :

Refreshed xenial patch (using 0.4), and added Y/Z patches.

Mathew Hodson (mhodson)
Changed in python-pip (Ubuntu Zesty):
importance: Undecided → High
Louis Bouchard (louis)
tags: added: sts-sponsor
Revision history for this message
Louis Bouchard (louis) wrote :

I have unsubscribed ubuntu-sponsors : I am taking care of the uploads

Changed in python-pip (Ubuntu Zesty):
status: Triaged → In Progress
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-pip - 8.1.2-2ubuntu1

---------------
python-pip (8.1.2-2ubuntu1) zesty; urgency=medium

  * d/tests:
    - control: Add needs-recommends restriction. (LP: #1626258)
    - pip2-*.sh: Install world 3.1, it's the latest version compatible
      with python2.

 -- Felipe Reyes <email address hidden> Tue, 25 Oct 2016 13:00:27 +0200

Changed in python-pip (Ubuntu Zesty):
status: In Progress → Fix Released
Revision history for this message
Barry Warsaw (barry) wrote :

I will fix this in Debian and syncpackage it back to Zesty. Thanks for the fix.

Changed in python-pip (Debian):
status: Unknown → Fix Committed
Changed in python-pip (Debian):
status: Fix Committed → Fix Released
Louis Bouchard (louis)
Changed in python-pip (Ubuntu Xenial):
status: Triaged → In Progress
Changed in python-pip (Ubuntu Yakkety):
status: Triaged → In Progress
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Hello Felipe, or anyone else affected,

Accepted python-pip into yakkety-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-pip/8.1.2-2ubuntu0.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-pip (Ubuntu Yakkety):
status: In Progress → Fix Committed
tags: removed: verification-failed
tags: added: verification-needed
Revision history for this message
Martin Pitt (pitti) wrote :

Hello Felipe, or anyone else affected,

Accepted python-pip into xenial-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/python-pip/8.1.1-2ubuntu0.4 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed.Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in python-pip (Ubuntu Xenial):
status: In Progress → Fix Committed
Louis Bouchard (louis)
tags: removed: sts-sponsor
Revision history for this message
Felipe Reyes (freyes) wrote :

Test case for xenial passes -> http://pastebin.ubuntu.com/23457302/
Test case for yakkety passes -> http://pastebin.ubuntu.com/23457392/

tags: added: verification-done verification-done-xenial verification-done-yakkety
removed: verification-needed
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for python-pip has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-pip - 8.1.2-2ubuntu0.1

---------------
python-pip (8.1.2-2ubuntu0.1) yakkety; urgency=medium

  * d/tests:
    - control: Add needs-recommends restriction. (LP: #1626258)
    - pip2-*.sh: Install world 3.1, it's the latest version compatible
      with python2.

 -- Felipe Reyes <email address hidden> Wed, 09 Nov 2016 15:02:34 +0100

Changed in python-pip (Ubuntu Yakkety):
status: Fix Committed → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

The python-virtualenv test regression is bug 1626201, thus unrelated to this update. Releasing SRU.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-pip - 8.1.1-2ubuntu0.4

---------------
python-pip (8.1.1-2ubuntu0.4) xenial; urgency=medium

  * d/patches/lp1626258.patch: Fix AttibuteError when accessing
    Requirement.project_name instead of Requirement.name. (LP: #1626258)
  * d/tests:
    - control: Add needs-recommends restriction.
    - pip2-*.sh: Install world 3.1, it's the latest version compatible
      with python2.

 -- Felipe Reyes <email address hidden> Wed, 21 Sep 2016 17:43:32 -0300

Changed in python-pip (Ubuntu Xenial):
status: Fix Committed → Fix Released
Louis Bouchard (louis)
tags: added: sts-sru-done
removed: sts-sru
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.