8000 fix(whl_library): fix ABI parsing for exotic wheel platforms · bazel-contrib/rules_python@430d62c · GitHub
[go: up one dir, main page]

Skip to content

Commit 430d62c

Browse files
committed
fix(whl_library): fix ABI parsing for exotic wheel platforms
In addition to the regular `cp39_linux_x86_64` or `linux_x86_64` we need to also handle the `abi3_linux_x86_64` and `none_linux_x86_64`.
1 parent f946f8d commit 430d62c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

python/pip_install/tools/wheel_installer/wheel.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,14 @@ def from_string(cls, platform: Union[str, List[str]]) -> List["Platform"]:
191191
continue
192192

193193
abi, _, tail = p.partition("_")
194-
if not abi.startswith("cp"):
194+
if abi in ["abi3", "none"]:
195+
abi = ""
196+
elif not abi.startswith("cp"):
195197
# The first item is not an abi
196198
tail = p
197199
abi = ""
198200
os, _, arch = tail.partition("_")
201+
print(abi, os, arch)
199202
arch = arch or "*"
200203

201204
minor_version = int(abi[len("cp3") :]) if abi else None

python/pip_install/tools/wheel_installer/wheel_test.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,14 @@ def test_can_get_host(self):
290290
self.assertEqual(host, wheel.Platform.from_string("host"))
291291

292292
def test_can_get_linux_x86_64_without_py_version(self):
293-
got = wheel.Platform.from_string("linux_x86_64")
294-
want = wheel.Platform(os=wheel.OS.linux, arch=wheel.Arch.x86_64)
295-
self.assertEqual(want, got[0])
293+
for input in [
294+
"linux_x86_64",
295+
"abi3_linux_x86_64",
296+
"none_linux_x86_64",
297+
]:
298+
got = wheel.Platform.from_string(input)
299+
want = wheel.Platform(os=wheel.OS.linux, arch=wheel.Arch.x86_64)
300+
self.assertEqual(want, got[0])
296301

297302
def test_can_get_specific_from_string(self):
298303
got = wheel.Platform.from_string("cp33_linux_x86_64")

0 commit comments

Comments
 (0)
0