pkg_resources.require() throws a DistributionNotFound exception if python-setuptools is not installed

Bug #563060 reported by Gediminas Paulauskas
28
This bug affects 4 people
Affects Status Importance Assigned to Milestone
distribute
Invalid
Undecided
Unassigned
distribute (Ubuntu)
Invalid
Undecided
Unassigned
Nominated for Lucid by Gediminas Paulauskas
zope.interface (Debian)
Fix Released
Unknown
zope.interface (Ubuntu)
Fix Released
Undecided
Matthias Klose
Nominated for Lucid by Gediminas Paulauskas

Bug Description

Many packages now depend only on python-pkg-resources and not python-setuptools, so the latter may be removed if it was automatically installed. However, in that case the whole mechanism stops working:

$ python
>>> import pkg_resources
>>> pkg_resources.require('zope.interface')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute

This happens because zope.interface has setuptools in it's *.egg-info/requires.txt, like many other packages, but in reality only needs pkg_resources, and that's what is installed. Distribute is not needed at all, so it is a bug that this breaks in such a way.

ProblemType: Crash
DistroRelease: Ubuntu 10.04
Package: python-pastescript 1.7.3-5ubuntu1
ProcVersionSignature: Ubuntu 2.6.32-20.29-generic 2.6.32.11+drm33.2
Uname: Linux 2.6.32-20-generic i686
NonfreeKernelModules: nvidia
Architecture: i386
Date: Wed Apr 14 13:12:48 2010
ExecutablePath: /usr/bin/paster
InterpreterPath: /usr/bin/python2.6
PackageArchitecture: all
ProcCmdline: python /usr/bin/paster serve --user=schooltool --group=schooltool --daemon --pid-file=/var/run/schooltool/schooltool-2009.pid --log-file=/var/log/schooltool/paste.log --quiet /etc/schooltool/schooltool-2009/paste.ini start
ProcEnviron: Error: [Errno 13] Permission denied: '/proc/32252/environ'
PythonArgs: ['/usr/bin/paster', 'serve', '--user=schooltool', '--group=schooltool', '--daemon', '--pid-file=/var/run/schooltool/schooltool-2009.pid', '--log-file=/var/log/schooltool/paste.log', '--quiet', '/etc/schooltool/schooltool-2009/paste.ini', 'start']
SourcePackage: pastescript
Title: paster crashed with DistributionNotFound in resolve()
UserGroups:

Revision history for this message
Gediminas Paulauskas (menesis) wrote :
visibility: private → public
tags: removed: need-duplicate-check
Revision history for this message
Matthias Klose (doko) wrote :

I'll fix that for zope.interface

> As far as I can see this bug only occurs when require()'ing a python package using python-central. python-support using package is found successfully

why would that make a difference?

affects: distribute (Ubuntu) → zope.interface (Ubuntu)
Changed in zope.interface (Ubuntu):
status: New → Triaged
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package zope.interface - 3.5.3-1ubuntu1

---------------
zope.interface (3.5.3-1ubuntu1) lucid; urgency=low

  * The egg doesn't require setuptools. LP: #563060.
 -- Matthias Klose <email address hidden> Wed, 14 Apr 2010 15:47:40 +0200

Changed in zope.interface (Ubuntu):
status: Triaged → Fix Released
Revision history for this message
Gediminas Paulauskas (menesis) wrote :

zope.interface was only an example of a package (there are many of them) that declares a dependency on setuptools (in egg-info/requires.txt) but only has python-pkg-resources dependency.

The purpose of the splitted python-pkg-resources package was to be used as a runtime dependency for exactly this purpose. But now this does not work. So this a regression of python-pkg-resources (distribute).

Also, sorry, python-support or python-central doesn't make a difference after all.

affects: zope.interface (Ubuntu) → distribute (Ubuntu)
Changed in distribute (Ubuntu):
status: Fix Released → New
Revision history for this message
Gediminas Paulauskas (menesis) wrote :

