feat(python): add Pyodide/Emscripten (wasm32) wheel#1811
Open
chaliy wants to merge 1 commit into
Open
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | c431bd1 | Commit Preview URL Branch Preview URL |
May 31 2026, 02:12 AM |
8cc7b33 to
ac3989b
Compare
Ship a reduced-feature `wasm32-unknown-emscripten` wheel so bashkit runs in the browser / JupyterLite via Pyodide. Mirrors the Rust+maturin+PyO3 recipe from pydantic's emscripten-wheels writeup. Pyodide is single-threaded with no sockets or host FS, so several deps hard-fail to compile on wasm (mio/reqwest, tokio rt-multi-thread for turso+sqlite, tokio::fs for realfs, pyo3-async-runtimes). Split bashkit-python deps per target: native keeps the full feature set; wasm builds scripted_tool+python+jq only. Gate the unbuildable surfaces behind cfg(not(target_arch = "wasm32")): the async execute() family, network/credential config, host mounts, sqlite, the capsule interop bridge, and external_handler. wasm exposes execute_sync() plus sync/async custom-builtin callbacks via the private-loop fallback. Unavailable config kwargs raise RuntimeError instead of silently no-opping. CI: add a wasm build+smoke-test job to python.yml (wired into the gate) and a build-emscripten publish job to publish-python.yml. Both use nightly Rust (Pyodide passes -Z link-native-libraries=no) and link at -O1 to skip emcc's binaryen pass (flag skew in some emsdk 3.1.46 snapshots). See specs/emscripten-wheels.md.
ac3989b to
c431bd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ship a reduced-feature
wasm32-unknown-emscripten(Pyodide) Python wheel sobashkitruns in the browser / JupyterLite / other WASM hosts, alongside the existing native wheels. Mirrors the Rust + maturin + PyO3 recipe from pydantic's emscripten-wheels writeup.Why
Pyodide is single-threaded with no sockets and no host filesystem. Several core deps hard-
compile_error!on emscripten (mio/reqwest, tokiort-multi-threadfor turso/sqlite,tokio::fsfor realfs,pyo3-async-runtimes). The corebashkitcrate was already wasm-aware; the work is confined tocrates/bashkit-pythonplus two small core wasm-cleanliness fixes.How
bashkit-pythondeps per target. Native keeps the full feature set;wasm32buildsscripted_tool + python + jqonly, on wasm-safe tokio base features, withoutpyo3-async-runtimes.#[cfg(not(target_arch = "wasm32"))]gates the asyncexecute()family, network/credential config, host mounts, sqlite, the capsule interop bridge, andexternal_handler. WASM exposesexecute_sync()plus sync/async custom-builtin callbacks via the private-loop fallback. Unavailable config kwargs raiseRuntimeErrorinstead of silently no-opping.CallerLoopLocalsaliasesTaskLocals(native) /Infallible(wasm) so caller-loop branches are statically dead on wasm.SPAWN_BLOCKING_THRESHOLD,execution_timeout) so the wasm build is warning-clean underclippy -D warnings.python.ymlgets awasmjob (build + Pyodide-venv smoke test, wired into thepython-checkgate);publish-python.ymlgets abuild-emscriptenjob feedinginspect→publish. Both use nightly Rust (Pyodide passes-Z link-native-libraries=no) and link at-O1to skip emcc's binaryen pass (flag skew in some emsdk 3.1.46 snapshots).specs/emscripten-wheels.md(feature matrix, toolchain, gotchas); updates topython-package.md,release-process.md,AGENTS.md.Tests verified
bashkit-0.8.0-cp311-cp311-emscripten_3_1_46_wasm32.whl(contains the Emscripten-compiled.so, correctly tagged).ssh_supabase_connects, a live-network test against an external host unreachable from the build sandbox (unrelated — diff touches no SSH code).bashkit_random_fsfixture crate built separately in CI).cargo fmt,clippy(native + wasm,-D warnings),ruff check/formatall clean.See
specs/emscripten-wheels.md.Generated by Claude Code