Skip to content

Commit ebc103b

Browse files
committed
Display dependency chain on each Collecting line
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.
1 parent e58a8a5 commit ebc103b

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

news/C0DAB099-D9CB-438B-9091-146533DD4741.trivial.rst

Whitespace-only changes.

src/pip/_internal/operations/prepare.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ def _log_preparing_link(self, req: InstallRequirement) -> None:
268268
else:
269269
message = "Collecting %s"
270270
information = str(req.req or req)
271+
# If we used req.req, inject requirement source if available (this
272+
# would already be included if we used req directly)
273+
if req.req and req.comes_from:
274+
if isinstance(req.comes_from, str):
275+
comes_from: Optional[str] = req.comes_from
276+
else:
277+
comes_from = req.comes_from.from_path()
278+
if comes_from:
279+
information += f" (from {comes_from})"
271280

272281
if (message, information) != self._previous_requirement_header:
273282
self._previous_requirement_header = (message, information)

0 commit comments

Comments
 (0)