@@ -79,15 +79,15 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
7979 init_and_register ( vec ! [ ] )
8080}
8181
82- fn cleanup_path_for_python ( path : & str ) -> String {
83- path. replace ( " \\ \\ ? \\ " , "" ) . replace ( "\\ " , "/" )
82+ fn cleanup_path_for_python ( path : & PathBuf ) -> String {
83+ dunce :: canonicalize ( & path) . unwrap ( ) . to_string_lossy ( ) . replace ( "\\ " , "/" )
8484}
8585
8686fn init_python ( code : String , dir : PathBuf ) {
8787 #[ allow( unused_mut) ]
8888 let mut sys_pyth_dir = vec ! [ format!(
8989 "\" {}\" " ,
90- cleanup_path_for_python( & dir. canonicalize ( ) . unwrap ( ) . to_string_lossy ( ) )
90+ cleanup_path_for_python( & dir)
9191 ) ] ;
9292 #[ cfg( feature = "venv" ) ]
9393 {
@@ -100,9 +100,7 @@ fn init_python(code: String, dir: PathBuf) {
100100 if Path :: exists ( site_packages. as_path ( ) ) {
101101 sys_pyth_dir. push ( format ! (
102102 "\" {}\" " ,
103- cleanup_path_for_python(
104- & site_packages. canonicalize( ) . unwrap( ) . to_string_lossy( )
105- )
103+ cleanup_path_for_python( & site_packages)
106104 ) ) ;
107105 break ;
108106 }
@@ -118,7 +116,6 @@ sys.path = sys.path + [{}]
118116 sys_pyth_dir. join( ", " ) ,
119117 code
120118 ) ;
121- dbg ! ( & sys_pyth_dir) ;
122119 py_lib:: run_python_internal ( path_import, "main.py" . into ( ) )
123120 . unwrap_or_else ( |e| panic ! ( "Error initializing main.py:\n \n {e}\n " ) ) ;
124121}
@@ -151,7 +148,6 @@ pub fn init_and_register<R: Runtime>(python_functions: Vec<&'static str>) -> Tau
151148 if code. is_empty ( ) {
152149 println ! ( "ERROR: Error reading 'src-tauri/main.py'" ) ;
153150 }
154- dir = dir. canonicalize ( ) . unwrap ( ) ;
155151 init_python ( code, dir) ;
156152 for function_name in python_functions {
157153 py_lib:: register_function_str ( function_name. into ( ) , None ) . unwrap ( ) ;
0 commit comments