Skip to content

Commit 22ea509

Browse files
committed
update log message
1 parent 48fa931 commit 22ea509

File tree

3 files changed

+14
-26
lines changed

3 files changed

+14
-26
lines changed

src/pip/_internal/index/package_finder.py

+7-19
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def evaluate_link(self, link: Link) -> Tuple[bool, Optional[str]]:
223223
ignore_requires_python=self._ignore_requires_python,
224224
)
225225
if not supports_python:
226-
reason = f'{version} Requires-Python {link.requires_python}'
226+
reason = f"{version} Requires-Python {link.requires_python}"
227227
return (False, reason)
228228

229229
logger.debug("Found link %s, version: %s", link, version)
@@ -685,6 +685,11 @@ def prefer_binary(self) -> bool:
685685
def set_prefer_binary(self) -> None:
686686
self._candidate_prefs.prefer_binary = True
687687

688+
def skipped_links_requires_python(self) -> List[str]:
689+
return sorted(
690+
{reason for _, reason in self._logged_links if "Requires-Python" in reason}
691+
)
692+
688693
def make_link_evaluator(self, project_name: str) -> LinkEvaluator:
689694
canonical_name = canonicalize_name(project_name)
690695
formats = self.format_control.get_allowed_formats(canonical_name)
@@ -698,18 +703,6 @@ def make_link_evaluator(self, project_name: str) -> LinkEvaluator:
698703
ignore_requires_python=self._ignore_requires_python,
699704
)
700705

701-
def skipped_links_requires_python(self):
702-
# type: () -> List[str]
703-
return sorted(
704-
{reason for _, reason in self._logged_links if 'Requires-Python' in reason}
705-
)
706-
707-
def logged_links_rp(self):
708-
# type: () -> List[str]
709-
skips = [skip for skip in self._logged_links_rp]
710-
skips.sort()
711-
return skips
712-
713706
def _sort_links(self, links: Iterable[Link]) -> List[Link]:
714707
"""
715708
Returns elements of links in order, non-egg links first, egg links
@@ -730,7 +723,7 @@ def _log_skipped_link(self, link: Link, reason: str) -> None:
730723
if (link, reason) not in self._logged_links:
731724
# Put the link at the end so the reason is more visible and because
732725
# the link string is usually very long.
733-
logger.debug('Skipping link: %s: %s', reason, link)
726+
logger.debug("Skipping link: %s: %s", reason, link)
734727
self._logged_links.add((link, reason))
735728

736729
def get_install_candidate(
@@ -751,11 +744,6 @@ def get_install_candidate(
751744
version=result,
752745
)
753746

754-
def _log_skipped_link_rp(self, reason):
755-
# type: (str) -> None
756-
if reason not in self._logged_links_rp:
757-
self._logged_links_rp.add(reason)
758-
759747
def evaluate_links(
760748
self, link_evaluator: LinkEvaluator, links: Iterable[Link]
761749
) -> List[InstallationCandidate]:

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,12 @@ def _report_single_requirement_conflict(
582582
skips = self._finder.skipped_links_requires_python()
583583
versions = [str(v) for v in sorted({c.version for c in cands})]
584584

585+
if skips:
586+
logger.critical(
587+
"Ignored the following versions that require a different python "
588+
"version: %s",
589+
"; ".join(skips) or "none",
590+
)
585591
logger.critical(
586592
"Could not find a version that satisfies the requirement %s "
587593
"(from versions: %s)",
@@ -595,12 +601,6 @@ def _report_single_requirement_conflict(
595601
"using the '-r' flag to install the packages listed in "
596602
"requirements.txt"
597603
)
598-
logger.critical(
599-
"Found versions that do not satisfy the requirement %s "
600-
"(from versions: %s)",
601-
req_disp,
602-
", ".join(skips) or "none",
603-
)
604604

605605
return DistributionNotFound(f"No matching distribution found for {req}")
606606

tests/unit/test_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class TestLinkEvaluator:
114114
[
115115
((3, 6, 5), None, (True, "1.12")),
116116
# Test an incompatible Python.
117-
((3, 6, 4), None, (False, '1.12 Requires-Python == 3.6.5')),
117+
((3, 6, 4), None, (False, "1.12 Requires-Python == 3.6.5")),
118118
# Test an incompatible Python with ignore_requires_python=True.
119119
((3, 6, 4), True, (True, "1.12")),
120120
],

0 commit comments

Comments
 (0)