From 65ffd338f4eb39ed46daf4c4eeb0a7c1fa19951c Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Thu, 2 Apr 2020 18:50:23 +0800 Subject: [PATCH] Explain how Requires-Python matching works --- src/pip/_internal/resolution/resolvelib/factory.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pip/_internal/resolution/resolvelib/factory.py b/src/pip/_internal/resolution/resolvelib/factory.py index c00567517..4c4bf2bee 100644 --- a/src/pip/_internal/resolution/resolvelib/factory.py +++ b/src/pip/_internal/resolution/resolvelib/factory.py @@ -71,6 +71,11 @@ class Factory(object): # type: (Optional[SpecifierSet]) -> Optional[Requirement] if self._ignore_requires_python or specifier is None: return None + # The logic here is different from SpecifierRequirement, for which we + # "find" candidates matching the specifier. But for Requires-Python, + # there is always exactly one candidate (the one specified with + # py_version_info). Here we decide whether to return that based on + # whether Requires-Python matches that one candidate or not. if self._python_candidate.version in specifier: return ExplicitRequirement(self._python_candidate) return NoMatchRequirement(self._python_candidate.name) -- GitLab