PyOxidizer
PyOxidizer copied to clipboard
Avoid conflict in program arguments
I am working with pyembed to embed a python kernel and using default python config for the kernel. however, i can see that there is an issue when im trying to pass args to my program to start. error is:
Try `python -h' for more information.
Error: during initializing Python core: could not format PyStatus
any ideas?
Also, when running cargo test -- --nocapture
, im getting:
unknown option --nocapture
Dynamic("during initializing Python core: could not format PyStatus")'
without -- --nocapture
, my tests run fine.
That during initializing Python core: could not format PyStatus
error occurs when Py_InitializeFromConfig()
errors and the resulting PyStatus
doesn't have an annotated function name or message. That's a bit weird, as I thought CPython would always set these fields to help debugging.
Do you know what Python interpreter/library you are linking against to reproduce this?
Here is a minimal reproducible example:
// lib.rs
include!("../kernel_artifacts/default_python_config.rs");
use std::io::{Error, ErrorKind};
use pyembed::MainPythonInterpreter;
pub struct PythonEnv <'a, 'b>{
interpreter: Option<MainPythonInterpreter<'a, 'b>>,
}
impl <'a, 'b>PythonEnv <'a, 'b>{
pub fn new() -> Result<Self, Error> {
let config = default_python_config();
let interpreter = MainPythonInterpreter::new(config).unwrap();
Ok(PythonEnv { interpreter: Some(interpreter) })
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_foo(){
let a = PythonEnv::new().unwrap();
}
}
Run:
PYO3_CONFIG_FILE=./kernel_artifacts/pyo3-build-config-file.txt cargo test -- --nocapture
i have tested this with py38 and py39 both on mac and linux. - same error everywhere.
any hope for this?
You'd have to give me steps to reproduce, including how you generated the kernel_artifacts
directory. Could you provide a Dockerfile
or a shell script to run inside a base Docker image to run that can reproduce?
Do you have any PYTHON*
environment variables that may be influencing behavior of the embedded interpreter?
I can reproduce this with (PyOxy 0.2.0 x64 linux) with pyoxy run-python -- --version
It'll print the Python version then croak with:
error: Error {
context: "initializing Python interpreter",
source: Dynamic(
"during initializing Python core: could not format PyStatus",
),
}