Skip to content

Commit 1ebeab5

Browse files
authored
Merge pull request #8319 from uranusjr/fix-prefer-binary-reqfile-new-resolver
2 parents 7d875fa + 0e4dd69 commit 1ebeab5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/pip/_internal/resolution/resolvelib/provider.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
if MYPY_CHECK_RUNNING:
77
from typing import Any, Dict, Optional, Sequence, Set, Tuple, Union
88

9-
from pip._vendor.packaging.version import _BaseVersion
10-
119
from .base import Requirement, Candidate
1210
from .factory import Factory
1311

@@ -90,17 +88,22 @@ def _eligible_for_upgrade(name):
9088
return False
9189

9290
def sort_key(c):
93-
# type: (Candidate) -> Tuple[int, _BaseVersion]
91+
# type: (Candidate) -> int
9492
"""Return a sort key for the matches.
9593
9694
The highest priority should be given to installed candidates that
9795
are not eligible for upgrade. We use the integer value in the first
9896
part of the key to sort these before other candidates.
97+
98+
We only pull the installed candidate to the bottom (i.e. most
99+
preferred), but otherwise keep the ordering returned by the
100+
requirement. The requirement is responsible for returning a list
101+
otherwise sorted for the resolver, taking account for versions
102+
and binary preferences as specified by the user.
99103
"""
100104
if c.is_installed and not _eligible_for_upgrade(c.name):
101-
return (1, c.version)
102-
103-
return (0, c.version)
105+
return 1
106+
return 0
104107

105108
return sorted(matches, key=sort_key)
106109

tests/functional/test_download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,6 @@ def test_download_exit_status_code_when_blank_requirements_file(script):
669669
script.pip('download', '-r', 'blank.txt')
670670

671671

672-
@pytest.mark.fails_on_new_resolver
673672
def test_download_prefer_binary_when_tarball_higher_than_wheel(script, data):
674673
fake_wheel(data, 'source-0.8-py2.py3-none-any.whl')
675674
result = script.pip(

0 commit comments

Comments
 (0)