Skip to content

Entry points with extra requirements doesn't work if .dist-info is used since setuptools 20.8.1 #759

@jun66j5

Description

@jun66j5

With setuptools 20.8.1: trac.mimeview.pygments would be imported even though pygments package is not resolved. Then, an ImportError would be raised. Latest of setuptools 26.0.0 has the same behavior.

$ /dev/shm/setuptools-20.8.1/bin/pip freeze
Genshi==0.6
Trac==1.0.12
argparse==1.2.1
wsgiref==0.1.2
$ /dev/shm/setuptools-20.8.1/bin/python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import working_set
>>> for ep in working_set.iter_entry_points('trac.plugins'):
...   if 'pygments' in ep.extras:
...     break
...
>>> ep
EntryPoint.parse('trac.mimeview.pygments = trac.mimeview.pygments [pygments]')
>>> ep.load(require=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/dev/shm/setuptools-20.8.1/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/dev/shm/setuptools-20.8.1/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/dev/shm/setuptools-20.8.1/local/lib/python2.7/site-packages/trac/mimeview/pygments.py", line 16, in <module>
    import pygments
ImportError: No module named pygments
>>>

With setuptools 20.4.0: trac.mimeview.pygments wouldn't be imported and DistributionNotFound would be raised because pygments package is not resolved.

$ /dev/shm/setuptools-20.4.0/bin/pip freeze
Genshi==0.6
Trac==1.0.12
argparse==1.2.1
wsgiref==0.1.2
$ /dev/shm/setuptools-20.4.0/bin/python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pkg_resources import working_set
>>> for ep in working_set.iter_entry_points('trac.plugins'):
...   if 'pygments' in ep.extras:
...     break
...
>>> ep
EntryPoint.parse('trac.mimeview.pygments = trac.mimeview.pygments [pygments]')
>>> from pkg_resources import get_distribution
>>> ep.load(require=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/dev/shm/setuptools-20.4.0/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2202, in load
    self.require(*args, **kwargs)
  File "/dev/shm/setuptools-20.4.0/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2219, in require
    items = working_set.resolve(reqs, env, installer)
  File "/dev/shm/setuptools-20.4.0/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 830, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'Pygments>=0.6; extra == "pygments"' distribution was not found and is required by the application

We expect DistributionNotFound (or UnknownExtra?) is raised in this case. See also https://trac.edgewall.org/ticket/12282#comment:7.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs TriageIssues that need to be evaluated for severity and status.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions