@@ -17,11 +17,6 @@ fn pip_install_if_needed(app_handle: tauri::AppHandle) -> Result<PathBuf, tauri:
1717 } else {
1818 venv_path. join ( "bin/activate" )
1919 } ;
20- let activate_path_str = activate_path
21- . clone ( )
22- . into_os_string ( )
23- . into_string ( )
24- . unwrap ( ) ;
2520 let cached_requirements_path = venv_path
2621 . join ( "requirements.txt" )
2722 . into_os_string ( )
@@ -34,13 +29,12 @@ fn pip_install_if_needed(app_handle: tauri::AppHandle) -> Result<PathBuf, tauri:
3429
3530 if !venv_path. exists ( ) {
3631 println ! ( "Creating virtual environment..." ) ;
37- let venv_path_string = venv_path. into_os_string ( ) . into_string ( ) . unwrap ( ) ;
3832 let python = if cfg ! ( target_os = "macos" ) {
3933 "python3.12"
4034 } else {
4135 "python3"
4236 } ;
43- cmd ! ( python, "-mvenv" , venv_path_string . as_str ( ) ) . run ( ) ?;
37+ cmd ! ( python, "-mvenv" , & venv_path ) . run ( ) ?;
4438 }
4539
4640 let requirements_path = app_handle
@@ -54,44 +48,14 @@ fn pip_install_if_needed(app_handle: tauri::AppHandle) -> Result<PathBuf, tauri:
5448 requirements_path. as_str ( ) ,
5549 cached_requirements_path. as_str ( ) ,
5650 ) {
57- println ! (
58- "Running pip install... {:?}" ,
59- if cfg!( windows) {
60- format!(
61- "{activate} ; pip install -r '{requirements}'" ,
62- activate = activate_path_str,
63- requirements = requirements_path
64- )
65- } else {
66- format!(
67- "source '{activate}' && pip install -r '{requirements}'" ,
68- activate = activate_path_str,
69- requirements = requirements_path
70- )
71- }
72- . as_str( ) ,
73- ) ;
7451 cmd ! (
75- if cfg!( windows) { "powershell" } else { "sh" } ,
76- if cfg!( windows) {
77- "invoke-expression"
78- } else {
79- "-c"
80- } ,
81- if cfg!( windows) {
82- format!(
83- "{activate} ; pip install -r '{requirements}'" ,
84- activate = activate_path_str,
85- requirements = requirements_path
86- )
87- } else {
88- format!(
89- "source '{activate}' && pip install -r '{requirements}'" ,
90- activate = activate_path_str,
91- requirements = requirements_path
92- )
93- }
94- . as_str( ) ,
52+ venv_path
53+ . clone( )
54+ . join( if cfg!( windows) { "Scripts" } else { "bin" } )
55+ . join( "pip" ) ,
56+ "install" ,
57+ "-r" ,
58+ & requirements_path,
9559 )
9660 . run ( ) ?;
9761
0 commit comments