indygreg / indygreg/PyOxidizer
pyoxidizer init-rust-project does not works as documented
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
pyoxidizer init-rust-project pyapp
I then modified src/main.rs :
#![windows_subsystem = "console"]
use pyembed::MainPythonInterpreter;
// Include an auto-generated file containing the default
// pyembed::OxidizedPythonInterpreterConfig derived by the PyOxidizer
// configuration file.
//
// If you do not want to use PyOxidizer to generate this file, simply
// remove this line and instantiate your own instance of
// pyembed::OxidizedPythonInterpreterConfig.
include!(env!("PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS"));
fn main() {
// The following code is in a block so the MainPythonInterpreter is destroyed in an
// orderly manner, before process exit.
let code = {
// Load the default Python configuration as derived by the PyOxidizer config
// file used at build time.
let config = default_python_config();
// Construct a new Python interpreter using that config, handling any errors
// from construction.
match MainPythonInterpreter::new(config) {
Ok(mut interp) => {
// And run it using the default run configuration as specified by the
// configuration. If an uncaught Python exception is raised, handle it.
// This includes the special SystemExit, which is a request to terminate the
// process.
// interp.run_as_main()
let py = interp.acquire_gil().unwrap();
match py.eval( "print('hello, world')", None, None) {
Ok(_) => println!("python code executed successfully"),
Err(e) => println!("python error: {:?}", e),
}
0
}
Err(msg) => {
eprintln!("{}", msg);
1
}
}
};
// And exit the process according to code execution results.
std::process::exit(code);
}
but when running
pyoxidizer run
I get the same python REPL as without modification !
And also,
cargo run --features jemalloc build-mode-pyoxidizer-exe
fail with
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'
That may be normal, but nothing tell me why in the doc.
I'm using ubuntu 20.04 and rust/cargo 1.47
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the documented pyoxidizer init-rust-project pyapp flow, then inspect the generated src/main.rs and compare pyoxidizer run with the modified entry point. Also run cargo run --features jemalloc build-mode-pyoxidizer-exe and investigate the reported encodings failure. Done means the documented project behavior and error explanation are corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- build-system, cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100