Skip to content

Commit

Permalink
Very verbose resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
notatallshaw committed Oct 23, 2024
1 parent 6958e28 commit fd28a93
Showing 1 changed file with 10 additions and 32 deletions.
42 changes: 10 additions & 32 deletions src/pip/_internal/resolution/resolvelib/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,17 @@


class PipReporter(BaseReporter):
def __init__(self) -> None:
self.reject_count_by_package: DefaultDict[str, int] = defaultdict(int)

self._messages_at_reject_count = {
1: (
"pip is looking at multiple versions of {package_name} to "
"determine which version is compatible with other "
"requirements. This could take a while."
),
8: (
"pip is still looking at multiple versions of {package_name} to "
"determine which version is compatible with other "
"requirements. This could take a while."
),
13: (
"This is taking longer than usual. You might need to provide "
"the dependency resolver with stricter constraints to reduce "
"runtime. See https://pip.pypa.io/warnings/backtracking for "
"guidance. If you want to abort this run, press Ctrl + C."
),
}
def adding_requirement(self, requirement: Requirement, parent: Requirement) -> None:
if parent:
logger.info("Adding requirement %s (from %s)", requirement, parent)
else:
logger.info("Adding requirement %s", requirement)

def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None:
self.reject_count_by_package[candidate.name] += 1

count = self.reject_count_by_package[candidate.name]
if count not in self._messages_at_reject_count:
return

message = self._messages_at_reject_count[count]
logger.info("INFO: %s", message.format(package_name=candidate.name))
def pinning(self, candidate: Candidate) -> None:
logger.info("Pinning %s %s", candidate.name, candidate.version)

msg = "Will try a different candidate, due to conflict:"
def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None:
msg = f"Rejecting {candidate.name} {candidate.version}, due to conflict:"
for req_info in criterion.information:
req, parent = req_info.requirement, req_info.parent
# Inspired by Factory.get_installation_error
Expand All @@ -52,7 +30,7 @@ def rejecting_candidate(self, criterion: Any, candidate: Candidate) -> None:
else:
msg += "The user requested "
msg += req.format_for_error()
logger.debug(msg)
logger.info(msg)


class PipDebuggingReporter(BaseReporter):
Expand Down

0 comments on commit fd28a93

Please sign in to comment.