Skip to content

Commit 2066902

Browse files
committed
Ability to install armv7l manylinux/musllinux wheels on armv8l
aarch64 systems running under linux32 emulation will report an armv8l machine rather than armv7l. This shall not prevent packaging to report musllinux/manylinux armv7l compatibiility as long as the running python has a compatible ABI.
1 parent 63f4cfe commit 2066902

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

src/packaging/_manylinux.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ def _is_compatible(name: str, arch: str, version: _GLibCVersion) -> bool:
204204

205205

206206
def platform_tags(linux: str, arch: str) -> Iterator[str]:
207+
if arch == "armv8l":
208+
# armv8l wheels are not accepted on PyPI
209+
# As long as we pass the the ABI check below,
210+
# the armv7l wheels can be installed.
211+
arch = "armv7l"
207212
if not _have_compatible_abi(sys.executable, arch):
208213
return
209214
# Oldest glibc to be supported regardless of architecture is (2, 17).
@@ -232,9 +237,9 @@ def platform_tags(linux: str, arch: str) -> Iterator[str]:
232237
glibc_version = _GLibCVersion(glibc_max.major, glibc_minor)
233238
tag = "manylinux_{}_{}".format(*glibc_version)
234239
if _is_compatible(tag, arch, glibc_version):
235-
yield linux.replace("linux", tag)
240+
yield f"{tag}_{arch}"
236241
# Handle the legacy manylinux1, manylinux2010, manylinux2014 tags.
237242
if glibc_version in _LEGACY_MANYLINUX_MAP:
238243
legacy_tag = _LEGACY_MANYLINUX_MAP[glibc_version]
239244
if _is_compatible(legacy_tag, arch, glibc_version):
240-
yield linux.replace("linux", legacy_tag)
245+
yield f"{legacy_tag}_{arch}"

src/packaging/_musllinux.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ def platform_tags(arch: str) -> Iterator[str]:
6363
sys_musl = _get_musl_version(sys.executable)
6464
if sys_musl is None: # Python not dynamically linked against musl.
6565
return
66+
if arch == "armv8l":
67+
# armv8l wheels are not accepted on PyPI
68+
# The armv7l wheels can be installed.
69+
arch = "armv7l"
6670
for minor in range(sys_musl.minor, -1, -1):
6771
yield f"musllinux_{sys_musl.major}_{minor}_{arch}"
6872

src/packaging/tags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def _linux_platforms(is_32bit: bool = _32_BIT_INTERPRETER) -> Iterator[str]:
473473
if linux == "linux_x86_64":
474474
linux = "linux_i686"
475475
elif linux == "linux_aarch64":
476-
linux = "linux_armv7l"
476+
linux = "linux_armv8l"
477477
_, arch = linux.split("_", 1)
478478
yield from _manylinux.platform_tags(linux, arch)
479479
yield from _musllinux.platform_tags(arch)

tests/test_tags.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ def test_get_config_var_does_log(self, monkeypatch):
362362
("linux-x86_64", False, "linux_x86_64"),
363363
("linux-x86_64", True, "linux_i686"),
364364
("linux-aarch64", False, "linux_aarch64"),
365-
("linux-aarch64", True, "linux_armv7l"),
365+
("linux-aarch64", True, "linux_armv8l"),
366366
],
367367
)
368368
def test_linux_platforms_32_64bit_on_64bit_os(
@@ -440,14 +440,20 @@ def test_linux_platforms_manylinux2014(self, monkeypatch):
440440
]
441441
assert platforms == expected
442442

443-
def test_linux_platforms_manylinux2014_armhf_abi(self, monkeypatch):
443+
@pytest.mark.parametrize(
444+
"native_arch, cross_arch",
445+
[("armv7l", "armv7l"), ("armv8l", "armv8l"), ("aarch64", "armv8l")],
446+
)
447+
def test_linux_platforms_manylinux2014_armhf_abi(
448+
self, native_arch, cross_arch, monkeypatch
449+
):
444450
monkeypatch.setattr(tags._manylinux, "_glibc_version_string", lambda: "2.30")
445451
monkeypatch.setattr(
446452
tags._manylinux,
447453
"_is_compatible",
448454
lambda name, *args: name == "manylinux2014",
449455
)
450-
monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_armv7l")
456+
monkeypatch.setattr(sysconfig, "get_platform", lambda: f"linux_{native_arch}")
451457
monkeypatch.setattr(
452458
sys,
453459
"executable",
@@ -458,7 +464,7 @@ def test_linux_platforms_manylinux2014_armhf_abi(self, monkeypatch):
458464
),
459465
)
460466
platforms = list(tags._linux_platforms(is_32bit=True))
461-
expected = ["manylinux2014_armv7l", "linux_armv7l"]
467+
expected = ["manylinux2014_armv7l", f"linux_{cross_arch}"]
462468
assert platforms == expected
463469

464470
def test_linux_platforms_manylinux2014_i386_abi(self, monkeypatch):
@@ -520,7 +526,8 @@ def test_linux_platforms_manylinux_glibc3(self, monkeypatch):
520526
@pytest.mark.parametrize(
521527
"native_arch, cross32_arch, musl_version",
522528
[
523-
("aarch64", "armv7l", _MuslVersion(1, 1)),
529+
("armv7l", "armv7l", _MuslVersion(1, 1)),
530+
("aarch64", "armv8l", _MuslVersion(1, 1)),
524531
("i386", "i386", _MuslVersion(1, 2)),
525532
("x86_64", "i686", _MuslVersion(1, 2)),
526533
],
@@ -543,8 +550,9 @@ def test_linux_platforms_musllinux(
543550

544551
platforms = list(tags._linux_platforms(is_32bit=cross32))
545552
target_arch = cross32_arch if cross32 else native_arch
553+
target_arch_musl = "armv7l" if target_arch == "armv8l" else target_arch
546554
expected = [
547-
f"musllinux_{musl_version[0]}_{minor}_{target_arch}"
555+
f"musllinux_{musl_version[0]}_{minor}_{target_arch_musl}"
548556
for minor in range(musl_version[1], -1, -1)
549557
] + [f"linux_{target_arch}"]
550558
assert platforms == expected

0 commit comments

Comments
 (0)