Skip to content

Commit

Permalink
Merge pull request #8349 from uranusjr/new-resolver-reject-unsupporte…
Browse files Browse the repository at this point in the history
…d-wheel
  • Loading branch information
pradyunsg authored Jun 11, 2020
2 parents b1d4fe9 + e7635b7 commit 445711c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/pip/_internal/index/package_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,11 @@ def create(
ignore_requires_python=selection_prefs.ignore_requires_python,
)

@property
def target_python(self):
# type: () -> TargetPython
return self._target_python

@property
def search_scope(self):
# type: () -> SearchScope
Expand Down
9 changes: 9 additions & 0 deletions src/pip/_internal/resolution/resolvelib/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from pip._internal.exceptions import (
InstallationError,
UnsupportedPythonVersion,
UnsupportedWheel,
)
from pip._internal.models.wheel import Wheel
from pip._internal.utils.compatibility_tags import get_supported
from pip._internal.utils.hashes import Hashes
from pip._internal.utils.misc import (
Expand Down Expand Up @@ -248,6 +250,13 @@ def make_requirement_from_install_req(self, ireq, requested_extras):
return None
if not ireq.link:
return SpecifierRequirement(ireq)
if ireq.link.is_wheel:
wheel = Wheel(ireq.link.filename)
if not wheel.supported(self._finder.target_python.get_tags()):
msg = "{} is not a supported wheel on this platform.".format(
wheel.filename,
)
raise UnsupportedWheel(msg)
cand = self._make_candidate_from_link(
ireq.link,
extras=frozenset(ireq.extras),
Expand Down
1 change: 0 additions & 1 deletion tests/functional/test_install_reqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ def test_install_unsupported_wheel_link_with_marker(script):
assert len(result.files_created) == 0


@pytest.mark.fails_on_new_resolver
def test_install_unsupported_wheel_file(script, data):
# Trying to install a local wheel with an incompatible version/type
# should fail.
Expand Down

0 comments on commit 445711c

Please sign in to comment.