Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resolver: Always return an install candidate last (i.e. most preferred) if matches #8014

Merged
merged 3 commits into from
Apr 18, 2020

Conversation

uranusjr
Copy link
Member

This rewrites how a SpecifierRequirement generates candidates, so it

  • Always return an AlreadyInstalledCandidate (as long as the version satisfies the specifier), even if PackageFinder does not return a candidate for the same version.
  • Always put the AlreadyInstalledCandidate last, so it’s preferred over LinkCandidate, preventing version changes if possible.

This rewrites how a SpecifierRequirement generates candidates, so it

* Always return an AlreadyInstalledCandidate (as long as the version
  satisfies the specifier), even if PackageFinder does not return a
  candidate for the same version.
* Always put the AlreadyInstalledCandidate last, so it's preferred over
  LinkCandidate, preventing version changes if possible.
@uranusjr uranusjr added the skip news Does not need a NEWS file entry (eg: trivial changes) label Apr 10, 2020
@uranusjr uranusjr changed the title Always return an install candidate last if matches Always return an install candidate last (i.e. most preferred) if matches Apr 11, 2020
@uranusjr uranusjr changed the title Always return an install candidate last (i.e. most preferred) if matches New Resolver: Always return an install candidate last (i.e. most preferred) if matches Apr 11, 2020
Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

LGTM!

src/pip/_internal/resolution/resolvelib/factory.py Outdated Show resolved Hide resolved
Copy link
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

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

One minor comment, but this LGTM!

if not should_use_installed_dist:
return self._make_candidate_from_link(
for ican in found.iter_applicable():
if dist is not None and dist.parsed_version == ican.version:
Copy link
Member

Choose a reason for hiding this comment

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

nit: Maybe rename dist as installed_dist - the point of this check wasn't obvious to me when the name is just dist. I think just renaming the variable would make that check clearer. Or you could add a comment :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@pradyunsg pradyunsg merged commit 97f6390 into pypa:master Apr 18, 2020
@uranusjr uranusjr deleted the always-return-installed-candidate branch April 18, 2020 11:25
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation skip news Does not need a NEWS file entry (eg: trivial changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants