From e99e82030e67254add8465074508608ceef1b3ba Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Mon, 11 Nov 2019 21:10:05 -0500 Subject: [PATCH] Make versions argument singular for pep425tags.get_supported() This simplifies the interface of this function in preparation for switching to packaging.tags. --- src/pip/_internal/models/target_python.py | 6 +++--- src/pip/_internal/pep425tags.py | 10 ++++++---- tests/unit/test_wheel.py | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/pip/_internal/models/target_python.py b/src/pip/_internal/models/target_python.py index a23b79c4e4e..cd08c917899 100644 --- a/src/pip/_internal/models/target_python.py +++ b/src/pip/_internal/models/target_python.py @@ -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, diff --git a/src/pip/_internal/pep425tags.py b/src/pip/_internal/pep425tags.py index c9425cdf823..515f515e845 100644 --- a/src/pip/_internal/pep425tags.py +++ b/src/pip/_internal/pep425tags.py @@ -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] @@ -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 @@ -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() diff --git a/tests/unit/test_wheel.py b/tests/unit/test_wheel.py index 0df9bd8351d..0eccac90567 100644 --- a/tests/unit/test_wheel.py +++ b/tests/unit/test_wheel.py @@ -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) @@ -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) @@ -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') @@ -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')