3
0
python-packaging/0002-Fix-check-for-64-bit-OS.patch

71 lines
2.6 KiB
Diff

From 73c4a178654cf0ffe64d2f10155f7d7978f3622d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20=C4=8Cerm=C3=A1k?= <dcermak@suse.com>
Date: Thu, 8 Aug 2019 15:44:09 +0200
Subject: [PATCH 2/5] Fix check for 64 bit OS
distutils.util.get_platform() returns "linux-x86_64" on 64 bit Linux and not
"linux_86_64" as assumed by this function. Instead we use the first element
returned by platform.architecture() and move the check into a separate fixture.
Furthermore, we have to check whether the current OS is x86-based, as the
results don't match otherwise.
---
tests/test_tags.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/tests/test_tags.py b/tests/test_tags.py
index 1f1441e..9ec30a4 100644
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -11,6 +11,7 @@ except ImportError:
import distutils.util
import platform
+import re
import sys
import sysconfig
import types
@@ -26,6 +27,16 @@ def example_tag():
return tags.Tag("py3", "none", "any")
+@pytest.fixture
+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"
+
+
def test_tag_lowercasing():
tag = tags.Tag("PY3", "None", "ANY")
assert tag.interpreter == "py3"
@@ -486,18 +497,16 @@ def test_have_compatible_glibc(monkeypatch):
assert not tags._have_compatible_glibc(2, 4)
-def test_linux_platforms_64bit_on_64bit_os(monkeypatch):
- is_64bit_os = distutils.util.get_platform().endswith("_x86_64")
- if platform.system() != "Linux" or not is_64bit_os:
+def test_linux_platforms_64bit_on_64bit_os(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 = tags._linux_platforms(is_32bit=False)[-1]
assert linux_platform == "linux_x86_64"
-def test_linux_platforms_32bit_on_64bit_os(monkeypatch):
- is_64bit_os = distutils.util.get_platform().endswith("_x86_64")
- if platform.system() != "Linux" or not is_64bit_os:
+def test_linux_platforms_32bit_on_64bit_os(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 = tags._linux_platforms(is_32bit=True)[-1]
--
2.22.0