From 2492108565c01726504f2af048f3406a87770d3a Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:08:46 -0800 Subject: [PATCH 1/3] filter packages for compatibility. pypy3 is going to be an issue here. need to handle that differently most likely --- eng/tox/install_depend_packages.py | 2 +- scripts/devops_tasks/common_tasks.py | 1 + tools/azure-sdk-tools/pypi_tools/pypi.py | 23 ++++++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/eng/tox/install_depend_packages.py b/eng/tox/install_depend_packages.py index 7138482cf0e3..9692fd54846d 100644 --- a/eng/tox/install_depend_packages.py +++ b/eng/tox/install_depend_packages.py @@ -84,7 +84,7 @@ def process_requirement(req, dependency_type): # get available versions on PyPI client = PyPIClient() - versions = [str(v) for v in client.get_ordered_versions(pkg_name)] + versions = [str(v) for v in client.get_ordered_versions(pkg_name, True)] logging.info("Versions available on PyPI for %s: %s", pkg_name, versions) if pkg_name in MINIMUM_VERSION_SUPPORTED_OVERRIDE: diff --git a/scripts/devops_tasks/common_tasks.py b/scripts/devops_tasks/common_tasks.py index 8333cd093205..bad1fa5f528c 100644 --- a/scripts/devops_tasks/common_tasks.py +++ b/scripts/devops_tasks/common_tasks.py @@ -42,6 +42,7 @@ "azure", "azure-mgmt", "azure-storage", + "azure-mgmt-regionmove" ] MANAGEMENT_PACKAGE_IDENTIFIERS = [ "mgmt", diff --git a/tools/azure-sdk-tools/pypi_tools/pypi.py b/tools/azure-sdk-tools/pypi_tools/pypi.py index 9eb28db8c0fe..42259cc2d179 100644 --- a/tools/azure-sdk-tools/pypi_tools/pypi.py +++ b/tools/azure-sdk-tools/pypi_tools/pypi.py @@ -34,14 +34,35 @@ def project_release(self, package_name, version): response.raise_for_status() return response.json() - def get_ordered_versions(self, package_name): + def filter_packages_for_compatibility(self, package_name, version_set): + # only need the packaging.specifiers import if we're actually executing this filter. + from packaging.specifiers import SpecifierSet + + results = [] + + for version in version_set: + requires_python = self.project_release(package_name, version)["info"]["requires_python"] + if requires_python: + if parse('.'.join(map(str, sys.version_info[:3]))) in SpecifierSet(requires_python): + results.append(version) + else: + results.append(version) + + return results + + def get_ordered_versions(self, package_name, filter_by_compatibility = False): project = self.project(package_name) + versions = [ Version(package_version) for package_version in project["releases"].keys() ] versions.sort() + + if filter_by_compatibility: + return self.filter_packages_for_compatibility(package_name, versions) + return versions def get_relevant_versions(self, package_name): From 4665108f6d14a18b39ff0aab85b7418ef2b4b1b7 Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:27:27 -0800 Subject: [PATCH 2/3] address dumb typo. using an old name instead of Version --- tools/azure-sdk-tools/pypi_tools/pypi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/azure-sdk-tools/pypi_tools/pypi.py b/tools/azure-sdk-tools/pypi_tools/pypi.py index 42259cc2d179..cffbfa9639db 100644 --- a/tools/azure-sdk-tools/pypi_tools/pypi.py +++ b/tools/azure-sdk-tools/pypi_tools/pypi.py @@ -43,7 +43,7 @@ def filter_packages_for_compatibility(self, package_name, version_set): for version in version_set: requires_python = self.project_release(package_name, version)["info"]["requires_python"] if requires_python: - if parse('.'.join(map(str, sys.version_info[:3]))) in SpecifierSet(requires_python): + if Version('.'.join(map(str, sys.version_info[:3]))) in SpecifierSet(requires_python): results.append(version) else: results.append(version) From 6ca90270a1e8b019c8a8d6c08507103ca2340a4a Mon Sep 17 00:00:00 2001 From: scbedd <45376673+scbedd@users.noreply.github.com> Date: Wed, 3 Feb 2021 15:57:11 -0800 Subject: [PATCH 3/3] sys needs to be imported. why didn't this pop locally? --- tools/azure-sdk-tools/pypi_tools/pypi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/azure-sdk-tools/pypi_tools/pypi.py b/tools/azure-sdk-tools/pypi_tools/pypi.py index cffbfa9639db..59ab517167a7 100644 --- a/tools/azure-sdk-tools/pypi_tools/pypi.py +++ b/tools/azure-sdk-tools/pypi_tools/pypi.py @@ -1,4 +1,5 @@ from packaging.version import parse as Version +import sys import requests