From 2ddd9523e8ed0b518faa6b779ba51313c73ca071 Mon Sep 17 00:00:00 2001 From: Mathias Burger Date: Thu, 26 Sep 2024 21:47:03 +0200 Subject: [PATCH] Bugfix: support packages that only have manylinux 2 wheels Currently onnxruntime==1.19.2 cannot be analyzed with python-inspector, because get_supported_wheels() is unable to process packages that only have manylinux wheels. E.g. https://pypi.org/project/onnxruntime/#files only contains the file ' onnxruntime-1.19.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl' for the x86_64 architecture. Signed-off-by: Mathias Burger --- src/python_inspector/utils_pypi.py | 2 ++ tests/test_utils_pypi.py | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/python_inspector/utils_pypi.py b/src/python_inspector/utils_pypi.py index 2af5d57f..09b811ed 100644 --- a/src/python_inspector/utils_pypi.py +++ b/src/python_inspector/utils_pypi.py @@ -143,6 +143,8 @@ def get_python_dot_version(version): "manylinux1_x86_64", "manylinux2010_x86_64", "manylinux2014_x86_64", + "manylinux_2_27_x86_64", + "manylinux_2_28_x86_64", ], "macos": [ "macosx_10_6_intel", diff --git a/tests/test_utils_pypi.py b/tests/test_utils_pypi.py index de6d4db9..1932d9c1 100644 --- a/tests/test_utils_pypi.py +++ b/tests/test_utils_pypi.py @@ -13,7 +13,9 @@ import pytest +from python_inspector import utils_pypi from python_inspector.utils_pypi import Distribution +from python_inspector.utils_pypi import PypiPackage from python_inspector.utils_pypi import Sdist from python_inspector.utils_pypi import Wheel @@ -138,6 +140,15 @@ def check(self, using=Distribution): ), ] +linux_platforms = [ + "linux_x86_64", + "manylinux1_x86_64", + "manylinux2010_x86_64", + "manylinux2014_x86_64", + "manylinux_2_27_x86_64", + "manylinux_2_28_x86_64", +] + @pytest.mark.parametrize("dist_test", sdist_tests + wheel_tests) def test_Distribution_from_filename(dist_test): @@ -152,3 +163,14 @@ def test_Sdist_from_filename(dist_test): @pytest.mark.parametrize("dist_test", wheel_tests) def test_Wheel_from_filename(dist_test): dist_test.check(using=Wheel) + + +@pytest.mark.parametrize("linux_platform", linux_platforms) +def test_PypiPackage_get_supported_wheels(linux_platform): + whl = Wheel.from_filename(f"onnxruntime-1.19.2-cp311-cp311-{linux_platform}.whl") + pkg = PypiPackage.package_from_dists(dists=[whl]) + env = utils_pypi.Environment.from_pyver_and_os(python_version="311", operating_system="linux") + + supported_wheels = list(pkg.get_supported_wheels(environment=env)) + + assert supported_wheels == [whl]