Skip to content

Commit

Permalink
Make versions argument singular for pep425tags.get_supported()
Browse files Browse the repository at this point in the history
This simplifies the interface of this function in preparation for
switching to packaging.tags.
  • Loading branch information
chrahunt committed Nov 12, 2019
1 parent 6c04fef commit e99e820
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/pip/_internal/models/target_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ def get_tags(self):
# versions=None uses special default logic.
py_version_info = self._given_py_version_info
if py_version_info is None:
versions = None
version = None
else:
versions = [version_info_to_nodot(py_version_info)]
version = version_info_to_nodot(py_version_info)

tags = get_supported(
versions=versions,
version=version,
platform=self.platform,
abi=self.abi,
impl=self.implementation,
Expand Down
10 changes: 6 additions & 4 deletions src/pip/_internal/pep425tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def get_all_minor_versions_as_strings(version_info):


def get_supported(
versions=None, # type: Optional[List[str]]
version=None, # type: Optional[str]
platform=None, # type: Optional[str]
impl=None, # type: Optional[str]
abi=None # type: Optional[str]
Expand All @@ -335,8 +335,8 @@ def get_supported(
"""Return a list of supported tags for each version specified in
`versions`.
:param versions: a list of string versions, of the form ["33", "32"],
or None. The first version will be assumed to support our ABI.
:param versions: a string versions, of the form "33" or "32",
or None. The version will be assumed to support our ABI.
:param platform: specify the exact platform you want valid
tags for, or None. If None, use the local system platform.
:param impl: specify the exact implementation you want valid
Expand All @@ -347,9 +347,11 @@ def get_supported(
supported = []

# Versions must be given with respect to the preference
if versions is None:
if version is None:
version_info = get_impl_version_info()
versions = get_all_minor_versions_as_strings(version_info)
else:
versions = [version]

impl = impl or get_abbr_impl()

Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def test_supported_osx_version(self):
Wheels built for macOS 10.6 are supported on 10.9
"""
tags = pep425tags.get_supported(
['27'], platform='macosx_10_9_intel', impl='cp'
'27', platform='macosx_10_9_intel', impl='cp'
)
w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_6_intel.whl')
assert w.supported(tags=tags)
Expand All @@ -315,7 +315,7 @@ def test_not_supported_osx_version(self):
Wheels built for macOS 10.9 are not supported on 10.6
"""
tags = pep425tags.get_supported(
['27'], platform='macosx_10_6_intel', impl='cp'
'27', platform='macosx_10_6_intel', impl='cp'
)
w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_9_intel.whl')
assert not w.supported(tags=tags)
Expand All @@ -325,22 +325,22 @@ def test_supported_multiarch_darwin(self):
Multi-arch wheels (intel) are supported on components (i386, x86_64)
"""
universal = pep425tags.get_supported(
['27'], platform='macosx_10_5_universal', impl='cp'
'27', platform='macosx_10_5_universal', impl='cp'
)
intel = pep425tags.get_supported(
['27'], platform='macosx_10_5_intel', impl='cp'
'27', platform='macosx_10_5_intel', impl='cp'
)
x64 = pep425tags.get_supported(
['27'], platform='macosx_10_5_x86_64', impl='cp'
'27', platform='macosx_10_5_x86_64', impl='cp'
)
i386 = pep425tags.get_supported(
['27'], platform='macosx_10_5_i386', impl='cp'
'27', platform='macosx_10_5_i386', impl='cp'
)
ppc = pep425tags.get_supported(
['27'], platform='macosx_10_5_ppc', impl='cp'
'27', platform='macosx_10_5_ppc', impl='cp'
)
ppc64 = pep425tags.get_supported(
['27'], platform='macosx_10_5_ppc64', impl='cp'
'27', platform='macosx_10_5_ppc64', impl='cp'
)

w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_intel.whl')
Expand All @@ -363,10 +363,10 @@ def test_not_supported_multiarch_darwin(self):
Single-arch wheels (x86_64) are not supported on multi-arch (intel)
"""
universal = pep425tags.get_supported(
['27'], platform='macosx_10_5_universal', impl='cp'
'27', platform='macosx_10_5_universal', impl='cp'
)
intel = pep425tags.get_supported(
['27'], platform='macosx_10_5_intel', impl='cp'
'27', platform='macosx_10_5_intel', impl='cp'
)

w = wheel.Wheel('simple-0.1-cp27-none-macosx_10_5_i386.whl')
Expand Down

0 comments on commit e99e820

Please sign in to comment.