File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " tauri-plugin-python"
3- version = " 0.3.2 "
3+ version = " 0.3.3 "
44authors = [ " Marco Mengelkoch" ]
55description = " A tauri 2 plugin to use python code in the backend."
66keywords = [" rust" , " python" , " tauri" , " gui" ]
Original file line number Diff line number Diff line change 11{
22 "name" : " tauri-plugin-python-api" ,
3- "version" : " 0.3.2 " ,
3+ "version" : " 0.3.3 " ,
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 @@ -81,10 +81,18 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
8181
8282fn init_python ( code : String , dir : PathBuf ) {
8383 let mut sys_pyth_dir = format ! ( "sys.path.append('{}')" , dir. to_str( ) . unwrap( ) ) ;
84- let venv_dir = dir. join ( ".venv" ) ;
84+ let venv_dir = dir. join ( ".venv" ) . join ( "lib" ) ;
8585 if Path :: exists ( venv_dir. as_path ( ) ) {
86- sys_pyth_dir += "\n " ;
87- sys_pyth_dir += & format ! ( "sys.path.append('{}')" , venv_dir. to_str( ) . unwrap( ) ) ;
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 ;
93+ }
94+ }
95+ }
8896 }
8997 let path_import_and_code = format ! (
9098 r#"
You can’t perform that action at this time.
0 commit comments