From 5142149518eb87c02f90f19e7ba91b08bd72bdf2 Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Fri, 9 Dec 2022 10:54:41 +0100 Subject: [PATCH] TST: reconcile platform tags with recent packaging on macOS --- tests/conftest.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 5d0b18080..90500dca1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -19,13 +19,25 @@ def adjust_packaging_platform_tag(platform: str) -> str: - # The packaging module generates overly specific platforms tags on - # Linux. The platforms tags on Linux evolved over time. - # meson-python uses more relaxed platform tags to maintain - # compatibility with old wheel installation tools. The relaxed - # platform tags match the ones generated by the wheel package. - # https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/ - return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform) + if platform.startswith(('manylinux', 'musllinux')): + # The packaging module generates overly specific platforms tags on + # Linux. The platforms tags on Linux evolved over time. + # meson-python uses more relaxed platform tags to maintain + # compatibility with old wheel installation tools. The relaxed + # platform tags match the ones generated by the wheel package. + # https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/ + return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform) + if platform.startswith('macosx'): + # Python built with older macOS SDK on macOS 11, reports an + # unexising macOS 10.16 version instead of the real version. + # The packaging module introduced a workaround in version + # 22.0. Too maintain compatibility with older packaging + # releases we don't implement it. Reconcile this. + from platform import mac_ver + version = tuple(map(int, mac_ver()[0].split('.')))[:2] + if version == (10, 16): + return re.sub(r'^macosx_\d+_\d+_(.*)$', r'macosx_10_16_\1', platform) + return platform package_dir = pathlib.Path(__file__).parent / 'packages'