py-runner

Crates.iopy-runner
lib.rspy-runner
version0.1.0
created_at2025-05-26 15:46:00.415889+00
updated_at2025-05-26 15:46:00.415889+00
descriptionSimple tool that allows you to execute Python code from Rust.
homepage
repository
max_upload_size
id1689979
size15,899
(frederik-uni)

documentation

README

py-runner

Simple tool that allows you to execute Python code from Rust.

let x = execute_code("x = '10'", |_, globals| {
    globals.get_item("x")?.unwrap().extract::<String>()
}).unwrap();

let project1 = PythonModule::new_project(Path::new("./my-project/main.py").into()).unwrap();
let sum = project1.action(|_, module| module.call_method1("add", (1, 2))?.extract::<i64>()).unwrap();


let module1 = PythonModule::new_module(Path::new("./my-module")).unwrap();
let sum = module1.action(|_, module| module.call_method1("add", (1, 2))?.extract::<i64>()).unwrap();
Commit count: 0

cargo fmt