File tree Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Expand file tree Collapse file tree 3 files changed +18
-12
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " tauri-plugin-python"
3- version = " 0.3.3 "
3+ version = " 0.3.4 "
44authors = [ " Marco Mengelkoch" ]
55description = " A tauri 2 plugin to use python code in the backend."
66keywords = [" rust" , " python" , " tauri" , " gui" ]
@@ -31,5 +31,7 @@ serde_json = "1.0.136"
3131tauri-plugin = { version = " 2" , features = [" build" ] }
3232
3333[features ]
34- # default = ["pyo3"] # enable to use pyo3 instead of rustpython
34+ venv = []
35+ default = [" venv" ] # auto load src-python/.venv
36+ # default = ["venv", "pyo3"] # enable to use pyo3 instead of rustpython
3537pyo3 = [" dep:pyo3" ]
Original file line number Diff line number Diff line change 11{
22 "name" : " tauri-plugin-python-api" ,
3- "version" : " 0.3.3 " ,
3+ "version" : " 0.3.4 " ,
44 "author" : " Marco Mengelkoch" ,
55 "description" : " Javascript package for tauri 2 python plugin." ,
66 "type" : " module" ,
Original file line number Diff line number Diff line change @@ -80,16 +80,20 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
8080}
8181
8282fn init_python ( code : String , dir : PathBuf ) {
83+ #[ allow( unused_mut) ]
8384 let mut sys_pyth_dir = format ! ( "sys.path.append('{}')" , dir. to_str( ) . unwrap( ) ) ;
84- let venv_dir = dir. join ( ".venv" ) . join ( "lib" ) ;
85- if Path :: exists ( venv_dir. as_path ( ) ) {
86- if let Ok ( py_dir) = venv_dir. read_dir ( ) {
87- for entry in py_dir. flatten ( ) {
88- let site_packages = entry. path ( ) . join ( "site-packages" ) ;
89- if Path :: exists ( site_packages. as_path ( ) ) { // use first site-packages found, ignoring version
90- sys_pyth_dir += "\n " ;
91- sys_pyth_dir += & format ! ( "sys.path.append('{}')" , site_packages. to_str( ) . unwrap( ) ) ;
92- break ;
85+ #[ cfg( feature = "venv" ) ]
86+ {
87+ let venv_dir = dir. join ( ".venv" ) . join ( "lib" ) ;
88+ if Path :: exists ( venv_dir. as_path ( ) ) {
89+ if let Ok ( py_dir) = venv_dir. read_dir ( ) {
90+ for entry in py_dir. flatten ( ) {
91+ let site_packages = entry. path ( ) . join ( "site-packages" ) ;
92+ if Path :: exists ( site_packages. as_path ( ) ) { // use first site-packages found, ignoring version
93+ sys_pyth_dir += "\n " ;
94+ sys_pyth_dir += & format ! ( "sys.path.append('{}')" , site_packages. to_str( ) . unwrap( ) ) ;
95+ break ;
96+ }
9397 }
9498 }
9599 }
You can’t perform that action at this time.
0 commit comments