fix(pypi): correctly translate ppc64le to bazel platforms (#2577)
Bump the `platforms` version and correctly translate the ppc64le value.
See https://github.com/bazelbuild/platforms/pull/105
---------
Co-authored-by: Richard Levasseur <rlevasseur@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 203cc55..8a62ab7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,11 +52,11 @@
{#v0-0-0-changed}
### Changed
-* Nothing changed.
+* (deps) platforms 0.0.4 -> 0.0.11
{#v0-0-0-fixed}
### Fixed
-* Nothing fixed.
+* (pypi) The `ppc64le` is now pointing to the right target in the `platforms` package.
{#v0-0-0-added}
### Added
diff --git a/MODULE.bazel b/MODULE.bazel
index 76710e4..3d7c304 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -7,7 +7,7 @@
bazel_dep(name = "bazel_features", version = "1.21.0")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_cc", version = "0.0.16")
-bazel_dep(name = "platforms", version = "0.0.4")
+bazel_dep(name = "platforms", version = "0.0.11")
# Those are loaded only when using py_proto_library
# Use py_proto_library directly from protobuf repository
diff --git a/python/private/pypi/whl_installer/platform.py b/python/private/pypi/whl_installer/platform.py
index 83e42b0..11dd6e3 100644
--- a/python/private/pypi/whl_installer/platform.py
+++ b/python/private/pypi/whl_installer/platform.py
@@ -42,14 +42,14 @@
x86_32 = 2
aarch64 = 3
ppc = 4
- s390x = 5
- arm = 6
+ ppc64le = 5
+ s390x = 6
+ arm = 7
amd64 = x86_64
arm64 = aarch64
i386 = x86_32
i686 = x86_32
x86 = x86_32
- ppc64le = ppc
@classmethod
def interpreter(cls) -> "Arch":
@@ -271,6 +271,8 @@
return "arm64"
elif self.os != OS.linux:
return ""
+ elif self.arch == Arch.ppc:
+ return "ppc"
elif self.arch == Arch.ppc64le:
return "ppc64le"
elif self.arch == Arch.s390x:
diff --git a/python/private/pypi/whl_target_platforms.bzl b/python/private/pypi/whl_target_platforms.bzl
index 6823199..9f47e62 100644
--- a/python/private/pypi/whl_target_platforms.bzl
+++ b/python/private/pypi/whl_target_platforms.bzl
@@ -31,7 +31,7 @@
"arm64": "aarch64",
"ppc": "ppc",
"ppc64": "ppc",
- "ppc64le": "ppc",
+ "ppc64le": "ppc64le",
"s390x": "s390x",
"arm": "arm",
"armv6l": "arm",
diff --git a/python/private/repo_utils.bzl b/python/private/repo_utils.bzl
index e5c78be..d9ad244 100644
--- a/python/private/repo_utils.bzl
+++ b/python/private/repo_utils.bzl
@@ -391,8 +391,10 @@
return "x86_32"
if arch in ["amd64", "x86_64", "x64"]:
return "x86_64"
- if arch in ["ppc", "ppc64", "ppc64le"]:
+ if arch in ["ppc", "ppc64"]:
return "ppc"
+ if arch in ["ppc64le"]:
+ return "ppc64le"
if arch in ["arm", "armv7l"]:
return "arm"
if arch in ["aarch64"]:
diff --git a/tests/config_settings/construct_config_settings_tests.bzl b/tests/config_settings/construct_config_settings_tests.bzl
index 087efbb..1d21a86 100644
--- a/tests/config_settings/construct_config_settings_tests.bzl
+++ b/tests/config_settings/construct_config_settings_tests.bzl
@@ -47,7 +47,7 @@
}
minor_cpu_matches = {
str(Label(":is_python_3.11_aarch64")): "matched-3.11-aarch64",
- str(Label(":is_python_3.11_ppc")): "matched-3.11-ppc",
+ str(Label(":is_python_3.11_ppc64le")): "matched-3.11-ppc64le",
str(Label(":is_python_3.11_s390x")): "matched-3.11-s390x",
str(Label(":is_python_3.11_x86_64")): "matched-3.11-x86_64",
}
@@ -58,7 +58,7 @@
}
minor_os_cpu_matches = {
str(Label(":is_python_3.11_linux_aarch64")): "matched-3.11-linux-aarch64",
- str(Label(":is_python_3.11_linux_ppc")): "matched-3.11-linux-ppc",
+ str(Label(":is_python_3.11_linux_ppc64le")): "matched-3.11-linux-ppc64le",
str(Label(":is_python_3.11_linux_s390x")): "matched-3.11-linux-s390x",
str(Label(":is_python_3.11_linux_x86_64")): "matched-3.11-linux-x86_64",
str(Label(":is_python_3.11_osx_aarch64")): "matched-3.11-osx-aarch64",
@@ -171,7 +171,7 @@
},
)
- for cpu in ["s390x", "ppc", "x86_64", "aarch64"]:
+ for cpu in ["s390x", "ppc", "ppc64le", "x86_64", "aarch64"]:
native.config_setting(
name = "is_python_3.11_" + cpu,
constraint_values = [
@@ -185,6 +185,7 @@
for (os, cpu) in [
("linux", "aarch64"),
("linux", "ppc"),
+ ("linux", "ppc64le"),
("linux", "s390x"),
("linux", "x86_64"),
("osx", "aarch64"),
diff --git a/tests/pypi/whl_installer/platform_test.py b/tests/pypi/whl_installer/platform_test.py
index 7ced1e9..2aeb4ca 100644
--- a/tests/pypi/whl_installer/platform_test.py
+++ b/tests/pypi/whl_installer/platform_test.py
@@ -34,17 +34,17 @@
def test_can_get_all_for_py_version(self):
cp39 = Platform.all(minor_version=9)
- self.assertEqual(18, len(cp39), f"Got {cp39}")
+ self.assertEqual(21, len(cp39), f"Got {cp39}")
self.assertEqual(cp39, Platform.from_string("cp39_*"))
def test_can_get_all_for_os(self):
linuxes = Platform.all(OS.linux, minor_version=9)
- self.assertEqual(6, len(linuxes))
+ self.assertEqual(7, len(linuxes))
self.assertEqual(linuxes, Platform.from_string("cp39_linux_*"))
def test_can_get_all_for_os_for_host_python(self):
linuxes = Platform.all(OS.linux)
- self.assertEqual(6, len(linuxes))
+ self.assertEqual(7, len(linuxes))
self.assertEqual(linuxes, Platform.from_string("linux_*"))
def test_specific_version_specializations(self):
@@ -84,6 +84,7 @@
Platform(os=OS.linux, arch=Arch.x86_32),
Platform(os=OS.linux, arch=Arch.aarch64),
Platform(os=OS.linux, arch=Arch.ppc),
+ Platform(os=OS.linux, arch=Arch.ppc64le),
Platform(os=OS.linux, arch=Arch.s390x),
Platform(os=OS.linux, arch=Arch.arm),
]
@@ -101,6 +102,7 @@
Platform(os=OS.osx, arch=Arch.x86_32),
Platform(os=OS.osx, arch=Arch.aarch64),
Platform(os=OS.osx, arch=Arch.ppc),
+ Platform(os=OS.osx, arch=Arch.ppc64le),
Platform(os=OS.osx, arch=Arch.s390x),
Platform(os=OS.osx, arch=Arch.arm),
]
diff --git a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
index ba04e1d..a042ed0 100644
--- a/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
+++ b/tests/pypi/whl_library_targets/whl_library_targets_tests.bzl
@@ -68,7 +68,7 @@
"@//python/config_settings:is_python_3.9": ["py39_dep"],
"@platforms//cpu:aarch64": ["arm_dep"],
"@platforms//os:windows": ["win_dep"],
- "cp310_linux_ppc": ["py310_linux_ppc_dep"],
+ "cp310_linux_ppc64le": ["py310_linux_ppc64le_dep"],
"cp39_anyos_aarch64": ["py39_arm_dep"],
"cp39_linux_anyarch": ["py39_linux_dep"],
"linux_x86_64": ["linux_intel_dep"],
@@ -82,12 +82,12 @@
env.expect.that_collection(calls).contains_exactly([
{
- "name": "is_python_3.10_linux_ppc",
+ "name": "is_python_3.10_linux_ppc64le",
"flag_values": {
"@rules_python//python/config_settings:python_version_major_minor": "3.10",
},
"constraint_values": [
- "@platforms//cpu:ppc",
+ "@platforms//cpu:ppc64le",
"@platforms//os:linux",
],
"visibility": ["//visibility:private"],
@@ -195,7 +195,7 @@
"@//python/config_settings:is_python_3.9": ["py39_dep"],
"@platforms//cpu:aarch64": ["arm_dep"],
"@platforms//os:windows": ["win_dep"],
- "cp310_linux_ppc": ["py310_linux_ppc_dep"],
+ "cp310_linux_ppc64le": ["py310_linux_ppc64le_dep"],
"cp39_anyos_aarch64": ["py39_arm_dep"],
"cp39_linux_anyarch": ["py39_linux_dep"],
"linux_x86_64": ["linux_intel_dep"],
@@ -227,7 +227,7 @@
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:whl"],
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:whl"],
"@platforms//os:windows": ["@pypi_win_dep//:whl"],
- ":is_python_3.10_linux_ppc": ["@pypi_py310_linux_ppc_dep//:whl"],
+ ":is_python_3.10_linux_ppc64le": ["@pypi_py310_linux_ppc64le_dep//:whl"],
":is_python_3.9_anyos_aarch64": ["@pypi_py39_arm_dep//:whl"],
":is_python_3.9_linux_anyarch": ["@pypi_py39_linux_dep//:whl"],
":is_linux_x86_64": ["@pypi_linux_intel_dep//:whl"],
@@ -264,7 +264,7 @@
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:pkg"],
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:pkg"],
"@platforms//os:windows": ["@pypi_win_dep//:pkg"],
- ":is_python_3.10_linux_ppc": ["@pypi_py310_linux_ppc_dep//:pkg"],
+ ":is_python_3.10_linux_ppc64le": ["@pypi_py310_linux_ppc64le_dep//:pkg"],
":is_python_3.9_anyos_aarch64": ["@pypi_py39_arm_dep//:pkg"],
":is_python_3.9_linux_anyarch": ["@pypi_py39_linux_dep//:pkg"],
":is_linux_x86_64": ["@pypi_linux_intel_dep//:pkg"],
diff --git a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl
index a72bdc2..a976a0c 100644
--- a/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl
+++ b/tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl
@@ -32,7 +32,7 @@
struct(os = "linux", cpu = "x86_32", abi = None, target_platform = "linux_x86_32", version = (2, 17)),
],
"musllinux_1_1_ppc64le": [
- struct(os = "linux", cpu = "ppc", abi = None, target_platform = "linux_ppc", version = (1, 1)),
+ struct(os = "linux", cpu = "ppc64le", abi = None, target_platform = "linux_ppc64le", version = (1, 1)),
],
"win_amd64": [
struct(os = "windows", cpu = "x86_64", abi = None, target_platform = "windows_x86_64", version = (0, 0)),
@@ -60,9 +60,12 @@
"manylinux1_i686.manylinux_2_17_i686": [
struct(os = "linux", cpu = "x86_32", abi = "cp38", target_platform = "cp38_linux_x86_32", version = (0, 0)),
],
- "musllinux_1_1_ppc64le": [
+ "musllinux_1_1_ppc64": [
struct(os = "linux", cpu = "ppc", abi = "cp311", target_platform = "cp311_linux_ppc", version = (1, 1)),
],
+ "musllinux_1_1_ppc64le": [
+ struct(os = "linux", cpu = "ppc64le", abi = "cp311", target_platform = "cp311_linux_ppc64le", version = (1, 1)),
+ ],
"win_amd64": [
struct(os = "windows", cpu = "x86_64", abi = "cp311", target_platform = "cp311_windows_x86_64", version = (0, 0)),
],