Skip to content

Commit b4e5c31

Browse files
committed
remove dbg and fix
1 parent 66364dc commit b4e5c31

File tree

4 files changed

+8
-28
lines changed

4 files changed

+8
-28
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ thiserror = "2"
1818
async-trait = "0.1"
1919

2020
lazy_static = "1.5.0"
21-
async_py = { version = "0.2.0", default-features = false }
21+
async_py = { version = "0.2.1", default-features = false }
2222
tokio = { version = "1", features = ["full"] }
2323
serde_json = "1.0.136"
2424
dunce = "1.0.5"
@@ -28,7 +28,7 @@ tauri-plugin = { version = "2", features = ["build"] }
2828

2929
[features]
3030
venv = []
31-
default = ["venv", "rustpython"] # auto load src-python/.venv
31+
default = ["venv", "pyo3"] # auto load src-python/.venv
3232
# default = ["venv", "pyo3"] # enable to use pyo3 instead of rustpython.
3333
rustpython = ["async_py/rustpython"]
3434
pyo3 = ["async_py/pyo3"]
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
2-
[env]
3-
PYO3_CONFIG_FILE = { value = "target/pyembed/pyo3-build-config-file.txt", relative = true }

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ impl<R: Runtime, T: Manager<R> + Sync> crate::PythonExt<R> for T {
7676
.runner()
7777
.read_variable(&payload.python_function_call)
7878
.await?;
79-
dbg!(&_tmp);
8079
Ok(StringResponse { value: "Ok".into() })
8180
}
8281

@@ -93,7 +92,7 @@ impl<R: Runtime, T: Manager<R> + Sync> crate::PythonExt<R> for T {
9392
.call_function(&function_name, payload.args)
9493
.await?;
9594
Ok(StringResponse {
96-
value: py_res.to_string(),
95+
value: py_res.as_str().unwrap().to_string(),
9796
})
9897
}
9998

@@ -198,18 +197,15 @@ pub fn init_and_register<R: Runtime>(python_functions: Vec<&'static str>) -> Tau
198197
.run_file(main_py.as_path())
199198
.await
200199
.expect("ERROR: Error running 'src-tauri/main.py'");
201-
let functions = runner
202-
.read_variable("_tauri_plugin_functions")
203-
.await
204-
.unwrap_or_default()
205-
.as_str()
206-
.unwrap()
207-
.replace("'", "\""); // python arrays are serialized usings ' instead of "
208200
register_python_functions(
209201
app,
210202
python_functions.iter().map(|s| s.to_string()).collect(),
211203
).await;
212-
if let Ok(python_functions) = serde_json::from_str::<Vec<String>>(&functions) {
204+
let functions = runner
205+
.read_variable("_tauri_plugin_functions")
206+
.await
207+
.unwrap_or_default();
208+
if let Ok(python_functions) = serde_json::from_value(functions) {
213209
register_python_functions(app, python_functions).await;
214210
}
215211
});

src/models.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,6 @@ pub struct StringRequest {
1111
pub value: String,
1212
}
1313

14-
#[cfg(feature = "pyo3")]
15-
#[derive(Debug, Serialize, Deserialize, pyo3::IntoPyObject)]
16-
#[serde(untagged)]
17-
pub enum JsMany {
18-
Bool(bool),
19-
Number(u64),
20-
Float(f64),
21-
String(String),
22-
StringVec(Vec<String>),
23-
FloatVec(Vec<f64>),
24-
}
25-
26-
#[cfg(not(feature = "pyo3"))]
2714
use serde_json::Value as JsMany;
2815

2916
#[derive(Debug, Deserialize, Serialize)]

0 commit comments

Comments
 (0)