Skip to content

Commit

Permalink
Merge pull request #25 from pfmoore/wheel_priority
Browse files Browse the repository at this point in the history
Give wheels priority over sdists when installing
  • Loading branch information
qwcode committed Oct 28, 2012
2 parents 1873e80 + 4b01b90 commit 28ffb1b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pip/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,18 @@ def mkurl_pypi_url(url):
continue
applicable_versions.append((parsed_version, link, version))
#bring the latest version to the front, but maintains the priority ordering as secondary
applicable_versions = sorted(applicable_versions, key=lambda v: v[0], reverse=True)
def sort_key(ver):
k1 = ver[0]
if self.use_wheel:
_, ext = ver[1].splitext()
if ext == '.whl':
k2 = 2
else:
k2 = 1
else:
k2 = 1
return (k1, k2)
applicable_versions = sorted(applicable_versions, key=sort_key, reverse=True)
existing_applicable = bool([link for parsed_version, link, version in applicable_versions if link is InfLink])
if not upgrade and existing_applicable:
if applicable_versions[0][1] is InfLink:
Expand Down
Empty file.
Empty file.
10 changes: 10 additions & 0 deletions tests/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ def test_finder_priority_nonegg_over_eggfragments():
assert link.url.endswith('tar.gz')


def test_wheel_priority():
"""
Test wheels have priority over sdists.
"""
find_links_url = 'file://' + os.path.join(here, 'packages')
find_links = [find_links_url]
req = InstallRequirement.from_line("priority")
finder = PackageFinder(find_links, [], use_wheel=True)
found = finder.find_requirement(req, True)
assert found.url.endswith("priority-1.0-py2.py3-none-any.whl"), found

0 comments on commit 28ffb1b

Please sign in to comment.