From 47c4823d52f9dfdaa05b17759dd479b60bc30439 Mon Sep 17 00:00:00 2001 From: Jeongwon Kim Date: Wed, 13 Aug 2025 18:33:49 +0900 Subject: [PATCH 1/2] Fix wheel compatibility check logic --- micropip/_utils.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/micropip/_utils.py b/micropip/_utils.py index 9abab9da..d64c437e 100644 --- a/micropip/_utils.py +++ b/micropip/_utils.py @@ -190,14 +190,28 @@ def platform_to_version(platform: str) -> str: for tag in tags: if tag.abi in abis: abi_incompatible = False - break + break if abi_incompatible: abis_string = ",".join({tag.abi for tag in tags}) raise ValueError( f"Wheel abi '{abis_string}' is not supported. Supported abis are 'abi3' and 'cp{version}'." ) + + # Check interpreter compatibility + current_version = int(version) + for tag in tags: + try: + wheel_version = int(tag.interpreter.removeprefix("cp")) + # abi3: forward compatible (wheel_version <= current_version) + # non-abi3: exact match required (wheel_version == current_version) + if (tag.abi == "abi3" and wheel_version <= current_version) or \ + (tag.abi != "abi3" and wheel_version == current_version): + return + except ValueError: + continue - raise ValueError(f"Wheel interpreter version '{tag.interpreter}' is not supported.") + interpreters_string = ",".join({tag.interpreter for tag in tags}) + raise ValueError(f"Wheel interpreter version '{interpreters_string}' is not supported.") def validate_constraints( From 529d15f3f1c6c4b015af089eca4fa7ee36d96f0a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 14 Aug 2025 06:40:06 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- micropip/_utils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/micropip/_utils.py b/micropip/_utils.py index d64c437e..ea1de855 100644 --- a/micropip/_utils.py +++ b/micropip/_utils.py @@ -196,7 +196,7 @@ def platform_to_version(platform: str) -> str: raise ValueError( f"Wheel abi '{abis_string}' is not supported. Supported abis are 'abi3' and 'cp{version}'." ) - + # Check interpreter compatibility current_version = int(version) for tag in tags: @@ -204,14 +204,17 @@ def platform_to_version(platform: str) -> str: wheel_version = int(tag.interpreter.removeprefix("cp")) # abi3: forward compatible (wheel_version <= current_version) # non-abi3: exact match required (wheel_version == current_version) - if (tag.abi == "abi3" and wheel_version <= current_version) or \ - (tag.abi != "abi3" and wheel_version == current_version): + if (tag.abi == "abi3" and wheel_version <= current_version) or ( + tag.abi != "abi3" and wheel_version == current_version + ): return except ValueError: continue interpreters_string = ",".join({tag.interpreter for tag in tags}) - raise ValueError(f"Wheel interpreter version '{interpreters_string}' is not supported.") + raise ValueError( + f"Wheel interpreter version '{interpreters_string}' is not supported." + ) def validate_constraints(