Skip to content

Commit 70fe24f

Browse files
committed
Add hint when resolution impossible causes have no versions
1 parent 76fc136 commit 70fe24f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,13 @@ def _report_single_requirement_conflict(
711711

712712
return DistributionNotFound(f"No matching distribution found for {req}")
713713

714+
def _has_any_candidates(self, project_name: str) -> bool:
715+
"""
716+
Check if there are any candidates available for the project name.
717+
"""
718+
candidates = self._finder.find_all_candidates(project_name)
719+
return any(not c.link.is_yanked for c in candidates)
720+
714721
def get_installation_error(
715722
self,
716723
e: ResolutionImpossible[Requirement, Candidate],
@@ -796,6 +803,22 @@ def describe_trigger(parent: Candidate) -> str:
796803
spec = constraints[key].specifier
797804
msg += f"\n The user requested (constraint) {key}{spec}"
798805

806+
# Check for causes that had no candidates
807+
causes = set()
808+
for req, _ in e.causes:
809+
causes.add(req.name)
810+
811+
no_candidates = {c for c in causes if not self._has_any_candidates(c)}
812+
if no_candidates:
813+
msg = (
814+
msg
815+
+ "\n\n"
816+
+ "Some conflict cause(s) have no "
817+
+ "available versions for your environment:"
818+
+ "\n "
819+
+ "\n ".join(sorted(no_candidates))
820+
)
821+
799822
msg = (
800823
msg
801824
+ "\n\n"

0 commit comments

Comments
 (0)