Skip to content

Commit

Permalink
Display dependency chain on each Collecting line
Browse files Browse the repository at this point in the history
This tremendously helps understand why a package is being fetched and
can help investigate and fix dependency resolver backtracking issues
when incoherent constraints/package sets are provided or when new
versions of a package trigger a completely different backtracking
strategy, leading to very hard to debug situations.
  • Loading branch information
iXce committed Jun 6, 2022
1 parent e58a8a5 commit ebc103b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Empty file.
9 changes: 9 additions & 0 deletions src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ def _log_preparing_link(self, req: InstallRequirement) -> None:
else:
message = "Collecting %s"
information = str(req.req or req)
# If we used req.req, inject requirement source if available (this
# would already be included if we used req directly)
if req.req and req.comes_from:
if isinstance(req.comes_from, str):
comes_from: Optional[str] = req.comes_from
else:
comes_from = req.comes_from.from_path()
if comes_from:
information += f" (from {comes_from})"

if (message, information) != self._previous_requirement_header:
self._previous_requirement_header = (message, information)
Expand Down

0 comments on commit ebc103b

Please sign in to comment.