mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
merge from 1.4.X
This commit is contained in:
commit
3c0072cc00
2 changed files with 57 additions and 4 deletions
11
pip/index.py
11
pip/index.py
|
@ -151,8 +151,10 @@ class PackageFinder(object):
|
|||
if link == InfLink: # existing install
|
||||
pri = 1
|
||||
elif link.wheel:
|
||||
# all wheel links are known to be supported at this stage
|
||||
pri = -(link.wheel.support_index_min())
|
||||
support_index = link.wheel.support_index_min()
|
||||
if support_index is None:
|
||||
raise InstallationError("%s is not a supported wheel for this platform. It can't be sorted." % link.wheel.filename)
|
||||
pri = -(support_index)
|
||||
else: # sdist
|
||||
pri = -(support_num)
|
||||
return (parsed_version, pri)
|
||||
|
@ -460,7 +462,10 @@ class PackageFinder(object):
|
|||
logger.debug('Skipping link %s; macosx10 one' % (link))
|
||||
self.logged_links.add(link)
|
||||
return []
|
||||
if link.wheel and link.wheel.name.lower() == search_name.lower():
|
||||
if link.wheel:
|
||||
if link.wheel.name.lower() != search_name.lower():
|
||||
logger.debug('Skipping link %s; wrong project name (not %s)' % (link, search_name))
|
||||
return []
|
||||
version = link.wheel.version
|
||||
if not link.wheel.supported():
|
||||
logger.debug('Skipping %s because it is not compatible with this Python' % link)
|
||||
|
|
|
@ -9,7 +9,7 @@ from pkg_resources import parse_version, Distribution
|
|||
from pip.backwardcompat import urllib
|
||||
from pip.req import InstallRequirement
|
||||
from pip.index import PackageFinder, Link
|
||||
from pip.exceptions import BestVersionAlreadyInstalled, DistributionNotFound
|
||||
from pip.exceptions import BestVersionAlreadyInstalled, DistributionNotFound, InstallationError
|
||||
from pip.util import Inf
|
||||
|
||||
from tests.lib.path import Path
|
||||
|
@ -166,6 +166,12 @@ class TestWheel:
|
|||
|
||||
assert links == results == results2, results2
|
||||
|
||||
@patch('pip.pep425tags.supported_tags', [])
|
||||
def test_link_sorting_raises_when_wheel_unsupported(self):
|
||||
links = [(parse_version('1.0'), Link('simple-1.0-py2.py3-none-TEST.whl'), '1.0')]
|
||||
finder = PackageFinder([], [], use_wheel=True)
|
||||
assert_raises(InstallationError, finder._sort_versions, links)
|
||||
|
||||
|
||||
def test_finder_priority_file_over_page(data):
|
||||
"""Test PackageFinder prefers file links over equivalent page links"""
|
||||
|
@ -455,3 +461,45 @@ def test_finder_finds_external_links_without_hashes_scraped_all_all_insecure(dat
|
|||
)
|
||||
link = finder.find_requirement(req, False)
|
||||
assert link.filename == "bar-4.0.tar.gz"
|
||||
|
||||
class test_link_package_versions(object):
|
||||
|
||||
# patch this for travis which has distribute in it's base env for now
|
||||
@patch('pip.wheel.pkg_resources.get_distribution', lambda x: Distribution(project_name='setuptools', version='0.9'))
|
||||
def setup(self):
|
||||
self.version = '1.0'
|
||||
self.parsed_version = parse_version(self.version)
|
||||
self.search_name = 'pytest'
|
||||
self.finder = PackageFinder([], [], use_wheel=True)
|
||||
|
||||
def test_link_package_versions_match_wheel(self):
|
||||
"""Test that 'pytest' archives match for 'pytest'"""
|
||||
|
||||
# TODO: Uncomment these, when #1217 is fixed
|
||||
# link = Link('http:/yo/pytest-1.0.tar.gz')
|
||||
# result = self.finder._link_package_versions(link, self.search_name)
|
||||
# assert result == [(self.parsed_version, link, self.version)], result
|
||||
|
||||
link = Link('http:/yo/pytest-1.0-py2.py3-none-any.whl')
|
||||
result = self.finder._link_package_versions(link, self.search_name)
|
||||
assert result == [(self.parsed_version, link, self.version)], result
|
||||
|
||||
def test_link_package_versions_substring_fails(self):
|
||||
"""Test that 'pytest<something> archives won't match for 'pytest'"""
|
||||
|
||||
# TODO: Uncomment these, when #1217 is fixed
|
||||
# link = Link('http:/yo/pytest-xdist-1.0.tar.gz')
|
||||
# result = self.finder._link_package_versions(link, self.search_name)
|
||||
# assert result == [], result
|
||||
|
||||
# link = Link('http:/yo/pytest2-1.0.tar.gz')
|
||||
# result = self.finder._link_package_versions(link, self.search_name)
|
||||
# assert result == [], result
|
||||
|
||||
link = Link('http:/yo/pytest_xdist-1.0-py2.py3-none-any.whl')
|
||||
result = self.finder._link_package_versions(link, self.search_name)
|
||||
assert result == [], result
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue