How to properly embed Python libraries/modules with embedded RustPython? #4407
Unanswered
Rafael-Conde
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I didn't put it in the title because I thought I might be wrong, but I think that the way to do it is to freeze the dependencies, as described in the readme:
that's in the section directed to the building the WASI file, but I believe it might work for non-wasm targets. I'm trying to embed RustPython into my application and I'm currently just writing tests and simples examples to get the hang of the library. In my application, I intend to use sympy, so I tried to write a example on how I could achieve it. it compiles fine, but when I run the executable I get an exception saying that there is no sympy module.
In this example I tried to freeze the Python dependencies with the intention to embed them into the binary too but I might be doing it wrong or maybe this isn't supposed to be used this way.
The example application I basically copied the hello_embed.rs example and made some modifications.
Here is the source code:
and this is the error I get when I try to run this:
which is basically saying there is no sympy module but as I understood, there should be an embedded one.
Another thing that might be important is that I got the source code for those libraries from the pip installation, I simply copied pasted the folder of the library into the folders described in the `init_vm´ function I defined. I figured this could work since I saw this comment, but that's also targeted at wasm.
Can you guys help me or point me towards possible sources of this problem?
my thoughts on this is:
vm.add_frozen(rustpython_vm::py_freeze!(dir = "deps"));
but it didn't work as well.Edit: I also tried to set RUSTPYTHONPATH, but it didn't work, I believe this is expected becauce RustPython is embedded in the application.
I also forgot, but thanks for this amazing project, the API is clean and comprehensive! congrats!🚀🚀🚀🦀🦀🦀
Beta Was this translation helpful? Give feedback.
All reactions