From f76e0fe5e669bd99c1f0c782eb6c3decec982bb6 Mon Sep 17 00:00:00 2001
From: Jo Shields
Date: Tue, 2 Sep 2025 13:17:30 -0400
Subject: [PATCH] Add `--python-platform riscv64-unknown-linux` to various
commands (#15630)
## Summary
We (and I'm sure many others) are currently doing a lot of RISC-V work
in QEMU. It is possible to significantly improve the speed of
Python-related builds by taking care of the environment setup using an
AMD64 `uv` binary (bypassing binfmt/qemu-system emulation).
Some approx numbers from local testing in riscv64 Ubuntu in QEMU:
| Resolver arch | Command | Time |
| --- | --- | --- |
| riscv64 | `pip install --upgrade --break-system-packages
--index-url=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
openai-harmony` | 15s |
| riscv64 | `uv pip install --upgrade --system --break-system-packages
--index-url=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
openai-harmony` | 5s |
| amd64 | `uv pip install --python-platform=riscv64-unknown-linux
--upgrade --system --break-system-packages
--index-url=https://gitlab.com/api/v4/projects/riseproject%2Fpython%2Fwheel_builder/packages/pypi/simple
openai-harmony` | 4s |
The numbers from some larger internal packages with deeper dependency
trees are much more pronounced - 3m6 vs 43s vs 8s, in one example.
Manylinux 2.39 is specified, as it's the first (only?) RISC-V manylinux
## Test Plan
Locally, in QEMU.
`$ docker run --platform linux/riscv64 -it ubuntu:latest`, get amd64
libc into LD_LIBRARY_PATH, tests as above
---
crates/uv-configuration/src/target_triple.rs | 19 +++++++++++++++++++
docs/reference/cli.md | 10 ++++++++++
uv.schema.json | 5 +++++
3 files changed, 34 insertions(+)
diff --git a/crates/uv-configuration/src/target_triple.rs b/crates/uv-configuration/src/target_triple.rs
index d64fcf1b1..851ca125a 100644
--- a/crates/uv-configuration/src/target_triple.rs
+++ b/crates/uv-configuration/src/target_triple.rs
@@ -78,6 +78,11 @@ pub enum TargetTriple {
#[serde(alias = "x8664-unknown-linux-musl")]
X8664UnknownLinuxMusl,
+ /// A RISCV64 Linux target.
+ #[cfg_attr(feature = "clap", value(name = "riscv64-unknown-linux"))]
+ #[serde(rename = "riscv64-unknown-linux")]
+ Riscv64UnknownLinuxGnu,
+
/// An `x86_64` target for the `manylinux2014` platform. Equivalent to `x86_64-manylinux_2_17`.
#[cfg_attr(feature = "clap", value(name = "x86_64-manylinux2014"))]
#[serde(rename = "x86_64-manylinux2014")]
@@ -273,6 +278,13 @@ impl TargetTriple {
},
Arch::Aarch64,
),
+ Self::Riscv64UnknownLinuxGnu => Platform::new(
+ Os::Manylinux {
+ major: 2,
+ minor: 39,
+ },
+ Arch::Riscv64,
+ ),
Self::Aarch64UnknownLinuxMusl => {
Platform::new(Os::Musllinux { major: 1, minor: 2 }, Arch::Aarch64)
}
@@ -483,6 +495,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "aarch64",
Self::Aarch64UnknownLinuxMusl => "aarch64",
Self::X8664UnknownLinuxMusl => "x86_64",
+ Self::Riscv64UnknownLinuxGnu => "riscv64",
Self::X8664Manylinux2014 => "x86_64",
Self::X8664Manylinux217 => "x86_64",
Self::X8664Manylinux228 => "x86_64",
@@ -525,6 +538,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "Linux",
Self::Aarch64UnknownLinuxMusl => "Linux",
Self::X8664UnknownLinuxMusl => "Linux",
+ Self::Riscv64UnknownLinuxGnu => "Linux",
Self::X8664Manylinux2014 => "Linux",
Self::X8664Manylinux217 => "Linux",
Self::X8664Manylinux228 => "Linux",
@@ -567,6 +581,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "",
Self::Aarch64UnknownLinuxMusl => "",
Self::X8664UnknownLinuxMusl => "",
+ Self::Riscv64UnknownLinuxGnu => "",
Self::X8664Manylinux2014 => "",
Self::X8664Manylinux217 => "",
Self::X8664Manylinux228 => "",
@@ -612,6 +627,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "",
Self::Aarch64UnknownLinuxMusl => "",
Self::X8664UnknownLinuxMusl => "",
+ Self::Riscv64UnknownLinuxGnu => "",
Self::X8664Manylinux2014 => "",
Self::X8664Manylinux217 => "",
Self::X8664Manylinux228 => "",
@@ -656,6 +672,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "posix",
Self::Aarch64UnknownLinuxMusl => "posix",
Self::X8664UnknownLinuxMusl => "posix",
+ Self::Riscv64UnknownLinuxGnu => "posix",
Self::X8664Manylinux2014 => "posix",
Self::X8664Manylinux217 => "posix",
Self::X8664Manylinux228 => "posix",
@@ -698,6 +715,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => "linux",
Self::Aarch64UnknownLinuxMusl => "linux",
Self::X8664UnknownLinuxMusl => "linux",
+ Self::Riscv64UnknownLinuxGnu => "linux",
Self::X8664Manylinux2014 => "linux",
Self::X8664Manylinux217 => "linux",
Self::X8664Manylinux228 => "linux",
@@ -740,6 +758,7 @@ impl TargetTriple {
Self::Aarch64UnknownLinuxGnu => true,
Self::Aarch64UnknownLinuxMusl => true,
Self::X8664UnknownLinuxMusl => true,
+ Self::Riscv64UnknownLinuxGnu => true,
Self::X8664Manylinux2014 => true,
Self::X8664Manylinux217 => true,
Self::X8664Manylinux228 => true,
diff --git a/docs/reference/cli.md b/docs/reference/cli.md
index ec8265f44..158f2cc1e 100644
--- a/docs/reference/cli.md
+++ b/docs/reference/cli.md
@@ -251,6 +251,7 @@ used.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -1243,6 +1244,7 @@ environment in the project.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -1843,6 +1845,7 @@ interpreter. Use --universal to display the tree for all platforms,
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -2167,6 +2170,7 @@ uv tool run [OPTIONS] [COMMAND]
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -2386,6 +2390,7 @@ uv tool install [OPTIONS]
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -2596,6 +2601,7 @@ Use with --all to apply to all tools.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -3834,6 +3840,7 @@ by --python-version.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -4105,6 +4112,7 @@ be used with caution, as it can modify the system Python installation.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -4394,6 +4402,7 @@ should be used with caution, as it can modify the system Python installation.aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
@@ -5023,6 +5032,7 @@ Python environment if no virtual environment is found.
aarch64-unknown-linux-gnu: An ARM64 Linux target. Equivalent to aarch64-manylinux_2_28
aarch64-unknown-linux-musl: An ARM64 Linux target
x86_64-unknown-linux-musl: An x86_64 Linux target
+riscv64-unknown-linux: A RISCV64 Linux target
x86_64-manylinux2014: An x86_64 target for the manylinux2014 platform. Equivalent to x86_64-manylinux_2_17
x86_64-manylinux_2_17: An x86_64 target for the manylinux_2_17 platform
x86_64-manylinux_2_28: An x86_64 target for the manylinux_2_28 platform
diff --git a/uv.schema.json b/uv.schema.json
index 4781a6a9a..655ce6a84 100644
--- a/uv.schema.json
+++ b/uv.schema.json
@@ -2291,6 +2291,11 @@
"type": "string",
"const": "x86_64-unknown-linux-musl"
},
+ {
+ "description": "A RISCV64 Linux target.",
+ "type": "string",
+ "const": "riscv64-unknown-linux"
+ },
{
"description": "An `x86_64` target for the `manylinux2014` platform. Equivalent to `x86_64-manylinux_2_17`.",
"type": "string",