Please revert the zope.interface "fix", it is wrong. The package should depend on python-pkg-resources (that is done automatically) because it installs a file that uses it:

$ cat src/zope/__init__.py
# this is a namespace package
try:
    import pkg_resources
    pkg_resources.declare_namespace(__name__)
except ImportError:
    import pkgutil
    __path__ = pkgutil.extend_path(__path__, __name__)

True, this is optional, but the preferred way to declare namespaces.

And it does not fix this crash at all.

Changed in zope.interface (Ubuntu):
assignee: nobody → Matthias Klose (doko)
Revision history for this message
aguynamedben (benstandefer) wrote :

Yes, this is a problem with python-pkg-resources (distribute), not zope.interface, and this affects me too. python-pylibmc does the same thing. When loading pylibmc through pkg_resources, I get DistributionNotFound: pylibmc. This bug is made even worse by the fact that in 10.04 you cannot actually get the real setuptools as a work-around because Ubuntu now gives you distribute when you ask for setuptools, so you're stuck with an impossible dependency.

Revision history for this message
Neal McBurnett (nealmcb) wrote :

I just got the same error when doing a setup.py sdist under lucid for my ElectionAudits project, which worked under Hardy. What is the status?

The workaround that seems to have worked for me is to apt-get install python-setuptools, so I'm confused by comment #6.

Changed in zope.interface (Ubuntu):
status: New → Fix Released
Changed in distribute:
status: New → Invalid
Revision history for this message
Gediminas Paulauskas (menesis) wrote :

Python packages that have 'setuptools' in they install_requires have this dependency translated to python-pkg-resources by van.pydeb. It works most of the time, except when pkg_resources.require is used (like paster from python-pastescript does). This was solved in Bug #572609.

So in the end the behaviour of van.pydeb that "fixed" http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543551 is incorrect.

Changed in distribute (Ubuntu):
status: New → Invalid
Revision history for this message
Clive Darra (osde8info) wrote :
Revision history for this message
Julian Taylor (jtaylor) wrote :

this bug was reintroduced again into oneiric:
clean chroot:

$ apt-get install python-zope.interface

$ apt-cache policy python-zope.interface
python-zope.interface:
  Installed: 3.6.1-1build1
  Candidate: 3.6.1-1build1
  Version table:
 *** 3.6.1-1build1 0
        500 http://de.archive.ubuntu.com/ubuntu/ oneiric/main amd64 Packages
        100 /var/lib/dpkg/status

$ python -c 'import pkg_resources; print pkg_resources.require("zope.interface")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 654, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute

Revision history for this message
Gediminas Paulauskas (menesis) wrote :

I have reverted the fix made in 3.5.3-1ubuntu1 when I packaged a newer version for maverick, because that solution (removing setuptools from requires.txt) is not sufficient, other zope.* packages also have setuptools in their setup.py install_requires and will have the same problem.

Changed in zope.interface (Ubuntu):
status: Fix Released → Triaged
Revision history for this message
Brian Sutherland (jinty) wrote :

yes, this affects many packages (almost any namespace package) and should really be fixed at the build helper level.

We shouldn't need to apply the same patch to every zope.* package.

Revision history for this message
Julian Taylor (jtaylor) wrote :

this issue should be fixed by a rebuild due to the recent python-defaults sync:
https://launchpad.net/ubuntu/+source/python-defaults/2.7.2-4ubuntu1

python-defaults (2.7.2-2) experimental; urgency=low

  [ Piotr Ożarowski ]
    - remove setuptools from requires.txt (it is replaced with
      python-pkg-resources Debian dependency)

Changed in zope.interface (Debian):
status: Unknown → New
Revision history for this message
Julian Taylor (jtaylor) wrote :

this issue was fixed with rebuild due to the recent upload

Changed in zope.interface (Ubuntu):
status: Triaged → Fix Released
Changed in zope.interface (Debian):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Related blueprints

Remote bug watches

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