Skip to content

Commit 242416b

Browse files
ffganmessense
andauthored
Add support for RISC-V architecture in manylinux and update compatibi… (#2694)
Recently, pypi has just provided support for riscv wheel uploads. For details, please see pypi/warehouse#18390 Here you can see that test.pypi.org has deployed support, https://github.com/pypi/warehouse/deployments/test.pypi.org I think maturin-action can also provide support for this, mainly by setting manylinux_2_39 as the default and supported version of riscv64, so that riscv64 packages that can be uploaded to pypi can be packaged Here are the results of my github action run, CI result: [release](https://github.com/ffgan/maturin/actions/runs/16551719275) [test](https://github.com/ffgan/maturin/actions/runs/16551720338) The results show that riscv64 runs well **Other Info** Co-authored-by: @kotvaer Co-authored-by: [email protected]; --------- Co-authored-by: messense <[email protected]>
1 parent f18f776 commit 242416b

File tree

5 files changed

+26
-16
lines changed

5 files changed

+26
-16
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ jobs:
168168
- target: "loongarch64-unknown-linux-gnu"
169169
image: "manylinux_2_36-cross:loongarch64"
170170
compatibility: "manylinux_2_36"
171+
- target: "riscv64gc-unknown-linux-gnu"
172+
image: "manylinux_2_39-cross:riscv64"
173+
compatibility: "manylinux_2_39"
171174
container:
172175
image: docker://ghcr.io/rust-cross/${{ matrix.platform.image }}
173176
env:
@@ -178,9 +181,9 @@ jobs:
178181
- uses: actions/checkout@v4
179182
# powerpc64le-unknown-linux-musl doesn't have official std library release
180183
- run: rustup target add --toolchain stable ${{ matrix.platform.target }}
181-
if: ${{ !contains(fromJson('["powerpc64le-unknown-linux-musl", "s390x-unknown-linux-gnu", "loongarch64-unknown-linux-gnu"]'), matrix.platform.target) }}
184+
if: ${{ !contains(fromJson('["powerpc64le-unknown-linux-musl", "s390x-unknown-linux-gnu", "loongarch64-unknown-linux-gnu", "riscv64gc-unknown-linux-gnu"]'), matrix.platform.target) }}
182185
- uses: dtolnay/rust-toolchain@stable
183-
if: contains(fromJson('["s390x-unknown-linux-gnu", "loongarch64-unknown-linux-gnu"]'), matrix.platform.target)
186+
if: contains(fromJson('["s390x-unknown-linux-gnu", "loongarch64-unknown-linux-gnu", "riscv64gc-unknown-linux-gnu"]'), matrix.platform.target)
184187
with:
185188
targets: ${{ matrix.platform.target }}
186189
- name: Build wheel

.github/workflows/test.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,11 @@ jobs:
389389
abi: cp310-cp310
390390
python: python3.10
391391
container: ghcr.io/rust-cross/manylinux_2_36-cross:loongarch64
392+
- target: riscv64gc-unknown-linux-gnu
393+
abi: cp310-cp310
394+
python: python3.10
395+
container: ghcr.io/rust-cross/manylinux_2_39-cross:riscv64
396+
extra-args: --manylinux 2_39
392397
# PyPy
393398
- target: aarch64-unknown-linux-gnu
394399
abi: pp310-pypy310_pp73
@@ -408,18 +413,18 @@ jobs:
408413
run: |
409414
set -ex
410415
# Use bundled sysconfig
411-
bin/maturin build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml
416+
bin/maturin build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml ${{ matrix.platform.extra-args }}
412417
413418
# Use PYO3_CROSS_LIB_DIR
414419
export PYO3_CROSS_LIB_DIR=/opt/python/${{ matrix.platform.abi }}
415-
bin/maturin build -i python3.9 --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml
420+
bin/maturin build -i python3.9 --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml ${{ matrix.platform.extra-args }}
416421
unset PYO3_CROSS_LIB_DIR
417422
418423
# Test abi3
419-
bin/maturin build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-pure/Cargo.toml
424+
bin/maturin build -i ${{ matrix.platform.python }} --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-pure/Cargo.toml ${{ matrix.platform.extra-args }}
420425
421426
# --find-interpreter
422-
bin/maturin build --find-interpreter --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml
427+
bin/maturin build --find-interpreter --release --out dist --target ${{ matrix.platform.target }} -m test-crates/pyo3-mixed/Cargo.toml ${{ matrix.platform.extra-args }}
423428
424429
test-bootstrap:
425430
name: Test Bootstrap

src/target/legacy_py.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub(super) static IOS_ARCHES: &[&str] = &["arm64", "x86_64"];
5757
pub(super) static ANDROID_ARCHES: &[&str] = &["armeabi_v7a", "arm64_v8a", "x86", "x86_64"];
5858

5959
pub(super) static MANYLINUX_ARCHES: &[&str] = &[
60-
"x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x", "ppc64",
60+
"x86_64", "i686", "aarch64", "armv7l", "ppc64le", "s390x", "ppc64", "riscv64",
6161
];
6262

6363
pub(super) static MUSLLINUX_ARCHES: &[&str] =

src/target/pypi_tags.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pub fn is_arch_supported_by_pypi(target: &Target) -> bool {
7878
/// Validates that a wheel platform tag is allowed by PyPI.
7979
///
8080
/// Based on PyPI warehouse platform tag validation logic.
81+
///
8182
fn is_platform_tag_allowed_by_pypi(platform_tag: &str) -> bool {
8283
// Covers old Windows and old manylinux tags.
8384
if ALLOWED_PLATFORMS.contains(&platform_tag) {
@@ -170,7 +171,8 @@ mod tests {
170171
// manylinux platforms
171172
("manylinux2014_x86_64", true),
172173
("manylinux_2_17_aarch64", true),
173-
("manylinux_2_17_riscv64", false),
174+
("manylinux_2_17_riscv64", true),
175+
("manylinux_2_39_riscv64", true),
174176
// musllinux platforms
175177
("musllinux_1_1_x86_64", true),
176178
("musllinux_1_1_riscv64", false),
@@ -222,12 +224,12 @@ mod tests {
222224
("x86_64-unknown-linux-gnu", true),
223225
("aarch64-linux-android", true),
224226
("armv7-linux-androideabi", true),
225-
("riscv64gc-unknown-linux-gnu", false), // Unsupported
226-
("x86_64-unknown-freebsd", false), // Now unsupported (no lazy validation)
227-
("powerpc64-unknown-linux-gnu", true), // PPC64 on Linux is supported
228-
("s390x-unknown-linux-gnu", true), // s390x on Linux is supported
229-
("wasm32-unknown-emscripten", false), // Emscripten is unsupported
230-
("i686-pc-windows-msvc", true), // i686 Windows is supported
227+
("riscv64gc-unknown-linux-gnu", true),
228+
("x86_64-unknown-freebsd", false), // Now unsupported (no lazy validation)
229+
("powerpc64-unknown-linux-gnu", true), // PPC64 on Linux is supported
230+
("s390x-unknown-linux-gnu", true), // s390x on Linux is supported
231+
("wasm32-unknown-emscripten", false), // Emscripten is unsupported
232+
("i686-pc-windows-msvc", true), // i686 Windows is supported
231233
];
232234

233235
for (triple, expected) in targets {

tests/common/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn pypi_compatibility_unsupported_target() -> Result<()> {
158158
"--compatibility",
159159
"pypi",
160160
"--target",
161-
"riscv64gc-unknown-linux-gnu", // Unsupported by PyPI
161+
"riscv32gc-unknown-linux-gnu", // Unsupported by PyPI
162162
"--target-dir",
163163
"test-crates/targets/pypi_compatibility_unsupported_target",
164164
"--out",
@@ -178,7 +178,7 @@ pub fn pypi_compatibility_unsupported_target() -> Result<()> {
178178
let err_string = err.to_string();
179179
assert!(
180180
err_string.contains(
181-
"Target riscv64gc-unknown-linux-gnu architecture is not supported by PyPI"
181+
"Target riscv32gc-unknown-linux-gnu architecture is not supported by PyPI"
182182
),
183183
"{err_string}",
184184
);

0 commit comments

Comments
 (0)