Open pingiun opened 2 years ago
So I think this would require a complete alternative implementation of the pyo3-ffi
crate which is able to lazily load the symbols it needed. I'm not against having this, however it's too niche a use-case for me to do this. It could be a feature, I think it'd be a lot of work though tbh.
An alternative could be to build your own .so
which implements the Python plugin engine (and uses PyO3's existing link model), and then your binary could dynamically load that .so
if a Python plugin is requested.
I want to optionally allow python plugins for my project. It would be nice if PyO3 could be configured such that python isn't linked at compile time and instead the
.so
is loaded dynamically at runtime and symbols are also loaded dynamically.An alternative would be to statically link python to my project so that it's always available but that would drastically increase my binary size.
I believe this can be implemented using the
libloading
crate, maybe macros can be used in some way to convert the extern "C" blocks into dynamic symbol lookups? I'm not too familiar with macros, so I cannot say for sure.