1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

explain requires-python ignored links

This commit is contained in:
ronaudinho 2021-03-15 23:35:42 +07:00
parent 89326c8a9f
commit 42613daf36
2 changed files with 27 additions and 3 deletions

View file

@ -225,7 +225,10 @@ class LinkEvaluator:
if not supports_python:
# Return None for the reason text to suppress calling
# _log_skipped_link().
return (False, None)
return (
False,
'{} requires-python {}'.format(version, link.requires_python),
)
logger.debug("Found link %s, version: %s", link, version)
@ -609,7 +612,8 @@ class PackageFinder:
self.format_control = format_control
# These are boring links that have already been logged somehow.
self._logged_links: Set[Link] = set()
self._logged_links = set() # type: Set[Link]
self._logged_links_rp = set() # type: Set[str]
# Don't include an allow_yanked default value to make sure each call
# site considers whether yanked releases are allowed. This also causes
@ -699,6 +703,12 @@ class PackageFinder:
ignore_requires_python=self._ignore_requires_python,
)
def logged_links_rp(self):
# type: () -> List[str]
skips = [skip for skip in self._logged_links_rp]
skips.sort()
return skips
def _sort_links(self, links: Iterable[Link]) -> List[Link]:
"""
Returns elements of links in order, non-egg links first, egg links
@ -731,7 +741,9 @@ class PackageFinder:
"""
is_candidate, result = link_evaluator.evaluate_link(link)
if not is_candidate:
if result:
if 'requires-python' in result:
self._log_skipped_link_rp(result)
else:
self._log_skipped_link(link, reason=result)
return None
@ -741,6 +753,11 @@ class PackageFinder:
version=result,
)
def _log_skipped_link_rp(self, reason):
# type: (str) -> None
if reason not in self._logged_links_rp:
self._logged_links_rp.add(reason)
def evaluate_links(
self, link_evaluator: LinkEvaluator, links: Iterable[Link]
) -> List[InstallationCandidate]:

View file

@ -579,6 +579,7 @@ class Factory:
req_disp = f"{req} (from {parent.name})"
cands = self._finder.find_all_candidates(req.project_name)
skips = self._finder.logged_links_rp()
versions = [str(v) for v in sorted({c.version for c in cands})]
logger.critical(
@ -594,6 +595,12 @@ class Factory:
"using the '-r' flag to install the packages listed in "
"requirements.txt"
)
logger.critical(
"Found versions that do not satisfy the requirement %s "
"(from versions: %s)",
req_disp,
", ".join(skips) or "none",
)
return DistributionNotFound(f"No matching distribution found for {req}")