File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ use py_lib_pyo3 as py_lib;
2626
2727pub use error:: { Error , Result } ;
2828use models:: * ;
29- use std:: path:: PathBuf ;
29+ use std:: path:: { Path , PathBuf } ;
3030
3131#[ cfg( desktop) ]
3232use desktop:: Python ;
@@ -80,14 +80,19 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
8080}
8181
8282fn init_python ( code : String , dir : PathBuf ) {
83+ let mut sys_pyth_dir = format ! ( "sys.path.append('{}')" , dir. to_str( ) . unwrap( ) ) ;
84+ let venv_dir = dir. join ( ".venv" ) ;
85+ 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( ) ) ;
88+ }
8389 let path_import_and_code = format ! (
8490 r#"
8591import sys
86- sys.path.append('{}')
92+ {}
8793{}
8894"# ,
89- dir. to_str( ) . unwrap( ) ,
90- code
95+ sys_pyth_dir, code
9196 ) ;
9297 py_lib:: run_python ( StringRequest {
9398 value : path_import_and_code,
You can’t perform that action at this time.
0 commit comments