Skip to content

Commit

Permalink
Prefer upper bounded requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
notatallshaw committed Oct 14, 2024
1 parent 15d3833 commit 70f4d92
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/pip/_internal/resolution/resolvelib/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,20 @@ def get_preference(
else:
_icandidates, ireqs = (), ()

operators = [
specifier.operator
operators_versions = [
(specifier.operator, specifier.version)
for specifier_set in (ireq.specifier for ireq in ireqs if ireq)
for specifier in specifier_set
]

pinned = any(op in ("==", "===") for op in operators)
unfree = bool(operators)
upper_bound = any(
op in ("<", "<=", "~=") or (op == "==" and "*" in ver)
for op, ver in operators_versions
)
pinned = any(
op == "===" or (op == "==" and "*" not in ver)
for op, ver in operators_versions
)
unfree = bool(operators_versions)

if identifier in self._user_requested:
requested_order: float = self._user_requested[identifier]
Expand Down Expand Up @@ -184,6 +190,7 @@ def get_preference(
return (
not requires_python,
not pinned,
not upper_bound,
not backtrack_cause,
inferred_depth,
requested_order,
Expand Down

0 comments on commit 70f4d92

Please sign in to comment.