MADE RUST TRANSFER ARGS TO PYTHON LETS GOOOOOOOOOOOOOOOOOOOOOOO

This commit is contained in:
2025-02-07 17:40:16 +01:00
parent 8186e4e75f
commit 9425c2cccc
7 changed files with 23 additions and 20 deletions
+4 -7
View File
@@ -8,22 +8,18 @@ use pyo3::prelude::*;
use pyo3::types::PyList;
pub fn start() -> PyResult<()> {
pub fn start(args: Vec<String>) -> PyResult<()> {
rs_println!("Running Python program...");
let path = concat!(env!("CARGO_MANIFEST_DIR"), "\\src\\python");
let code = get_code(&(path.to_owned() + "\\main.py"));
let app_path = CString::new(code).unwrap();
let app_path = CString::new(format!("args = {:?}\n{}", args, code)).unwrap();
pyo3::prepare_freethreaded_python();
let from_python = Python::with_gil(|py| -> PyResult<Py<PyAny>> {
let syspath = py
.import("sys")?
.getattr("path")?
.downcast_into::<PyList>()?;
let syspath = py.import("sys")?.getattr("path")?.downcast_into::<PyList>()?;
syspath.insert(0, path)?;
let empty = CString::new("").unwrap();
@@ -38,6 +34,7 @@ pub fn start() -> PyResult<()> {
return Ok(());
}
fn get_code(path: &str) -> String {
return fs::read_to_string(path)
.expect("Failed to read Python file.")