Skip to content

Commit

Permalink
Present found conflicts when discarding some criterion
Browse files Browse the repository at this point in the history
Fixes gh-9254.
Closes gh-10258.
See #10258 (comment) for inspiration.
  • Loading branch information
astrojuanlu committed Mar 3, 2022
1 parent a4f7508 commit f47bc88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/pip/_internal/resolution/resolvelib/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ def __init__(self) -> None:
),
}

def discarding_conflicted_criterion(self, criterion, candidate) -> None:
msg = "Will try a different candidate, due to conflict:"
for req_info in criterion.information:
req, parent = req_info.requirement, req_info.parent
# Inspired by Factory.get_installation_error
msg += "\n "
if parent:
msg += f"{parent.name} {parent.version} depends on "
else:
msg += "The user requested "
msg += req.format_for_error()
logger.info(msg)

def backtracking(self, candidate: Candidate) -> None:
self.backtracks_by_package[candidate.name] += 1

Expand Down
3 changes: 3 additions & 0 deletions src/pip/_vendor/resolvelib/reporters.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ def adding_requirement(self, requirement, parent):
requirements passed in from ``Resolver.resolve()``.
"""

def discarding_conflicted_criterion(self, criterion, candidate):
"""Called when discarding conflicted requirements."""

def resolving_conflicts(self, causes):
"""Called when starting to attempt requirement conflict resolution.
Expand Down
1 change: 1 addition & 0 deletions src/pip/_vendor/resolvelib/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ def _attempt_to_pin_criterion(self, name):
try:
criteria = self._get_updated_criteria(candidate)
except RequirementsConflicted as e:
self._r.discarding_conflicted_criterion(e.criterion, candidate)
causes.append(e.criterion)
continue

Expand Down

0 comments on commit f47bc88

Please sign in to comment.