Open julienfr112 opened 3 years ago
I solved the problem, but not easy at all, and mostly undocumented. (I had to look at pyoxidizer src ...)
=> add "cpython-link-default" to default feature ( not documented ) => add "allocator-jemalloc" to default feature ( was in the error message) => add PYTHON_SYS_EXECUTABLE=... as documented in https://pyoxidizer.readthedocs.io/en/latest/pyoxidizer_rust_cargo_source_checkouts.html
I can make an Pull requests witch customize init-rust-project's cargo.toml with
default = ["build-mode-pyoxidizer-exe", "allocator-jemalloc", "cpython-link-default"]
would you be interested in merging this Pull Requests ?
I discovered the same thing, pyoxidizer run
does not even read src/main.rs
and local buld.rs
. The only way that it seems we can embed python in our rust project is by building with cargo
. I filed this issue #439 in relation to that problem.
I was getting the exact error you got, and thanks to your help, by adding in default
in Cargo.toml
i was able to get rid of that error. But now i am getting different error:
It's unable to find my python module: test.py
in project root
No module named test
Solved it. Had to input the correct path in pyoxidizer.bzl in
exe.add_python_resources(
exe.read_package_root(
path=<fullpath>,
packages=["test"]))
Thanks @julienfr112.
On ubuntu 20.04 :
works ok with pyoxidizer run. but fails with cargo run
Reading the doc, I discovered that setting the same python that the one fetched by pyoxidizer could help :
but it fails with another error.
Idem on Mac Os ( mac mini A1), but with the encoding error
I'm really not sure if it should work or not, but I find it the only way to have a rust project that embed a python interpreter. As everything is quite complicated ( pyembed is calling pyoxidier, or the revese, or both ... ) , and the doc is still work in progress, I think the init-rust-project should work out of box with cargo.
On top of that, pyoxidier run does not seems to care at all about the src/main.rs, and just lauching a python exe.