Skip to content

Commit 793dddf

Browse files
kxxtaignas
andauthored
fix: Add linux_riscv64 to _pip_repository_impl (#3350)
Add `linux_riscv64` support for pulling pip dependencies. This is not adding any hermetic toolchain support - user has to provide a working toolchain. Fix #2729 --------- Co-authored-by: Ignas Anikevicius <[email protected]>
1 parent 3c3e0be commit 793dddf

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ END_UNRELEASED_TEMPLATE
113113
([#3339](https://github.com/bazel-contrib/rules_python/issues/3339)).
114114
* (uv) {obj}`//python/uv:lock.bzl%lock` now works with a local platform
115115
runtime.
116+
* (pypi) `linux_riscv64` is added to the platforms list in `_pip_repository_impl`,
117+
which fixes [a build issue for tensorflow on riscv64](https://github.com/bazel-contrib/rules_python/discussions/2729).
116118
* (toolchains) WORKSPACE builds now correctly register musl and freethreaded
117119
variants. Setting {obj}`--py_linux_libc=musl` and `--py_freethreaded=yes` now
118120
activate them, respectively.

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: 8 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
],
@@ -103,6 +109,7 @@ def _can_parse_existing_tags(env):
103109
"manylinux_11_12_i686": 1,
104110
"manylinux_11_12_ppc64": 1,
105111
"manylinux_11_12_ppc64le": 1,
112+
"manylinux_11_12_riscv64": 1,
106113
"manylinux_11_12_s390x": 1,
107114
"manylinux_11_12_x86_64": 1,
108115
"manylinux_1_2_aarch64": 1,
@@ -111,6 +118,7 @@ def _can_parse_existing_tags(env):
111118
"musllinux_11_12_armv7l": 1,
112119
"musllinux_11_12_i686": 1,
113120
"musllinux_11_12_ppc64le": 1,
121+
"musllinux_11_12_riscv64": 1,
114122
"musllinux_11_12_s390x": 1,
115123
"musllinux_11_12_x86_64": 1,
116124
"win32": 1,

0 commit comments

Comments
 (0)