()
| 4 | }; |
| 5 | |
| 6 | pub fn main() { |
| 7 | let builder = rustpython::Interpreter::builder(Default::default()); |
| 8 | let def = rust_py_module::module_def(&builder.ctx); |
| 9 | let interp = builder.init_stdlib().add_native_module(def).build(); |
| 10 | |
| 11 | interp.enter(|vm| { |
| 12 | vm.insert_sys_path(vm.new_pyobj("examples")) |
| 13 | .expect("add path"); |
| 14 | |
| 15 | let module = vm.import("call_between_rust_and_python", 0).unwrap(); |
| 16 | let init_fn = module.get_attr("python_callback", vm).unwrap(); |
| 17 | init_fn.call((), vm).unwrap(); |
| 18 | |
| 19 | let take_string_fn = module.get_attr("take_string", vm).unwrap(); |
| 20 | take_string_fn |
| 21 | .call((String::from("Rust string sent to python"),), vm) |
| 22 | .unwrap(); |
| 23 | }) |
| 24 | } |
| 25 | |
| 26 | #[pymodule] |
| 27 | mod rust_py_module { |
nothing calls this directly
no test coverage detected