We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent0e72ba8 commitbda7c5cCopy full SHA for bda7c5c
examples/package_embed.rs
@@ -4,8 +4,9 @@ use vm::{builtins::PyStrRef, Interpreter};
4
5
fnpy_main(interp:&Interpreter) -> vm::PyResult<PyStrRef>{
6
interp.enter(|vm|{
7
+// Add local library path
8
vm.insert_sys_path(vm.new_pyobj("examples"))
-.expect("add path");
9
+.expect("addexamples to sys.path failed");
10
let module = vm.import("package_embed",None,0)?;
11
let name_func = module.get_attr("context", vm)?;
12
let result = name_func.call((), vm)?;
@@ -15,7 +16,10 @@ fn py_main(interp: &Interpreter) -> vm::PyResult<PyStrRef> {
15
16
}
17
18
fnmain() ->ExitCode{
-let interp = vm::Interpreter::with_init(Default::default(), |vm|{
19
+// Add standard library path
20
+letmut settings = vm::Settings::default();
21
+ settings.path_list.push("Lib".to_owned());
22
+let interp = vm::Interpreter::with_init(settings, |vm|{
23
vm.add_native_modules(rustpython_stdlib::get_module_inits());
24
});
25
let result =py_main(&interp);