You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Try to embed RustPython as a wasm component, but fail to build it on wasm32-wasip2 target.
Details
Environment
rust: 1.95.0-nightly (85eff7c80 2026-01-15)
RustPython: 2025-11-10-main-55
OS: Debian GNU/Linux 12
Reproduction
cargo build -r
Error goes as
error[E0425]: cannot find value `CLOCK_PROCESS_CPUTIME_ID`in crate `libc`
--> /root/.cargo/git/checkouts/rustpython-63090cdce5e18442/9792001/vm/src/stdlib/time.rs:432:42
|
432 |if libc::clock_gettime(libc::CLOCK_PROCESS_CPUTIME_ID, time.as_mut_ptr()) == -1 {
| ^^^^^^^^^^^^^^^^^^^^^^^^ not found in`libc`
For more information about this error, try `rustc --explain E0425`.
error: could not compile `rustpython-vm` (lib) due to 1 previous error
Related Code
lib.rs
#[cfg(target_arch = "wasm32")]mod wasm;#[cfg(target_arch = "wasm32")]pubuse wasm::*;use anyhow::Result;use rustpython_vm::{Interpreter,PyResult,VirtualMachine};/// Run Python code and return the result////// # Arguments/// * `code` - The Python code to execute////// # Returns/// The result of the Python code execution as a string////// # Errors/// Returns an error if the Python code execution failspubfnrun(code:&str) -> Result<String>{let interpreter = Interpreter::new_without_stdlib(None);let vm = &interpreter.vm;// Execute the Python code and get the resultlet result:PyResult = vm.run_code_string(code,"<embedded>".to_owned(),None);match result {Ok(value) => {// Convert the result to string representationlet str_value = value.to_repr(vm);Ok(str_value.to_string())}Err(e) => Err(anyhow::anyhow!("Python execution error: {}", e.to_string(vm))),}}
wasm.rs
mod bindgen {
wit_bindgen::generate!();usecrate::App;export!(App);}use bindgen::exports::sammyne::rust_python::api::Guest;pubstructApp;implGuestforApp{fnrun(code:String) -> Result<String,String>{crate::run(&code).map_err(|err| err.to_string())}}
Activity