Skip to content

[BUG] DistributionNotFound error for ==x!y.z.* dependency in editable-installed package #3802

@MetRonnie

Description

@MetRonnie

setuptools version

setuptools==67.0.0

Python version

3.7-3.10

OS

RHEL 7, Ubuntu 22, MacOS 12

Additional environment information

Description

setuptools 67 is having a problem with a version specifier ==1!3.0.* for a dependency of the package in setup.cfg, whereas 66.1.1 did not have this problem. This only happens when the package was installed in editable mode (pip install -e .), and only seems to affect dependencies specified with an epoch and * at the end.

Problem appears to be here: https://github.com/pypa/setuptools/blob/v67.0.0/pkg_resources/__init__.py#L840

Output while paused at breakpoint at that line:

req.key  # metomi-isodatetime

# setuptools 66.1.1:
dist in req  # True

# setuptools 67.0.0:
dist in req  # False

Expected behavior

==1!3.0.* should work

How to Reproduce

  1. Create this minimal example with the file structure given in filetree.txt: https://gist.github.com/MetRonnie/f30efd9d2567c9e3091ceb4943d60227
  2. Run pip install -e . in the same directory as setup.cfg
  3. Run the command darmok

Output

Traceback (most recent call last):
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 617, in _build_master
    ws.require(__requires__)
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 956, in require
    needed = self.resolve(parse_requirements(requirements))
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 861, in _resolve_dist
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.ContextualVersionConflict: (metomi-isodatetime 1!3.0.0 (~/github/isodatetime), Requirement.parse('metomi-isodatetime==1!3.0.*'), {'cylc-flow'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "~/.conda/envs/cylc8.1/bin/cylc", line 33, in <module>
    sys.exit(load_entry_point('cylc-flow', 'console_scripts', 'cylc')())
  File "~/.conda/envs/cylc8.1/bin/cylc", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "~/.conda/envs/cylc8.1/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "~/.conda/envs/cylc8.1/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "~/github/cylc-flow-8.1/cylc/flow/scripts/cylc.py", line 26, in <module>
    import pkg_resources
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3249, in <module>
    def _initialize_master_working_set():
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3223, in _call_aside
    f(*args, **kwargs)
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3261, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 619, in _build_master
    return cls._build_from_requirements(__requires__)
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 632, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(
  File "~/.conda/envs/cylc8.1/lib/python3.10/site-packages/pkg_resources/__init__.py", line 856, in _resolve_dist
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'metomi-isodatetime==1!3.0.*' distribution was not found and is required by cylc-flow

Also viewable here: https://github.com/MetRonnie/cylc-flow/actions/runs/4044453546/jobs/6954609806#step:10:71

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions