From 3942a08e0c2d4a6376649908153c55beb5d7f09b Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Thu, 9 Feb 2023 21:31:32 +0900 Subject: [PATCH] Simplify examples/call_between_rust_and_python --- examples/call_between_rust_and_python.rs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/call_between_rust_and_python.rs b/examples/call_between_rust_and_python.rs index be93fb971..591304228 100644 --- a/examples/call_between_rust_and_python.rs +++ b/examples/call_between_rust_and_python.rs @@ -1,14 +1,17 @@ -use rustpython_vm::{ +use rustpython::vm::{ pyclass, pymodule, PyObject, PyPayload, PyResult, TryFromBorrowedObject, VirtualMachine, }; -pub(crate) use rust_py_module::make_module; - pub fn main() { - let interp = rustpython_vm::Interpreter::with_init(Default::default(), |vm| { - vm.add_native_modules(rustpython_stdlib::get_module_inits()); - vm.add_native_module("rust_py_module".to_owned(), Box::new(make_module)); - }); + let interp = rustpython::InterpreterConfig::new() + .init_stdlib() + .init_hook(Box::new(|vm| { + vm.add_native_module( + "rust_py_module".to_owned(), + Box::new(rust_py_module::make_module), + ); + })) + .interpreter(); interp.enter(|vm| { vm.insert_sys_path(vm.new_pyobj("examples")) @@ -30,7 +33,7 @@ pub fn main() { #[pymodule] mod rust_py_module { use super::*; - use rustpython_vm::{builtins::PyList, convert::ToPyObject, PyObjectRef}; + use rustpython::vm::{builtins::PyList, convert::ToPyObject, PyObjectRef}; #[pyfunction] fn rust_function(