File tree Expand file tree Collapse file tree 4 files changed +8
-28
lines changed
examples/plain-javascript/src-tauri/.cargo Expand file tree Collapse file tree 4 files changed +8
-28
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ thiserror = "2"
1818async-trait = " 0.1"
1919
2020lazy_static = " 1.5.0"
21- async_py = { version = " 0.2.0 " , default-features = false }
21+ async_py = { version = " 0.2.1 " , default-features = false }
2222tokio = { version = " 1" , features = [" full" ] }
2323serde_json = " 1.0.136"
2424dunce = " 1.0.5"
@@ -28,7 +28,7 @@ tauri-plugin = { version = "2", features = ["build"] }
2828
2929[features ]
3030venv = []
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.
3333rustpython = [" async_py/rustpython" ]
3434pyo3 = [" async_py/pyo3" ]
Original file line number Diff line number Diff line change 1-
2- [env ]
3- PYO3_CONFIG_FILE = { value = " target/pyembed/pyo3-build-config-file.txt" , relative = true }
Original file line number Diff line number Diff 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 } ) ;
Original file line number Diff line number Diff 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" ) ) ]
2714use serde_json:: Value as JsMany ;
2815
2916#[ derive( Debug , Deserialize , Serialize ) ]
You can’t perform that action at this time.
0 commit comments