Skip to content

Commit 47c4823

Browse files
committed
Fix wheel compatibility check logic
1 parent be08cfd commit 47c4823

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

micropip/_utils.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,28 @@ def platform_to_version(platform: str) -> str:
190190
for tag in tags:
191191
if tag.abi in abis:
192192
abi_incompatible = False
193-
break
193+
break
194194
if abi_incompatible:
195195
abis_string = ",".join({tag.abi for tag in tags})
196196
raise ValueError(
197197
f"Wheel abi '{abis_string}' is not supported. Supported abis are 'abi3' and 'cp{version}'."
198198
)
199+
200+
# Check interpreter compatibility
201+
current_version = int(version)
202+
for tag in tags:
203+
try:
204+
wheel_version = int(tag.interpreter.removeprefix("cp"))
205+
# abi3: forward compatible (wheel_version <= current_version)
206+
# non-abi3: exact match required (wheel_version == current_version)
207+
if (tag.abi == "abi3" and wheel_version <= current_version) or \
208+
(tag.abi != "abi3" and wheel_version == current_version):
209+
return
210+
except ValueError:
211+
continue
199212

200-
raise ValueError(f"Wheel interpreter version '{tag.interpreter}' is not supported.")
213+
interpreters_string = ",".join({tag.interpreter for tag in tags})
214+
raise ValueError(f"Wheel interpreter version '{interpreters_string}' is not supported.")
201215

202216

203217
def validate_constraints(

0 commit comments

Comments
 (0)