summaryrefslogtreecommitdiff
path: root/src/pip/_internal/operations/prepare.py
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume_seguin@apple.com>2022-06-06 11:39:20 -0700
committerGuillaume Seguin <guillaume_seguin@apple.com>2023-02-23 18:12:08 -0800
commitc546c99480875cfe4cdeaefa6d16bad9998d0f70 (patch)
treef00e541218d8725415e22ee394425095db8f8f4d /src/pip/_internal/operations/prepare.py
parent5e20a7bddcf05227a0c942367d92ab48b2a8293e (diff)
downloadpip-c546c99480875cfe4cdeaefa6d16bad9998d0f70.tar.gz
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.
Diffstat (limited to 'src/pip/_internal/operations/prepare.py')
-rw-r--r--src/pip/_internal/operations/prepare.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py
index 4bf414cb0..343a01bef 100644
--- a/src/pip/_internal/operations/prepare.py
+++ b/src/pip/_internal/operations/prepare.py
@@ -270,6 +270,16 @@ class RequirementPreparer:
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)
logger.info(message, information)