1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
--- a/packaging/tags.py
+++ b/packaging/tags.py
@@ -4,8 +4,6 @@
from __future__ import absolute_import
-import distutils.util
-
try:
from importlib.machinery import EXTENSION_SUFFIXES
except ImportError: # pragma: no cover
@@ -781,7 +779,7 @@ def _manylinux_tags(linux, arch):
def _linux_platforms(is_32bit=_32_BIT_INTERPRETER):
# type: (bool) -> Iterator[str]
- linux = _normalize_string(distutils.util.get_platform())
+ linux = _normalize_string(sysconfig.get_platform())
if is_32bit:
if linux == "linux_x86_64":
linux = "linux_i686"
@@ -796,7 +794,7 @@ def _linux_platforms(is_32bit=_32_BIT_IN
def _generic_platforms():
# type: () -> Iterator[str]
- yield _normalize_string(distutils.util.get_platform())
+ yield _normalize_string(sysconfig.get_platform())
def _platform_tags():
--- a/tests/test_tags.py
+++ b/tests/test_tags.py
@@ -11,7 +11,6 @@ try:
import ctypes
except ImportError:
ctypes = None
-import distutils.util
import os
import platform
import re
@@ -492,14 +491,14 @@ class TestManylinuxPlatform:
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(sysconfig, "get_platform", lambda: arch)
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.20", raising=False)
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")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.20", raising=False)
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda *args: False)
linux_platform = list(tags._linux_platforms(is_32bit=False))
@@ -509,7 +508,7 @@ class TestManylinuxPlatform:
monkeypatch.setattr(
tags, "_is_manylinux_compatible", lambda name, *args: name == "manylinux1"
)
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.20", raising=False)
platforms = list(tags._linux_platforms(is_32bit=False))
@@ -517,7 +516,7 @@ class TestManylinuxPlatform:
assert platforms == ["manylinux1_" + arch, "linux_" + arch]
def test_linux_platforms_manylinux2010(self, monkeypatch):
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.12", raising=False)
platforms = list(tags._linux_platforms(is_32bit=False))
@@ -538,7 +537,7 @@ class TestManylinuxPlatform:
assert platforms == expected
def test_linux_platforms_manylinux2014(self, monkeypatch):
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(platform, "machine", lambda: "x86_64")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.17", raising=False)
platforms = list(tags._linux_platforms(is_32bit=False))
@@ -571,7 +570,7 @@ class TestManylinuxPlatform:
"_is_manylinux_compatible",
lambda name, *args: name == "manylinux2014",
)
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_armv7l")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_armv7l")
monkeypatch.setattr(
sys,
"executable",
@@ -583,7 +582,7 @@ class TestManylinuxPlatform:
def test_linux_platforms_manylinux2014_i386_abi(self, monkeypatch):
monkeypatch.setattr(tags, "_glibc_version_string", lambda: "2.17")
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(
sys,
"executable",
@@ -615,7 +614,7 @@ class TestManylinuxPlatform:
# test for a future glic 3.x version
monkeypatch.setattr(tags, "_glibc_version_string", lambda: "3.2")
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda name, *args: True)
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_aarch64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_aarch64")
monkeypatch.setattr(
sys,
"executable",
@@ -633,7 +632,7 @@ class TestManylinuxPlatform:
monkeypatch.setattr(
tags, "_is_manylinux_compatible", lambda name, _: name == "manylinux2014"
)
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_armv6l")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_armv6l")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.20", raising=False)
platforms = list(tags._linux_platforms(is_32bit=True))
expected = ["linux_armv6l"]
@@ -648,7 +647,7 @@ class TestManylinuxPlatform:
):
monkeypatch.setattr(tags, "_is_manylinux_compatible", lambda name, _: False)
monkeypatch.setattr(
- distutils.util, "get_platform", lambda: "linux_{}".format(machine)
+ sysconfig, "get_platform", lambda: "linux_{}".format(machine)
)
monkeypatch.setattr(
sys,
@@ -995,7 +994,7 @@ class TestGenericTags:
assert not list(tags._generic_abi())
def test_generic_platforms(self):
- platform = distutils.util.get_platform().replace("-", "_")
+ platform = sysconfig.get_platform().replace("-", "_")
platform = platform.replace(".", "_")
assert list(tags._generic_platforms()) == [platform]
@@ -1269,14 +1268,14 @@ class TestSysTags:
assert result[-1] == expected
def test_linux_platforms_manylinux2014_armv6l(self, monkeypatch, manylinux_module):
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_armv6l")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_armv6l")
monkeypatch.setattr(os, "confstr", lambda x: "glibc 2.20", raising=False)
platforms = list(tags._linux_platforms(is_32bit=True))
expected = ["linux_armv6l"]
assert platforms == expected
def test_skip_manylinux_2014(self, monkeypatch, manylinux_module):
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_ppc64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_ppc64")
monkeypatch.setattr(tags, "_get_glibc_version", lambda: (2, 20))
monkeypatch.setattr(
manylinux_module, "manylinux2014_compatible", False, raising=False
@@ -1300,7 +1299,7 @@ class TestSysTags:
self, monkeypatch, manylinux_module, machine, abi, alt_machine
):
monkeypatch.setattr(
- distutils.util, "get_platform", lambda: "linux_{}".format(machine)
+ sysconfig, "get_platform", lambda: "linux_{}".format(machine)
)
monkeypatch.setattr(
sys,
@@ -1326,7 +1325,7 @@ class TestSysTags:
monkeypatch.setattr(tags, "_get_glibc_version", lambda: (major, minor))
monkeypatch.setattr(
- distutils.util, "get_platform", lambda: "linux_{}".format(machine)
+ sysconfig, "get_platform", lambda: "linux_{}".format(machine)
)
monkeypatch.setattr(
manylinux_module,
@@ -1349,7 +1348,7 @@ class TestSysTags:
return None
monkeypatch.setattr(tags, "_get_glibc_version", lambda: (2, 30))
- monkeypatch.setattr(distutils.util, "get_platform", lambda: "linux_x86_64")
+ monkeypatch.setattr(sysconfig, "get_platform", lambda: "linux_x86_64")
monkeypatch.setattr(
manylinux_module,
"manylinux_compatible",
|