Skip to content

Commit 565bd4a

Browse files
committed
TST: reconcile platform tags with recent packaging on macOS
1 parent d0a8bd4 commit 565bd4a

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

tests/conftest.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import os
55
import os.path
66
import pathlib
7+
import platform
78
import re
89
import shutil
910
import subprocess
@@ -19,13 +20,24 @@
1920

2021

2122
def adjust_packaging_platform_tag(platform: str) -> str:
22-
# The packaging module generates overly specific platforms tags on
23-
# Linux. The platforms tags on Linux evolved over time.
24-
# meson-python uses more relaxed platform tags to maintain
25-
# compatibility with old wheel installation tools. The relaxed
26-
# platform tags match the ones generated by the wheel package.
27-
# https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/
28-
return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform)
23+
if platform.startswith(('manylinux', 'musllinux')):
24+
# The packaging module generates overly specific platforms tags on
25+
# Linux. The platforms tags on Linux evolved over time.
26+
# meson-python uses more relaxed platform tags to maintain
27+
# compatibility with old wheel installation tools. The relaxed
28+
# platform tags match the ones generated by the wheel package.
29+
# https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/
30+
return re.sub(r'^(many|musl)linux(1|2010|2014|_\d+_\d+)_(.*)$', r'linux_\3', platform)
31+
if platform.startwith('macosx'):
32+
# Python built with older macOS SDK on macOS 11, reports an
33+
# unexising macOS 10.16 version instead of the real version.
34+
# The packaging module introduced a workaround in version
35+
# 22.0. Too maintain compatibility with older packaging
36+
# releases we don't implement it. Reconcile this.
37+
version = tuple(map(int, platform.mac_ver()[0].split('.'))[:2])
38+
if version == (10, 16):
39+
return re.sub(r'^macosx_\d+_\d+_(.*)$', r'macosx_10_16_\1', platform)
40+
return platform
2941

3042

3143
package_dir = pathlib.Path(__file__).parent / 'packages'

0 commit comments

Comments
 (0)