Skip to content

Commit bda7c5c

Browse files
authored
Fix examples/package_embed (RustPython#5096)
1 parent 0e72ba8 commit bda7c5c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

examples/package_embed.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ use vm::{builtins::PyStrRef, Interpreter};
44

55
fn py_main(interp: &Interpreter) -> vm::PyResult<PyStrRef> {
66
interp.enter(|vm| {
7+
// Add local library path
78
vm.insert_sys_path(vm.new_pyobj("examples"))
8-
.expect("add path");
9+
.expect("add examples to sys.path failed");
910
let module = vm.import("package_embed", None, 0)?;
1011
let name_func = module.get_attr("context", vm)?;
1112
let result = name_func.call((), vm)?;
@@ -15,7 +16,10 @@ fn py_main(interp: &Interpreter) -> vm::PyResult<PyStrRef> {
1516
}
1617

1718
fn main() -> ExitCode {
18-
let interp = vm::Interpreter::with_init(Default::default(), |vm| {
19+
// Add standard library path
20+
let mut settings = vm::Settings::default();
21+
settings.path_list.push("Lib".to_owned());
22+
let interp = vm::Interpreter::with_init(settings, |vm| {
1923
vm.add_native_modules(rustpython_stdlib::get_module_inits());
2024
});
2125
let result = py_main(&interp);

0 commit comments

Comments
 (0)