@@ -48,11 +48,22 @@ def on_progress(line: str):
4848 def on_error (line : str ):
4949 log .error (f"uv: [error]\n { line .strip ()} " )
5050
51- _wrap_command_with_callbacks (
52- [get_uv_bin (), 'pip' , 'install' , '--python' , '.venv/bin/python' , '.' ],
53- on_progress = on_progress ,
54- on_error = on_error ,
55- )
51+ try :
52+ result = _wrap_command_with_callbacks (
53+ [get_uv_bin (), 'pip' , 'install' , '--python' , '.venv/bin/python' , '.' ],
54+ on_progress = on_progress ,
55+ on_error = on_error ,
56+ )
57+ if result is False :
58+ log .info ("Retrying uv installation with --no-cache flag..." )
59+ _wrap_command_with_callbacks (
60+ [get_uv_bin (), 'pip' , 'install' , '--no-cache' , '--python' , '.venv/bin/python' , '.' ],
61+ on_progress = on_progress ,
62+ on_error = on_error ,
63+ )
64+ except Exception as e :
65+ log .error (f"Installation failed: { str (e )} " )
66+ raise
5667
5768
5869def remove (package : str ):
@@ -137,8 +148,9 @@ def _wrap_command_with_callbacks(
137148 on_progress : Callable [[str ], None ] = lambda x : None ,
138149 on_complete : Callable [[str ], None ] = lambda x : None ,
139150 on_error : Callable [[str ], None ] = lambda x : None ,
140- ) -> None :
141- """Run a command with progress callbacks."""
151+ ) -> bool :
152+ """Run a command with progress callbacks. Returns bool for cmd success."""
153+ process = None
142154 try :
143155 all_lines = ''
144156 process = subprocess .Popen (
@@ -165,12 +177,16 @@ def _wrap_command_with_callbacks(
165177
166178 if process .wait () == 0 : # return code: success
167179 on_complete (all_lines )
180+ return True
168181 else :
169182 on_error (all_lines )
183+ return False
170184 except Exception as e :
171185 on_error (str (e ))
186+ return False
172187 finally :
173- try :
174- process .terminate ()
175- except :
176- pass
188+ if process :
189+ try :
190+ process .terminate ()
191+ except :
192+ pass
0 commit comments