Skip to content

Commit bda1bb6

Browse files
dnicolodirgommers
authored andcommitted
BUG: use 11.0 as minimum macOS platform ABI tag on arm64
Fixes #524.
1 parent 778e2f9 commit bda1bb6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

mesonpy/_tags.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ def _get_macosx_platform_tag() -> str:
129129
# can therefore ignore the issue and generate the slightly
130130
# incorrect tag.
131131

132+
# The minimum macOS ABI version on arm64 is 11.0. The macOS SDK
133+
# on arm64 silently bumps any compatibility version specified via
134+
# the MACOSX_DEPLOYMENT_TARGET environment variable to 11.0.
135+
# Despite the platform ABI tag being intended to be a minimum
136+
# compatibility version, pip refuses to install wheels with a
137+
# platform tag specifying an ABI version lower than 11.0. Use
138+
# 11.0 as minimum ABI version on arm64.
139+
if arch == 'arm64' and version < (11, 0):
140+
version = (11, 0)
141+
132142
major, minor = version
133143

134144
if major >= 11:

tests/test_tags.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import importlib.machinery
66
import os
77
import pathlib
8+
import platform
89
import sys
910
import sysconfig
1011

@@ -47,13 +48,24 @@ def test_wheel_tag():
4748
def test_macos_platform_tag(monkeypatch):
4849
for minor in range(9, 16):
4950
monkeypatch.setenv('MACOSX_DEPLOYMENT_TARGET', f'10.{minor}')
50-
assert next(packaging.tags.mac_platforms((10, minor))) == mesonpy._tags.get_platform_tag()
51+
version = (10, minor) if platform.mac_ver()[2] != 'arm64' else (11, 0)
52+
assert next(packaging.tags.mac_platforms(version)) == mesonpy._tags.get_platform_tag()
5153
for major in range(11, 20):
5254
for minor in range(3):
5355
monkeypatch.setenv('MACOSX_DEPLOYMENT_TARGET', f'{major}.{minor}')
5456
assert next(packaging.tags.mac_platforms((major, minor))) == mesonpy._tags.get_platform_tag()
5557

5658

59+
@pytest.mark.skipif(sys.platform != 'darwin', reason='macOS specific test')
60+
def test_macos_platform_tag_arm64(monkeypatch):
61+
monkeypatch.setenv('_PYTHON_HOST_PLATFORM', 'macosx-12.0-arm64')
62+
# Verify that the minimum platform ABI version on arm64 is 11.0.
63+
monkeypatch.setenv('MACOSX_DEPLOYMENT_TARGET', '10.12')
64+
assert mesonpy._tags.get_platform_tag() == 'macosx_11_0_arm64'
65+
monkeypatch.setenv('MACOSX_DEPLOYMENT_TARGET', '12.34')
66+
assert mesonpy._tags.get_platform_tag() == 'macosx_12_0_arm64'
67+
68+
5769
@pytest.mark.skipif(sys.platform != 'darwin', reason='macOS specific test')
5870
def test_python_host_platform(monkeypatch):
5971
monkeypatch.setenv('_PYTHON_HOST_PLATFORM', 'macosx-12.0-arm64')

0 commit comments

Comments
 (0)