indygreg / indygreg/PyOxidizer
pyoxidizer 0.17 init-rust-project builds but fails with cargo.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
On ubuntu 20.04 :
```
pyoxidizer --version
PyOxidizer 0.17.0
commit: unknown
source: https://github.com/indygreg/PyOxidizer.git
pyembed crate location: version = "0.17.0"
~/test/testpyo$ pyoxidizer init-rust-project testpyo
```
works ok with pyoxidizer run. but fails with cargo run
```
~/test/testpyo$ cargo run --features allocator-jemalloc
Compiling fs_extra v1.2.0
Compiling pyembed v0.17.0
Compiling testpyo v0.1.0 (/home/julien/test/testpyo)
Compiling jemalloc-sys v0.3.2
Finished dev [unoptimized + debuginfo] target(s) in 58.66s
Running `target/debug/testpyo`
SystemError: null argument to internal routine
Fatal Python error: init_importlib_external: external importer setup failed
Python runtime state: core initialized
Current thread 0x00007fcaa90c4000 (most recent call first):
```
Reading the doc, I discovered that setting the same python that the one fetched by pyoxidizer could help :
```
cargo clean
$ PYTHON_SYS_EXECUTABLE=/home/julien/test/testpyo/python/python/install/bin/python3 cargo run --features allocator-jemalloc
Compiling python3-sys v0.6.0
Compiling pyembed v0.17.0
Compiling cpython v0.6.0
Compiling testpyo v0.1.0 (/home/julien/test/testpyo)
Finished dev [unoptimized + debuginfo] target(s) in 11.48s
Running `target/debug/testpyo`
Python path configuration:
PYTHONHOME = '/home/julien/test/testpyo/target/debug'
PYTHONPATH = (not set)
program name = '/home/julien/test/testpyo/target/debug/testpyo'
isolated = 1
environment = 0
user site = 0
import site = 1
sys._base_executable = '/home/julien/test/testpyo/target/debug/testpyo'
sys.base_prefix = '/home/julien/test/testpyo/target/debug'
sys.base_exec_prefix = '/home/julien/test/testpyo/target/debug'
sys.platlibdir = 'lib'
sys.executable = '/home/julien/test/testpyo/target/debug/testpyo'
sys.prefix = '/home/julien/test/testpyo/target/debug'
sys.exec_prefix = '/home/julien/test/testpyo/target/debug'
sys.path = [
'/home/julien/test/testpyo/target/debug/lib/python39.zip',
'/home/julien/test/testpyo/target/debug/lib/python3.9',
'/home/julien/test/testpyo/target/debug/lib/python3.9/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007fbf4f445000 (most recent call first):
File "", line 228 in _call_with_frames_removed
File "", line 763 in create_module
File "", line 565 in module_from_spec
File "", line 666 in _load_unlocked
File "", line 986 in _find_and_load_unlocked
File "", line 1007 in _find_and_load
```
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the issue from the init-rust-project entry point on Ubuntu 20.04 by comparing pyoxidizer run with cargo run --features allocator-jemalloc, including the PYTHON_SYS_EXECUTABLE variant. Trace the generated project's Python embedding and startup paths; done means the generated project builds and runs correctly with cargo, and its src/main.rs behavior is respected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100