diff options
author | Tzu-ping Chung <uranusjr@gmail.com> | 2020-12-03 18:25:17 +0800 |
---|---|---|
committer | Tzu-ping Chung <uranusjr@gmail.com> | 2020-12-03 20:06:28 +0800 |
commit | 82fe333c09c11b508389d9c925fec92f0c7e1ed0 (patch) | |
tree | 24a68ba9978e067aff41b9e0a8544caf264a743b | |
parent | 4ad924a66f87002195e6815a3697c3316afc02d1 (diff) | |
download | pip-82fe333c09c11b508389d9c925fec92f0c7e1ed0.tar.gz |
Also prefer requirements with non-empty specifiers
-rw-r--r-- | src/pip/_internal/resolution/resolvelib/provider.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/pip/_internal/resolution/resolvelib/provider.py b/src/pip/_internal/resolution/resolvelib/provider.py index b1df3ca52..c91f252f7 100644 --- a/src/pip/_internal/resolution/resolvelib/provider.py +++ b/src/pip/_internal/resolution/resolvelib/provider.py @@ -64,7 +64,9 @@ class PipProvider(AbstractProvider): Currently pip considers the followings in order: * Prefer if any of the known requirements points to an explicit URL. - * If equal, prefer if any requirements contain `===` and `==`. + * If equal, prefer if any requirements contain ``===`` and ``==``. + * If equal, prefer if requirements include version constraints, e.g. + ``>=`` and ``<``. * If equal, prefer user-specified (non-transitive) requirements. * If equal, order alphabetically for consistency (helps debuggability). """ @@ -90,14 +92,17 @@ class PipProvider(AbstractProvider): if any(cand is not None for cand in cands): return 0 spec_sets = (ireq.specifier for ireq in ireqs if ireq) - operators = ( + operators = [ specifier.operator for spec_set in spec_sets for specifier in spec_set - ) + ] if any(op in ("==", "===") for op in operators): return 1 - return 2 + if operators: + return 2 + # A "bare" requirement without any version requirements. + return 3 restrictive = _get_restrictive_rating(req for req, _ in information) transitive = all(parent is not None for _, parent in information) |