Skip to content

Commit 96deeab

Browse files
committed
fix: Add linux_riscv64 to _pip_repository_impl
Fix #2729
1 parent 43a5acf commit 96deeab

File tree

6 files changed

+20
-4
lines changed

6 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ END_UNRELEASED_TEMPLATE
110110
([#3339](https://github.com/bazel-contrib/rules_python/issues/3339)).
111111
* (uv) {obj}`//python/uv:lock.bzl%lock` now works with a local platform
112112
runtime.
113+
* (pypi) `linux_riscv64` is added to the platforms list in `_pip_repository_impl`,
114+
which fixes [a build issue for tensorflow on riscv64](https://github.com/bazel-contrib/rules_python/discussions/2729).
113115
* (toolchains) WORKSPACE builds now correctly register musl and freethreaded
114116
variants. Setting {obj}`--py_linux_libc=musl` and `--py_freethreaded=yes` now
115117
activate them, respectively.
@@ -1980,4 +1982,4 @@ Breaking changes:
19801982
* (pip) Create all_data_requirements alias
19811983
* Expose Python C headers through the toolchain.
19821984

1983-
[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0
1985+
[0.24.0]: https://github.com/bazel-contrib/rules_python/releases/tag/0.24.0

python/private/pypi/pip_repository.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def _pip_repository_impl(rctx):
9696
"linux_aarch64",
9797
"linux_arm",
9898
"linux_ppc",
99+
"linux_riscv64",
99100
"linux_s390x",
100101
"linux_x86_64",
101102
"osx_aarch64",

python/private/pypi/whl_installer/platform.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Arch(Enum):
4545
ppc64le = 5
4646
s390x = 6
4747
arm = 7
48+
riscv64 = 8
4849
amd64 = x86_64
4950
arm64 = aarch64
5051
i386 = x86_32
@@ -269,6 +270,8 @@ def platform_machine(self) -> str:
269270
return "ppc"
270271
elif self.arch == Arch.ppc64le:
271272
return "ppc64le"
273+
elif self.arch == Arch.riscv64:
274+
return "riscv64"
272275
elif self.arch == Arch.s390x:
273276
return "s390x"
274277
else:

python/private/pypi/whl_target_platforms.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ _CPU_ALIASES = {
3030
"ppc": "ppc",
3131
"ppc64": "ppc",
3232
"ppc64le": "ppc64le",
33+
"riscv64": "riscv64",
3334
"s390x": "s390x",
3435
"arm": "arm",
3536
"armv6l": "arm",

tests/pypi/whl_installer/platform_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ def test_can_get_specific_from_string(self):
3838

3939
def test_can_get_all_for_py_version(self):
4040
cp39 = Platform.all(minor_version=9, micro_version=0)
41-
self.assertEqual(21, len(cp39), f"Got {cp39}")
41+
self.assertEqual(24, len(cp39), f"Got {cp39}")
4242
self.assertEqual(cp39, Platform.from_string("cp39.0_*"))
4343

4444
def test_can_get_all_for_os(self):
4545
linuxes = Platform.all(OS.linux, minor_version=9)
46-
self.assertEqual(7, len(linuxes))
46+
self.assertEqual(8, len(linuxes))
4747
self.assertEqual(linuxes, Platform.from_string("cp39_linux_*"))
4848

4949
def test_can_get_all_for_os_for_host_python(self):
5050
linuxes = Platform.all(OS.linux)
51-
self.assertEqual(7, len(linuxes))
51+
self.assertEqual(8, len(linuxes))
5252
self.assertEqual(linuxes, Platform.from_string("linux_*"))
5353

5454
def test_platform_sort(self):

tests/pypi/whl_target_platforms/whl_target_platforms_tests.bzl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ def _test_simple(env):
3434
"musllinux_1_1_ppc64le": [
3535
struct(os = "linux", cpu = "ppc64le", abi = None, target_platform = "linux_ppc64le", version = (1, 1)),
3636
],
37+
"musllinux_1_2_riscv64": [
38+
struct(os = "linux", cpu = "riscv64", abi = None, target_platform = "linux_riscv64", version = (1, 2)),
39+
],
3740
"win_amd64": [
3841
struct(os = "windows", cpu = "x86_64", abi = None, target_platform = "windows_x86_64", version = (0, 0)),
3942
],
@@ -66,6 +69,9 @@ def _test_with_abi(env):
6669
"musllinux_1_1_ppc64le": [
6770
struct(os = "linux", cpu = "ppc64le", abi = "cp311", target_platform = "cp311_linux_ppc64le", version = (1, 1)),
6871
],
72+
"musllinux_1_2_riscv64": [
73+
struct(os = "linux", cpu = "riscv64", abi = "cp311", target_platform = "cp311_linux_riscv64", version = (1, 2)),
74+
],
6975
"win_amd64": [
7076
struct(os = "windows", cpu = "x86_64", abi = "cp311", target_platform = "cp311_windows_x86_64", version = (0, 0)),
7177
],
@@ -96,13 +102,15 @@ def _can_parse_existing_tags(env):
96102
"manylinux2014_i686": 1,
97103
"manylinux2014_ppc64": 1,
98104
"manylinux2014_ppc64le": 1,
105+
"manylinux2014_riscv64": 1,
99106
"manylinux2014_s390x": 1,
100107
"manylinux2014_x86_64": 1,
101108
"manylinux_11_12_aarch64": 1,
102109
"manylinux_11_12_armv7l": 1,
103110
"manylinux_11_12_i686": 1,
104111
"manylinux_11_12_ppc64": 1,
105112
"manylinux_11_12_ppc64le": 1,
113+
"manylinux_11_12_riscv64": 1,
106114
"manylinux_11_12_s390x": 1,
107115
"manylinux_11_12_x86_64": 1,
108116
"manylinux_1_2_aarch64": 1,
@@ -111,6 +119,7 @@ def _can_parse_existing_tags(env):
111119
"musllinux_11_12_armv7l": 1,
112120
"musllinux_11_12_i686": 1,
113121
"musllinux_11_12_ppc64le": 1,
122+
"musllinux_11_12_riscv64": 1,
114123
"musllinux_11_12_s390x": 1,
115124
"musllinux_11_12_x86_64": 1,
116125
"win32": 1,

0 commit comments

Comments
 (0)