@@ -16,17 +16,12 @@ fn pip_install_if_needed_with_hash(
16
16
cache_path : & Path ,
17
17
requirements_path : & Path ,
18
18
hash : String ,
19
- force : bool ,
20
19
) -> Result < PathBuf , tauri:: Error > {
21
20
create_dir_all ( & cache_path) ?;
22
21
23
22
let venv_path = cache_path. join ( "venvs" ) . join ( hash) ;
24
23
let bin_path = venv_path. join ( if cfg ! ( windows) { "Scripts" } else { "bin" } ) ;
25
24
26
- // re: force, this is part of the short-term hack to install all
27
- // code block dependencies in the main interpreter venv. Once we
28
- // figure out how to support a separate venv for each code block
29
- // (that needs it), we can undo this hack.
30
25
if !venv_path. exists ( ) {
31
26
println ! ( "Creating virtual environment..." ) ;
32
27
let python = if cfg ! ( target_os = "macos" ) {
@@ -36,16 +31,10 @@ fn pip_install_if_needed_with_hash(
36
31
} ;
37
32
cmd ! ( python, "-mvenv" , & venv_path) . run ( ) ?;
38
33
39
- if !force {
40
- cmd ! ( bin_path. join( "pip" ) , "install" , "-r" , & requirements_path) . run ( ) ?;
41
-
42
- let cached_requirements_path = venv_path. join ( "requirements.txt" ) ;
43
- copy ( requirements_path, cached_requirements_path) ?;
44
- }
45
- }
46
-
47
- if force {
48
34
cmd ! ( bin_path. join( "pip" ) , "install" , "-r" , & requirements_path) . run ( ) ?;
35
+
36
+ let cached_requirements_path = venv_path. join ( "requirements.txt" ) ;
37
+ copy ( requirements_path, cached_requirements_path) ?;
49
38
}
50
39
51
40
Ok ( bin_path. to_path_buf ( ) )
@@ -57,7 +46,7 @@ fn pip_install_if_needed(
57
46
requirements_path : & Path ,
58
47
) -> Result < PathBuf , tauri:: Error > {
59
48
let hash = shasum:: sha256sum ( & requirements_path) ?;
60
- pip_install_if_needed_with_hash ( cache_path, requirements_path, hash, false )
49
+ pip_install_if_needed_with_hash ( cache_path, requirements_path, hash)
61
50
}
62
51
63
52
#[ cfg( desktop) ]
@@ -67,11 +56,6 @@ pub async fn pip_install_code_blocks_if_needed(
67
56
) -> Result < Option < Yaml > , tauri:: Error > {
68
57
let cache_path = app_handle. path ( ) . cache_dir ( ) ?. join ( "pdl" ) ;
69
58
70
- // for now, install the requirements in the main interpreter venv
71
- let requirements_path = app_handle
72
- . path ( )
73
- . resolve ( "interpreter/requirements.txt" , BaseDirectory :: Resource ) ?;
74
-
75
59
let ( reqs, updated_program) = extract:: extract_requirements ( & program) ;
76
60
let n = reqs
77
61
. into_par_iter ( )
@@ -80,12 +64,8 @@ pub async fn pip_install_code_blocks_if_needed(
80
64
. prefix ( "pdl-requirements-" )
81
65
. suffix ( ".txt" )
82
66
. tempfile ( ) ?;
83
- // This is part of the "force" hack described above, where
84
- // we force the code block dependencies to be installed in
85
- // the main interpreter venv.
86
- let hash = shasum:: sha256sum ( & requirements_path) ?;
87
67
write ( & req_path, req) ?;
88
- pip_install_if_needed_with_hash ( & cache_path, & req_path. path ( ) , hash , true ) ?;
68
+ pip_install_if_needed ( & cache_path, & req_path. path ( ) ) ?;
89
69
Ok ( 1 )
90
70
} )
91
71
. count ( ) ;
0 commit comments