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 try user requested combinations first #8924

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/8924.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
New resolver: Tweak resolution logic to improve user experience when
user-supplied requirements conflict.
17 changes: 12 additions & 5 deletions src/pip/_internal/resolution/resolvelib/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
self._constraints = constraints
self._ignore_dependencies = ignore_dependencies
self._upgrade_strategy = upgrade_strategy
self.user_requested = user_requested
self._user_requested = user_requested

def _sort_matches(self, matches):
# type: (Iterable[Candidate]) -> Sequence[Candidate]
Expand Down Expand Up @@ -84,7 +84,7 @@ def _eligible_for_upgrade(name):
if self._upgrade_strategy == "eager":
return True
elif self._upgrade_strategy == "only-if-needed":
return (name in self.user_requested)
return (name in self._user_requested)
return False

def sort_key(c):
Expand Down Expand Up @@ -115,11 +115,18 @@ def get_preference(
self,
resolution, # type: Optional[Candidate]
candidates, # type: Sequence[Candidate]
information # type: Sequence[Tuple[Requirement, Candidate]]
information # type: Sequence[Tuple[Requirement, Optional[Candidate]]]
Copy link
Member

Choose a reason for hiding this comment

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

Part of me wonders if we could call this something else, since "information" is too generic. OTOH, dependency_information seems even worse tho. ('.')

Copy link
Member

Choose a reason for hiding this comment

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

information is what resolvelib calls it. Agreed that a better name might be nice, but let's leave that as a resolvelib question :-)

):
# type: (...) -> Any
# Use the "usual" value for now
return len(candidates)
"""Return a sort key to determine what dependency to look next.

A smaller value makes a dependency higher priority. We put direct
(user-requested) dependencies first since they may contain useful
user-specified version ranges. Users tend to expect us to catch
problems in them early as well.
"""
transitive = all(parent is not None for _, parent in information)
return (transitive, len(candidates))

def find_matches(self, requirements):
# type: (Sequence[Requirement]) -> Iterable[Candidate]
Expand Down