pypa / pypa/setuptools

[BUG] DistributionNotFound does not handle name normalization

Open
#3,797 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Needs Triage
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

setuptools

Python version

3.x

OS

Any

Additional environment information

No response

Description

pkg_resources.DistributionNotFound: The 'a.b<3,>=2' distribution was not found and is required . Which is true, but a-b is present. Per PEP-503, installers and backends can normalize package names, so when we search, we should look for normalized names too.

Expected behavior

We accept both a_b and a.b for requirements.

How to Reproduce

Create a package with a_b and add a package that depends on it in requires as a.b.

Output

👍

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pkg_resources DistributionNotFound lookup described in the report and reproduce the case using packages named a_b and a.b. Trace how the requirement name is compared with the installed distribution name. Done means requirements using a_b and a.b both resolve to the installed distribution, with coverage for the reproduced case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.