From 7c0f9eac274e833e5e23f0eac6173bffdc1385ec Mon Sep 17 00:00:00 2001 From: Frost Ming Date: Wed, 3 Jul 2024 18:19:24 +0800 Subject: [PATCH] fix: macos platform tags Signed-off-by: Frost Ming --- src/dep_logic/tags/platform.py | 5 ++++- src/dep_logic/tags/tags.py | 2 +- tests/tags/test_tags.py | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/dep_logic/tags/platform.py b/src/dep_logic/tags/platform.py index a0dee42..51e5a10 100644 --- a/src/dep_logic/tags/platform.py +++ b/src/dep_logic/tags/platform.py @@ -313,7 +313,10 @@ def get_minimum_manylinux_minor(self) -> int | None: return None def get_mac_binary_formats(self) -> list[str]: - formats = [self.value] + if self == Arch.Aarch64: + formats = ["arm64"] + else: + formats = [self.value] if self == Arch.X86_64: formats.extend(["intel", "fat64", "fat32"]) diff --git a/src/dep_logic/tags/tags.py b/src/dep_logic/tags/tags.py index 37228d3..fd3f417 100644 --- a/src/dep_logic/tags/tags.py +++ b/src/dep_logic/tags/tags.py @@ -103,7 +103,7 @@ def from_spec( cls, requires_python: str, platform: str, - implementation: str, + implementation: str = "cpython", gil_disabled: bool = False, ) -> Self: return cls( diff --git a/tests/tags/test_tags.py b/tests/tags/test_tags.py index 60cfd7f..402f48f 100644 --- a/tests/tags/test_tags.py +++ b/tests/tags/test_tags.py @@ -5,6 +5,7 @@ def test_check_wheel_tags(): wheels = [ "protobuf-5.27.2-cp310-abi3-win32.whl", "protobuf-5.27.2-cp310-abi3-win_amd64.whl", + "protobuf-5.27.2-cp310-cp310-macosx_12_0_arm64.whl", "protobuf-5.27.2-cp38-abi3-macosx_10_9_universal2.whl", "protobuf-5.27.2-cp38-abi3-manylinux2014_aarch64.whl", "protobuf-5.27.2-cp38-abi3-manylinux2014_x86_64.whl", @@ -39,3 +40,16 @@ def test_check_wheel_tags(): "protobuf-5.27.2-cp39-cp39-win_amd64.whl", "protobuf-5.27.2-py3-none-any.whl", ] + + macos_env = EnvSpec.from_spec(">=3.9", "macos", "cpython") + wheel_compats = { + f: c + for f, c in {f: macos_env.wheel_compatibility(f) for f in wheels}.items() + if c is not None + } + filtered_wheels = sorted(wheel_compats, key=wheel_compats.__getitem__, reverse=True) + assert filtered_wheels == [ + "protobuf-5.27.2-cp310-cp310-macosx_12_0_arm64.whl", + "protobuf-5.27.2-cp38-abi3-macosx_10_9_universal2.whl", + "protobuf-5.27.2-py3-none-any.whl", + ]