mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Fix examples/package_embed (#5096)
This commit is contained in:
@@ -4,8 +4,9 @@ use vm::{builtins::PyStrRef, Interpreter};
|
||||
|
||||
fn py_main(interp: &Interpreter) -> vm::PyResult<PyStrRef> {
|
||||
interp.enter(|vm| {
|
||||
// Add local library path
|
||||
vm.insert_sys_path(vm.new_pyobj("examples"))
|
||||
.expect("add path");
|
||||
.expect("add examples to sys.path failed");
|
||||
let module = vm.import("package_embed", None, 0)?;
|
||||
let name_func = module.get_attr("context", vm)?;
|
||||
let result = name_func.call((), vm)?;
|
||||
@@ -15,7 +16,10 @@ fn py_main(interp: &Interpreter) -> vm::PyResult<PyStrRef> {
|
||||
}
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let interp = vm::Interpreter::with_init(Default::default(), |vm| {
|
||||
// Add standard library path
|
||||
let mut settings = vm::Settings::default();
|
||||
settings.path_list.push("Lib".to_owned());
|
||||
let interp = vm::Interpreter::with_init(settings, |vm| {
|
||||
vm.add_native_modules(rustpython_stdlib::get_module_inits());
|
||||
});
|
||||
let result = py_main(&interp);
|
||||
|
||||
Reference in New Issue
Block a user