From d6c47108b6585b25edde41d9044168f2d4dc4e49 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 5 Aug 2026 21:26:47 +1000 Subject: [PATCH] chore(ci): skip generic linux_ tags Python has introduced generic `linux_` tags which are independent of the libc implementation. We need to know whether we are building against glibc or musl, so we have to skip these `linux_` tags. Signed-off-by: JP-Ellis --- pact-python-cli/hatch_build.py | 16 +++++++++++++++- pact-python-ffi/hatch_build.py | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/pact-python-cli/hatch_build.py b/pact-python-cli/hatch_build.py index eefc646ff..3128b17be 100644 --- a/pact-python-cli/hatch_build.py +++ b/pact-python-cli/hatch_build.py @@ -149,8 +149,22 @@ def _sys_tag_platform(self) -> str: Get the platform tag from the current system tags. This is used to determine the target platform for the Pact binaries. + + On Linux, the generic `linux_{arch}` tag conveys no information about + the platform's C library, so the more specific `manylinux`/`musllinux` + tag is preferred when one is available. + + Returns: + The most specific platform tag supported by the current system. """ - return next(t.platform for t in sys_tags()) + platforms = (t.platform for t in sys_tags()) + preferred = next(platforms) + if preferred.startswith("linux_"): + return next( + (p for p in platforms if not p.startswith("linux_")), + preferred, + ) + return preferred def _install_ruby_cli(self, version: str) -> Mapping[str, str]: """ diff --git a/pact-python-ffi/hatch_build.py b/pact-python-ffi/hatch_build.py index 80d0e7bc6..cee63c269 100644 --- a/pact-python-ffi/hatch_build.py +++ b/pact-python-ffi/hatch_build.py @@ -135,8 +135,22 @@ def _sys_tag_platform(self) -> str: Get the platform tag from the current system tags. This is used to determine the target platform for the Pact library. + + On Linux, the generic `linux_{arch}` tag conveys no information about + the platform's C library, so the more specific `manylinux`/`musllinux` + tag is preferred when one is available. + + Returns: + The most specific platform tag supported by the current system. """ - return next(t.platform for t in sys_tags()) + platforms = (t.platform for t in sys_tags()) + preferred = next(platforms) + if preferred.startswith("linux_"): + return next( + (p for p in platforms if not p.startswith("linux_")), + preferred, + ) + return preferred def _install(self, version: str) -> Mapping[str, str]: """