Skip to content

Commit d2ccd88

Browse files
authored
fix: evaluate free threaded wheel tags (#5)
Signed-off-by: Frost Ming <[email protected]>
1 parent d9ae6c9 commit d2ccd88

File tree

4 files changed

+39
-6
lines changed

4 files changed

+39
-6
lines changed

src/dep_logic/tags/platform.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def parse(cls, platform: str) -> Self:
3535
Available operating systems:
3636
- `linux`: an alias for `manylinux_2_17_x86_64`
3737
- `windows`: an alias for `win_amd64`
38-
- `macos`: an alias for `macos_12_0_arm64`
38+
- `macos`: an alias for `macos_14_0_arm64`
3939
- `alpine`: an alias for `musllinux_1_2_x86_64`
4040
- `windows_amd64`
4141
- `windows_x86`
@@ -54,7 +54,7 @@ def parse(cls, platform: str) -> Self:
5454
elif platform == "windows":
5555
return cls(os.Windows(), Arch.X86_64)
5656
elif platform == "macos":
57-
return cls(os.Macos(12, 0), Arch.Aarch64)
57+
return cls(os.Macos(14, 0), Arch.Aarch64)
5858
elif platform == "alpine":
5959
return cls(os.Musllinux(1, 2), Arch.X86_64)
6060
elif platform.startswith("windows_"):

src/dep_logic/tags/tags.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,16 @@ def _evaluate_python(
167167
.replace("pyston", "pt")
168168
.lower()
169169
)
170+
allow_abi3 = impl == "cp" and (
171+
self.implementation is None or not self.implementation.gil_disabled
172+
)
173+
free_threaded: bool | None = None
174+
if self.implementation is not None:
175+
free_threaded = self.implementation.gil_disabled
170176
try:
171-
if impl == "cp" and abi_impl == "abi3":
177+
if abi_impl == "abi3":
178+
if not allow_abi3:
179+
return None
172180
if (
173181
parse_version_specifier(f">={major}.{minor or 0}")
174182
& self.requires_python
@@ -178,8 +186,14 @@ def _evaluate_python(
178186
# cp36-cp36m-*
179187
# cp312-cp312m-*
180188
# pp310-pypy310_pp75-*
181-
if abi_impl != "none" and not abi_impl.startswith(python_tag.lower()):
182-
return None
189+
if abi_impl != "none":
190+
if not abi_impl.startswith(python_tag.lower()):
191+
return None
192+
if (
193+
free_threaded is not None
194+
and abi_impl.endswith("t") is not free_threaded
195+
):
196+
return None
183197
if major and minor:
184198
wheel_range = parse_version_specifier(f"=={major}.{minor}.*")
185199
else:

tests/tags/test_platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def test_platform_tags_musl():
322322
"text,expected,normalized",
323323
[
324324
("linux", Platform(os.Manylinux(2, 17), Arch.X86_64), "manylinux_2_17_x86_64"),
325-
("macos", Platform(os.Macos(12, 0), Arch.Aarch64), "macos_12_0_arm64"),
325+
("macos", Platform(os.Macos(14, 0), Arch.Aarch64), "macos_14_0_arm64"),
326326
("windows", Platform(os.Windows(), Arch.X86_64), "windows_amd64"),
327327
("alpine", Platform(os.Musllinux(1, 2), Arch.X86_64), "musllinux_1_2_x86_64"),
328328
(

tests/tags/test_tags.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
def test_check_wheel_tags():
88
wheels = [
9+
"protobuf-5.27.2-cp313-cp313t-macosx_14_0_arm64.whl",
10+
"protobuf-5.27.2-cp313-cp313-macosx_14_0_arm64.whl",
911
"protobuf-5.27.2-cp310-abi3-win32.whl",
1012
"protobuf-5.27.2-cp310-abi3-win_amd64.whl",
1113
"protobuf-5.27.2-cp310-cp310-macosx_12_0_arm64.whl",
@@ -52,11 +54,26 @@ def test_check_wheel_tags():
5254
}
5355
filtered_wheels = sorted(wheel_compats, key=wheel_compats.__getitem__, reverse=True)
5456
assert filtered_wheels == [
57+
"protobuf-5.27.2-cp313-cp313-macosx_14_0_arm64.whl",
5558
"protobuf-5.27.2-cp310-cp310-macosx_12_0_arm64.whl",
5659
"protobuf-5.27.2-cp38-abi3-macosx_10_9_universal2.whl",
5760
"protobuf-5.27.2-py3-none-any.whl",
5861
]
5962

63+
macos_free_threaded_env = EnvSpec.from_spec(">=3.9", "macos", "cpython", True)
64+
wheel_compats = {
65+
f: c
66+
for f, c in {
67+
f: macos_free_threaded_env.wheel_compatibility(f) for f in wheels
68+
}.items()
69+
if c is not None
70+
}
71+
filtered_wheels = sorted(wheel_compats, key=wheel_compats.__getitem__, reverse=True)
72+
assert filtered_wheels == [
73+
"protobuf-5.27.2-cp313-cp313t-macosx_14_0_arm64.whl",
74+
"protobuf-5.27.2-py3-none-any.whl",
75+
]
76+
6077
python_env = EnvSpec.from_spec(">=3.9")
6178
wheel_compats = {
6279
f: c
@@ -65,6 +82,8 @@ def test_check_wheel_tags():
6582
}
6683
filtered_wheels = sorted(wheel_compats, key=wheel_compats.__getitem__, reverse=True)
6784
assert filtered_wheels == [
85+
"protobuf-5.27.2-cp313-cp313t-macosx_14_0_arm64.whl",
86+
"protobuf-5.27.2-cp313-cp313-macosx_14_0_arm64.whl",
6887
"protobuf-5.27.2-cp310-cp310-macosx_12_0_arm64.whl",
6988
"protobuf-5.27.2-cp310-abi3-win32.whl",
7089
"protobuf-5.27.2-cp310-abi3-win_amd64.whl",

0 commit comments

Comments
 (0)