(vm: &mut VirtualMachine)
| 13 | } |
| 14 | |
| 15 | pub(crate) fn init_importlib_base(vm: &mut VirtualMachine) -> PyResult<PyObjectRef> { |
| 16 | flame_guard!("init importlib"); |
| 17 | |
| 18 | // importlib_bootstrap needs these and it inlines checks to sys.modules before calling into |
| 19 | // import machinery, so this should bring some speedup |
| 20 | #[cfg(all(feature = "threading", not(target_os = "wasi")))] |
| 21 | import_builtin(vm, "_thread")?; |
| 22 | import_builtin(vm, "_warnings")?; |
| 23 | import_builtin(vm, "_weakref")?; |
| 24 | |
| 25 | let importlib = thread::enter_vm(vm, || { |
| 26 | let bootstrap = import_frozen(vm, "_frozen_importlib")?; |
| 27 | let install = bootstrap.get_attr("_install", vm)?; |
| 28 | let imp = import_builtin(vm, "_imp")?; |
| 29 | install.call((vm.sys_module.clone(), imp), vm)?; |
| 30 | Ok(bootstrap) |
| 31 | })?; |
| 32 | vm.import_func = importlib.get_attr(identifier!(vm, __import__), vm)?; |
| 33 | vm.importlib = importlib.clone(); |
| 34 | Ok(importlib) |
| 35 | } |
| 36 | |
| 37 | #[cfg(feature = "host_env")] |
| 38 | pub(crate) fn init_importlib_package(vm: &VirtualMachine, importlib: PyObjectRef) -> PyResult<()> { |
no test coverage detected