Open
Description
I've been playing with the idea of being able to build a module/extension in Rust that plugs in to RustPython, and I think I've come up with a pretty decent way of doing it. I've drawn some inspiration/learned about Rust dynamic loading from this ffi guide.
- Add
libloading
as a dependency. - Add a field to
VirtualMachine
that's aVec
oflibloading::Library
s. - In the module resolution process, check if there's a
*.so
or*.dll
on thePYTHONPATH
, maybe have a specific prefix or suffix to designate that it's specifically a RustPython extension. - Load that library and store it in the
Vec<Library>
, and then load a fn from there with a name likerustpython_init_module
and a signature along the lines oftype ExtensionInitFn = unsafe extern fn(vm: &mut VirtualMachine);
- Call that
ExtensionInitFn
.
I think it's pretty straightforward, but does anyone have any ideas for the parts that could be filled in, e.g. resolution along the PYTHONPATH
?
Metadata
Metadata
Assignees
Labels
About RustPython's own implementationAbout RustPython's own implementationNew feature or requestNew feature or request