diff --git a/micropip/_utils.py b/micropip/_utils.py index 9abab9d..ea1de85 100644 --- a/micropip/_utils.py +++ b/micropip/_utils.py @@ -190,14 +190,31 @@ 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}'." ) - raise ValueError(f"Wheel interpreter version '{tag.interpreter}' is not supported.") + # 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 + + interpreters_string = ",".join({tag.interpreter for tag in tags}) + raise ValueError( + f"Wheel interpreter version '{interpreters_string}' is not supported." + ) def validate_constraints(