Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32-bit Linux running on 64-bit ARM arch should have platform "linux_armv7l" #234

Merged
merged 15 commits into from
Feb 6, 2020
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
*unreleased*
~~~~~~~~~~~~

No changes yet.
* Fix a bug that caused a 32-bit OS that runs on a 64-bit ARM CPU (e.g. ARM-v8,
aarch64), to report the wrong bitness.

20.1 - 2020-01-24
~~~~~~~~~~~~~~~~~~~
Expand Down
7 changes: 5 additions & 2 deletions packaging/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,11 @@ def _have_compatible_manylinux_abi(arch):
def _linux_platforms(is_32bit=_32_BIT_INTERPRETER):
# type: (bool) -> Iterator[str]
linux = _normalize_string(distutils.util.get_platform())
if linux == "linux_x86_64" and is_32bit:
linux = "linux_i686"
if is_32bit:
if linux == "linux_x86_64":
linux = "linux_i686"
elif linux == "linux_aarch64":
brettcannon marked this conversation as resolved.
Show resolved Hide resolved
linux = "linux_armv7l"
manylinux_support = []
_, arch = linux.split("_", 1)
if _have_compatible_manylinux_abi(arch):
Expand Down
34 changes: 16 additions & 18 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ def is_x86():
return re.match(r"(i\d86|x86_64)", platform.machine()) is not None


@pytest.fixture
def is_64bit_os():
return platform.architecture()[0] == "64bit"


@pytest.fixture
def manylinux_module(monkeypatch):
monkeypatch.setattr(tags, "_have_compatible_glibc", lambda *args: False)
Expand Down Expand Up @@ -415,19 +410,22 @@ def test_glibc_version_string_none(self, monkeypatch):
monkeypatch.setattr(tags, "_glibc_version_string", lambda: None)
assert not tags._have_compatible_glibc(2, 4)

def test_linux_platforms_64bit_on_64bit_os(self, is_64bit_os, is_x86, monkeypatch):
if platform.system() != "Linux" or not is_64bit_os or not is_x86:
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = list(tags._linux_platforms(is_32bit=False))[-1]
assert linux_platform == "linux_x86_64"

def test_linux_platforms_32bit_on_64bit_os(self, is_64bit_os, is_x86, monkeypatch):
if platform.system() != "Linux" or not is_64bit_os or not is_x86:
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = list(tags._linux_platforms(is_32bit=True))[-1]
assert linux_platform == "linux_i686"
@pytest.mark.parametrize(
"arch,is_32bit,expected",
[
("linux-x86_64", False, "linux_x86_64"),
("linux-x86_64", True, "linux_i686"),
("linux-aarch64", False, "linux_aarch64"),
("linux-aarch64", True, "linux_armv7l"),
],
)
def test_linux_platforms_32_64bit_on_64bit_os(
self, arch, is_32bit, expected, monkeypatch
):
monkeypatch.setattr(distutils.util, "get_platform", lambda: arch)
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = list(tags._linux_platforms(is_32bit=is_32bit))[-1]
assert linux_platform == expected

def test_linux_platforms_manylinux_unsupported(self, monkeypatch):
monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
Expand Down