Skip to content

Commit f47bc88

Browse files
committed
Present found conflicts when discarding some criterion
Fixes pypagh-9254. Closes pypagh-10258. See pypa#10258 (comment) for inspiration.
1 parent a4f7508 commit f47bc88

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/pip/_internal/resolution/resolvelib/reporter.py

+13
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ def __init__(self) -> None:
3232
),
3333
}
3434

35+
def discarding_conflicted_criterion(self, criterion, candidate) -> None:
36+
msg = "Will try a different candidate, due to conflict:"
37+
for req_info in criterion.information:
38+
req, parent = req_info.requirement, req_info.parent
39+
# Inspired by Factory.get_installation_error
40+
msg += "\n "
41+
if parent:
42+
msg += f"{parent.name} {parent.version} depends on "
43+
else:
44+
msg += "The user requested "
45+
msg += req.format_for_error()
46+
logger.info(msg)
47+
3548
def backtracking(self, candidate: Candidate) -> None:
3649
self.backtracks_by_package[candidate.name] += 1
3750

src/pip/_vendor/resolvelib/reporters.py

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ def adding_requirement(self, requirement, parent):
3030
requirements passed in from ``Resolver.resolve()``.
3131
"""
3232

33+
def discarding_conflicted_criterion(self, criterion, candidate):
34+
"""Called when discarding conflicted requirements."""
35+
3336
def resolving_conflicts(self, causes):
3437
"""Called when starting to attempt requirement conflict resolution.
3538

src/pip/_vendor/resolvelib/resolvers.py

+1
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def _attempt_to_pin_criterion(self, name):
212212
try:
213213
criteria = self._get_updated_criteria(candidate)
214214
except RequirementsConflicted as e:
215+
self._r.discarding_conflicted_criterion(e.criterion, candidate)
215216
causes.append(e.criterion)
216217
continue
217218

0 commit comments

Comments
 (0)