Skip to content

Commit fa88281

Browse files
aignasrickeylev
andauthored
fix(pypi): correctly translate ppc64le to bazel platforms (bazel-contrib#2577)
Bump the `platforms` version and correctly translate the ppc64le value. See bazelbuild/platforms#105 --------- Co-authored-by: Richard Levasseur <[email protected]>
1 parent a04b2a4 commit fa88281

File tree

9 files changed

+32
-22
lines changed

9 files changed

+32
-22
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ Unreleased changes template.
5252

5353
{#v0-0-0-changed}
5454
### Changed
55-
* Nothing changed.
55+
* (deps) platforms 0.0.4 -> 0.0.11
5656

5757
{#v0-0-0-fixed}
5858
### Fixed
59-
* Nothing fixed.
59+
* (pypi) The `ppc64le` is now pointing to the right target in the `platforms` package.
6060

6161
{#v0-0-0-added}
6262
### Added

MODULE.bazel

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module(
77
bazel_dep(name = "bazel_features", version = "1.21.0")
88
bazel_dep(name = "bazel_skylib", version = "1.7.1")
99
bazel_dep(name = "rules_cc", version = "0.0.16")
10-
bazel_dep(name = "platforms", version = "0.0.4")
10+
bazel_dep(name = "platforms", version = "0.0.11")
1111

1212
# Those are loaded only when using py_proto_library
1313
# Use py_proto_library directly from protobuf repository

python/private/pypi/whl_installer/platform.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ class Arch(Enum):
4242
x86_32 = 2
4343
aarch64 = 3
4444
ppc = 4
45-
s390x = 5
46-
arm = 6
45+
ppc64le = 5
46+
s390x = 6
47+
arm = 7
4748
amd64 = x86_64
4849
arm64 = aarch64
4950
i386 = x86_32
5051
i686 = x86_32
5152
x86 = x86_32
52-
ppc64le = ppc
5353

5454
@classmethod
5555
def interpreter(cls) -> "Arch":
@@ -271,6 +271,8 @@ def platform_machine(self) -> str:
271271
return "arm64"
272272
elif self.os != OS.linux:
273273
return ""
274+
elif self.arch == Arch.ppc:
275+
return "ppc"
274276
elif self.arch == Arch.ppc64le:
275277
return "ppc64le"
276278
elif self.arch == Arch.s390x:

python/private/pypi/whl_target_platforms.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _CPU_ALIASES = {
3131
"arm64": "aarch64",
3232
"ppc": "ppc",
3333
"ppc64": "ppc",
34-
"ppc64le": "ppc",
34+
"ppc64le": "ppc64le",
3535
"s390x": "s390x",
3636
"arm": "arm",
3737
"armv6l": "arm",

python/private/repo_utils.bzl

+3-1
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,10 @@ def _get_platforms_cpu_name(mrctx):
391391
return "x86_32"
392392
if arch in ["amd64", "x86_64", "x64"]:
393393
return "x86_64"
394-
if arch in ["ppc", "ppc64", "ppc64le"]:
394+
if arch in ["ppc", "ppc64"]:
395395
return "ppc"
396+
if arch in ["ppc64le"]:
397+
return "ppc64le"
396398
if arch in ["arm", "armv7l"]:
397399
return "arm"
398400
if arch in ["aarch64"]:

tests/config_settings/construct_config_settings_tests.bzl

+4-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def _test_minor_version_matching(name):
4747
}
4848
minor_cpu_matches = {
4949
str(Label(":is_python_3.11_aarch64")): "matched-3.11-aarch64",
50-
str(Label(":is_python_3.11_ppc")): "matched-3.11-ppc",
50+
str(Label(":is_python_3.11_ppc64le")): "matched-3.11-ppc64le",
5151
str(Label(":is_python_3.11_s390x")): "matched-3.11-s390x",
5252
str(Label(":is_python_3.11_x86_64")): "matched-3.11-x86_64",
5353
}
@@ -58,7 +58,7 @@ def _test_minor_version_matching(name):
5858
}
5959
minor_os_cpu_matches = {
6060
str(Label(":is_python_3.11_linux_aarch64")): "matched-3.11-linux-aarch64",
61-
str(Label(":is_python_3.11_linux_ppc")): "matched-3.11-linux-ppc",
61+
str(Label(":is_python_3.11_linux_ppc64le")): "matched-3.11-linux-ppc64le",
6262
str(Label(":is_python_3.11_linux_s390x")): "matched-3.11-linux-s390x",
6363
str(Label(":is_python_3.11_linux_x86_64")): "matched-3.11-linux-x86_64",
6464
str(Label(":is_python_3.11_osx_aarch64")): "matched-3.11-osx-aarch64",
@@ -171,7 +171,7 @@ def construct_config_settings_test_suite(name): # buildifier: disable=function-
171171
},
172172
)
173173

174-
for cpu in ["s390x", "ppc", "x86_64", "aarch64"]:
174+
for cpu in ["s390x", "ppc", "ppc64le", "x86_64", "aarch64"]:
175175
native.config_setting(
176176
name = "is_python_3.11_" + cpu,
177177
constraint_values = [
@@ -185,6 +185,7 @@ def construct_config_settings_test_suite(name): # buildifier: disable=function-
185185
for (os, cpu) in [
186186
("linux", "aarch64"),
187187
("linux", "ppc"),
188+
("linux", "ppc64le"),
188189
("linux", "s390x"),
189190
("linux", "x86_64"),
190191
("osx", "aarch64"),

tests/pypi/whl_installer/platform_test.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,17 @@ def test_can_get_specific_from_string(self):
3434

3535
def test_can_get_all_for_py_version(self):
3636
cp39 = Platform.all(minor_version=9)
37-
self.assertEqual(18, len(cp39), f"Got {cp39}")
37+
self.assertEqual(21, len(cp39), f"Got {cp39}")
3838
self.assertEqual(cp39, Platform.from_string("cp39_*"))
3939

4040
def test_can_get_all_for_os(self):
4141
linuxes = Platform.all(OS.linux, minor_version=9)
42-
self.assertEqual(6, len(linuxes))
42+
self.assertEqual(7, len(linuxes))
4343
self.assertEqual(linuxes, Platform.from_string("cp39_linux_*"))
4444

4545
def test_can_get_all_for_os_for_host_python(self):
4646
linuxes = Platform.all(OS.linux)
47-
self.assertEqual(6, len(linuxes))
47+
self.assertEqual(7, len(linuxes))
4848
self.assertEqual(linuxes, Platform.from_string("linux_*"))
4949

5050
def test_specific_version_specializations(self):
@@ -84,6 +84,7 @@ def test_linux_specializations(self):
8484
Platform(os=OS.linux, arch=Arch.x86_32),
8585
Platform(os=OS.linux, arch=Arch.aarch64),
8686
Platform(os=OS.linux, arch=Arch.ppc),
87+
Platform(os=OS.linux, arch=Arch.ppc64le),
8788
Platform(os=OS.linux, arch=Arch.s390x),
8889
Platform(os=OS.linux, arch=Arch.arm),
8990
]
@@ -101,6 +102,7 @@ def test_osx_specializations(self):
101102
Platform(os=OS.osx, arch=Arch.x86_32),
102103
Platform(os=OS.osx, arch=Arch.aarch64),
103104
Platform(os=OS.osx, arch=Arch.ppc),
105+
Platform(os=OS.osx, arch=Arch.ppc64le),
104106
Platform(os=OS.osx, arch=Arch.s390x),
105107
Platform(os=OS.osx, arch=Arch.arm),
106108
]

tests/pypi/whl_library_targets/whl_library_targets_tests.bzl

+6-6
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def _test_platforms(env):
6868
"@//python/config_settings:is_python_3.9": ["py39_dep"],
6969
"@platforms//cpu:aarch64": ["arm_dep"],
7070
"@platforms//os:windows": ["win_dep"],
71-
"cp310_linux_ppc": ["py310_linux_ppc_dep"],
71+
"cp310_linux_ppc64le": ["py310_linux_ppc64le_dep"],
7272
"cp39_anyos_aarch64": ["py39_arm_dep"],
7373
"cp39_linux_anyarch": ["py39_linux_dep"],
7474
"linux_x86_64": ["linux_intel_dep"],
@@ -82,12 +82,12 @@ def _test_platforms(env):
8282

8383
env.expect.that_collection(calls).contains_exactly([
8484
{
85-
"name": "is_python_3.10_linux_ppc",
85+
"name": "is_python_3.10_linux_ppc64le",
8686
"flag_values": {
8787
"@rules_python//python/config_settings:python_version_major_minor": "3.10",
8888
},
8989
"constraint_values": [
90-
"@platforms//cpu:ppc",
90+
"@platforms//cpu:ppc64le",
9191
"@platforms//os:linux",
9292
],
9393
"visibility": ["//visibility:private"],
@@ -195,7 +195,7 @@ def _test_whl_and_library_deps(env):
195195
"@//python/config_settings:is_python_3.9": ["py39_dep"],
196196
"@platforms//cpu:aarch64": ["arm_dep"],
197197
"@platforms//os:windows": ["win_dep"],
198-
"cp310_linux_ppc": ["py310_linux_ppc_dep"],
198+
"cp310_linux_ppc64le": ["py310_linux_ppc64le_dep"],
199199
"cp39_anyos_aarch64": ["py39_arm_dep"],
200200
"cp39_linux_anyarch": ["py39_linux_dep"],
201201
"linux_x86_64": ["linux_intel_dep"],
@@ -227,7 +227,7 @@ def _test_whl_and_library_deps(env):
227227
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:whl"],
228228
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:whl"],
229229
"@platforms//os:windows": ["@pypi_win_dep//:whl"],
230-
":is_python_3.10_linux_ppc": ["@pypi_py310_linux_ppc_dep//:whl"],
230+
":is_python_3.10_linux_ppc64le": ["@pypi_py310_linux_ppc64le_dep//:whl"],
231231
":is_python_3.9_anyos_aarch64": ["@pypi_py39_arm_dep//:whl"],
232232
":is_python_3.9_linux_anyarch": ["@pypi_py39_linux_dep//:whl"],
233233
":is_linux_x86_64": ["@pypi_linux_intel_dep//:whl"],
@@ -264,7 +264,7 @@ def _test_whl_and_library_deps(env):
264264
Label("//python/config_settings:is_python_3.9"): ["@pypi_py39_dep//:pkg"],
265265
"@platforms//cpu:aarch64": ["@pypi_arm_dep//:pkg"],
266266
"@platforms//os:windows": ["@pypi_win_dep//:pkg"],
267-
":is_python_3.10_linux_ppc": ["@pypi_py310_linux_ppc_dep//:pkg"],
267+
":is_python_3.10_linux_ppc64le": ["@pypi_py310_linux_ppc64le_dep//:pkg"],
268268
":is_python_3.9_anyos_aarch64": ["@pypi_py39_arm_dep//:pkg"],
269269
":is_python_3.9_linux_anyarch": ["@pypi_py39_linux_dep//:pkg"],
270270
":is_linux_x86_64": ["@pypi_linux_intel_dep//:pkg"],

tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def _test_simple(env):
3232
struct(os = "linux", cpu = "x86_32", abi = None, target_platform = "linux_x86_32", version = (2, 17)),
3333
],
3434
"musllinux_1_1_ppc64le": [
35-
struct(os = "linux", cpu = "ppc", abi = None, target_platform = "linux_ppc", version = (1, 1)),
35+
struct(os = "linux", cpu = "ppc64le", abi = None, target_platform = "linux_ppc64le", version = (1, 1)),
3636
],
3737
"win_amd64": [
3838
struct(os = "windows", cpu = "x86_64", abi = None, target_platform = "windows_x86_64", version = (0, 0)),
@@ -60,9 +60,12 @@ def _test_with_abi(env):
6060
"manylinux1_i686.manylinux_2_17_i686": [
6161
struct(os = "linux", cpu = "x86_32", abi = "cp38", target_platform = "cp38_linux_x86_32", version = (0, 0)),
6262
],
63-
"musllinux_1_1_ppc64le": [
63+
"musllinux_1_1_ppc64": [
6464
struct(os = "linux", cpu = "ppc", abi = "cp311", target_platform = "cp311_linux_ppc", version = (1, 1)),
6565
],
66+
"musllinux_1_1_ppc64le": [
67+
struct(os = "linux", cpu = "ppc64le", abi = "cp311", target_platform = "cp311_linux_ppc64le", version = (1, 1)),
68+
],
6669
"win_amd64": [
6770
struct(os = "windows", cpu = "x86_64", abi = "cp311", target_platform = "cp311_windows_x86_64", version = (0, 0)),
6871
],

0 commit comments

Comments
 (0)