Emit a WASI platform tag for non-bin extension wheels #3321
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 447 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.365
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3321"
general
weight: 0.35
messense
Problem
maturin build --target wasm32-wasip1tags every WASI wheelany, regardless of binding type. That's correct forbindings = "bin"(a.wasmbinary behind a wasmtime launcher, genuinely host-portable, added in #1107), but wrong for PyO3/cffi/uniffi bindings: those compile straight to a.wasmextension module that only a WASI-capable Python build can load. The wasi-wheels project already works around this by manually retagging its built wheels fromanytowasi_0_0_0_wasm32after the fact.As noted in the March 2026 status update on this issue, the actual loadability gap (no
dlopenon WASI) is a CPython/WASI platform limitation outside maturin's reach. This PR addresses the one piece that is reachable from maturin: giving the wheel the tag it should have had in the first place, so downstream tooling doesn't need the manual retag step.Fix
ProjectContext::get_platform_tagalready has the bridge model in scope at its one call intotarget::get_platform_tag, so this threads anis_bin: boolthrough that single call site instead of adding a parallel dispatch path. The existing(Os::Wasi, Arch::Wasm32)arm now calls a newwasi_platform_tag(is_bin)helper:anyfor bin bindings (unchanged),wasi_0_0_0_wasm32otherwise. That tag mirrors CPython's ownsysconfig.get_platform()fallback behavior on WASI (no WASI special-case there either, so it falls back toos.uname(), which reportssysname=wasi,release=0.0.0,machine=wasm32) and matches what wasi-wheels already retags to by hand. There's no PEP defining a WASI wheel tag yet (unlike Emscripten's PEP 783), so this follows existing real-world convention rather than a ratified spec.Both
wasm32-wasip1andwasm32-wasip2resolve to the same internalOs::Wasiand get the same treatment; CPython's own WASI support (per PEP 816) is wasip1 only today, so a wasip2 extension wheel has no consumer yet — a known limitation, not something this PR tries to solve by splitting theOsenum.This is a behavior change for non-bin WASI wheels: anyone currently installing one with only
--platform anywill need to add--platform wasi_0_0_0_wasm32(wasi-wheels' own install instructions already pass both).--compatibility pypivalidation is unaffected either way, since it already bails out for any WASI target viais_arch_supported_by_pypi.Background: I ship both maturin/PyO3 wheels and separate wasm32 (wasm-bindgen, wasm32-unknown-unknown) builds from the same Rust crates across several of my own crates, which is what pointed me at this specific gap in the tag dispatch rather than the broader (and currently unsolvable) extension-loading problem.
Testing
cargo test --lib target::platform_tag(includes the two new tests below): passcargo clippy --tests --all-features -- -D warnings: passcargo fmt --all -- --check: passAdded
test_wasi_platform_tag(the bin/non-bin branch in isolation) andtest_get_platform_tag_wasi(the full dispatch for bothwasm32-wasip1andwasm32-wasip2), following the existing pure-function test style in this module (e.g.test_pep783_emscripten_platform_tag) rather than requiring a WASI toolchain. I did not run theintegration_wasm_hello_worldend-to-end test locally — wasmtime isn't installed in my environment — but it's unaffected by this change (test-crates/hello-worldusesbindings = "bin", which keeps theanytag), and CI will cover it.Addresses #2338.