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

Change specifier detection logic to exclude compatible release clauses

This commit is contained in:
Alberto Sottile 2021-11-06 16:24:00 +01:00
parent 99cb1e0fc3
commit 8293826bf0

View file

@ -274,14 +274,24 @@ class Factory:
icans = list(result.iter_applicable())
# PEP 592: Yanked releases are ignored unless the specifier
# explicitely requests a version ('==' or '===') that can be
# explicitely pins a version (via '==' or '===') that can be
# solely satisfied by a yanked release.
all_yanked = all(ican.link.is_yanked for ican in icans)
direct_specifier = any({'==' in sp.operator for sp in specifier})
def is_pinned(specifier: SpecifierSet) -> bool:
for sp in specifier:
if sp.operator == "===":
return True
if sp.operator != "==":
continue
if sp.version.endswith(".*"):
continue
return True
return False
# PackageFinder returns earlier versions first, so we reverse.
for ican in reversed(icans):
if (all_yanked and not direct_specifier) and ican.link.is_yanked:
if (all_yanked and not is_pinned(specifier)) and ican.link.is_yanked:
continue
func = functools.partial(
self._make_candidate_from_link,