Skip to content

Fix the 'no matching distributions' message being shown for installable packages - #14194

Open
2ykwang wants to merge 7 commits into
pypa:mainfrom
2ykwang:fix-no-versions-hint-always-shown
Open

Fix the 'no matching distributions' message being shown for installable packages#14194
2ykwang wants to merge 7 commits into
pypa:mainfrom
2ykwang:fix-no-versions-hint-always-shown

Conversation

@2ykwang

@2ykwang 2ykwang commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #14193

Uses find_all_candidates() so the no matching distributions available.... message is only shown when the project has no candidates.

PR Checklist:

  • I agree to follow the PSF Code of Conduct.
  • I have read and have followed the CONTRIBUTING.md file.
  • I have added a news file fragment (or this PR does not need one).
  • I have read and followed the AI_POLICY.md file, and if any AI tools were used, I have disclosed it below.

Assisted-by: Codex (review)

@2ykwang

2ykwang commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

@2ykwang
2ykwang marked this pull request as ready for review July 21, 2026 02:42

@sepehr-rs sepehr-rs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the fix!

Comment thread news/14193.bugfix.rst Outdated
Co-authored-by: Sepehr Rasouli <sepehrrasouli06@gmail.com>
@2ykwang 2ykwang changed the title Fix the no-matching-distributions message being shown for installable packages Fix the 'no matching distributions' message being shown for installable packages Jul 21, 2026
@ichard26
ichard26 self-requested a review July 23, 2026 20:24

@ichard26 ichard26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the "have no matching distributions available" note would still be printed if there no distributions available from an index (or find-links), but the package is given by an direct URL requirement.

Generally, whenever an "explicit requirement -- a requirement that forces a particular distribution at a specific URI -- is specified, the finder is irrelevant since the resolver must use the explicit distributions.

@2ykwang

2ykwang commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Generally, whenever an "explicit requirement -- a requirement that forces a particular distribution at a specific URI -- is specified, the finder is irrelevant since the resolver must use the explicit distributions.

ah, you're right. should names given by an explicit requirement be excluded from the hint then?

@ichard26

ichard26 commented Aug 3, 2026

Copy link
Copy Markdown
Member

I believe so. Not sure if there's an easy way to do that though.

@2ykwang

2ykwang commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

How about something like this? We could collect the names of ExplicitRequirements in a separate set:

causes = set()
explicit_names = set()
for req, _ in e.causes:
    if isinstance(req, ExplicitRequirement):
        explicit_names.add(req.name)
    causes.add(req.name)
 

Finally, exclude ExplicitRequirement names from the _has_any_candidates() check:

no_candidates = {
    c for c in causes - explicit_names if not self._has_any_candidates(c)
}

@ichard26

ichard26 commented Aug 6, 2026

Copy link
Copy Markdown
Member

I'd have to dig into the resolver implementation further to be sure, but that looks generally OK...?

@notatallshaw
notatallshaw self-requested a review August 6, 2026 02:23
@notatallshaw

Copy link
Copy Markdown
Member

I've been meaning to review this, I'll get round to it soonish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The "no matching distributions" hint is shown for packages that are installable

4 participants