Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Load stdlib when calling Py_InitializeEx"
This reverts commit bccd38e.
  • Loading branch information
bschoenmaeckers committed May 6, 2026
commit 268856b7fab6ae804aa03c7d35802029a6cdc981
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion crates/capi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ rustpython-stdlib = {workspace = true, features = ["threading"] }

[dev-dependencies]
pyo3 = { version = "0.28", features = ["auto-initialize", "abi3"] }
rustpython-pylib = { workspace = true, features = ["freeze-stdlib"] }

[lints]
workspace = true

[package.metadata.cargo-shear]
# Not a direct dependency (yet), but we need to enable threading support in the stdlib.
ignored = ["rustpython-stdlib"]
22 changes: 2 additions & 20 deletions crates/capi/src/pylifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::pyerrors::init_exception_statics;
use crate::pystate::ensure_thread_has_vm_attached;
use core::ffi::c_int;
use rustpython_vm::vm::thread::ThreadedVirtualMachine;
use rustpython_vm::{Context, Interpreter, Settings};
use rustpython_vm::{Context, Interpreter};
use std::sync::Mutex;

pub(crate) static MAIN_INTERP: Mutex<Option<Interpreter>> = Mutex::new(None);
Expand Down Expand Up @@ -32,25 +32,7 @@ pub extern "C" fn Py_InitializeEx(_initsigs: c_int) {
if interp.is_none() {
// Safety: Interpreter was not initialized before, so we can safely assume the statics are not used
unsafe { init_exception_statics(&Context::genesis().exceptions) };

let settings = Settings::default();
let mut builder = Interpreter::builder(settings);

let defs = rustpython_stdlib::stdlib_module_defs(&builder.ctx);
builder = builder.add_native_modules(&defs);

#[cfg(test)]
{
use rustpython_vm::common::rc::PyRc;
builder = builder
.add_frozen_modules(rustpython_pylib::FROZEN_STDLIB)
.init_hook(|vm| {
let state = PyRc::get_mut(&mut vm.state).unwrap();
state.config.paths.stdlib_dir = Some(rustpython_pylib::LIB_PATH.to_owned());
});
}

*interp = Some(builder.build());
*interp = Interpreter::with_init(Default::default(), |_vm| {}).into();
drop(interp);
ensure_thread_has_vm_attached();
}
Expand Down
Loading