Skip to content

Commit 621f688

Browse files
committed
List out helpful info on basic resolution failures
If there was a failure in resolution of a requirement that stemmed from a simple fact of there being no candidate found that could possibly satisfy it, make pip output the following diagnostic information as a warning: - Which versions of the package are available to pip (outputs "(none)" if there weren't any). - For the above versions, in which indexes were they found (outputs "(none)" if there weren't any) - Wheel cache directory path (outputs "(not used)" if cache is not used).
1 parent 7369ac2 commit 621f688

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

+16
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,22 @@ def get_installation_error(self, e):
430430
"Could not find a version that satisfies the requirement %s",
431431
req_disp,
432432
)
433+
434+
acands = self._finder.find_all_candidates(req.project_name)
435+
aversions = [str(cand.version) for cand in acands]
436+
afrom = set(str(cand.link.comes_from) for cand in acands)
437+
cache_dir = (self._wheel_cache.cache_dir
438+
if self._wheel_cache is not None else None)
439+
diagnostic_hint = (
440+
f"\nAvailable versions for '{req.project_name}':\n"
441+
f"{', '.join(aversions) if aversions else '(none)'}\n\n"
442+
f"Found in index{'es' if len(afrom) > 1 else ''}:\n"
443+
f"{', '.join(afrom) if afrom else '(none)'}\n\n"
444+
f"Cache dir:\n"
445+
f"{cache_dir or '(not used)'}"
446+
)
447+
logger.warning(diagnostic_hint)
448+
433449
return DistributionNotFound(
434450
f'No matching distribution found for {req}'
435451
)

0 commit comments

Comments
 (0)