Skip to content

Commit cf44301

Browse files
authored
Change warnings to errors in package installation
and install one by one. So a failure does not stop installing other packages.
1 parent 4d54627 commit cf44301

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

builder/penv_setup.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -286,18 +286,18 @@ def _get_installed_uv_packages():
286286
for p in packages:
287287
result[p["name"].lower()] = pepver_to_semver(p["version"])
288288
else:
289-
print(f"Warning: uv pip list failed with exit code {result_obj.returncode}")
289+
print(f"Error: uv pip list failed with exit code {result_obj.returncode}")
290290
if result_obj.stderr:
291291
print(f"Error output: {result_obj.stderr.strip()}")
292292

293293
except subprocess.TimeoutExpired:
294-
print("Warning: uv pip list command timed out")
294+
print("Error: uv pip list command timed out")
295295
except (json.JSONDecodeError, KeyError) as e:
296-
print(f"Warning: Could not parse package list: {e}")
296+
print(f"Error: Could not parse package list: {e}")
297297
except FileNotFoundError:
298-
print("Warning: uv command not found")
298+
print("Error: uv command not found")
299299
except Exception as e:
300-
print(f"Warning! Couldn't extract the list of installed Python packages: {e}")
300+
print(f"Error! Couldn't extract the list of installed Python packages: {e}")
301301

302302
return result
303303

@@ -306,39 +306,39 @@ def _get_installed_uv_packages():
306306

307307
if packages_to_install:
308308
packages_list = []
309+
package_map = {}
309310
for p in packages_to_install:
310311
spec = python_deps[p]
311312
if spec.startswith(('http://', 'https://', 'git+', 'file://')):
312313
packages_list.append(spec)
314+
package_map[spec] = p
313315
else:
314-
packages_list.append(f"{p}{spec}")
315-
316-
cmd = [
317-
penv_uv_executable, "pip", "install",
318-
f"--python={python_exe}",
319-
"--quiet", "--upgrade"
320-
] + packages_list
316+
full_spec = f"{p}{spec}"
317+
packages_list.append(full_spec)
318+
package_map[full_spec] = p
321319

322-
try:
323-
subprocess.check_call(
324-
cmd,
325-
stdout=subprocess.DEVNULL,
326-
stderr=subprocess.STDOUT,
327-
timeout=300
328-
)
329-
330-
except subprocess.CalledProcessError as e:
331-
print(f"Error: Failed to install Python dependencies (exit code: {e.returncode})")
332-
return False
333-
except subprocess.TimeoutExpired:
334-
print("Error: Python dependencies installation timed out")
335-
return False
336-
except FileNotFoundError:
337-
print("Error: uv command not found")
338-
return False
339-
except Exception as e:
340-
print(f"Error installing Python dependencies: {e}")
341-
return False
320+
for package_spec in packages_list:
321+
cmd = [
322+
penv_uv_executable, "pip", "install",
323+
f"--python={python_exe}",
324+
"--quiet", "--upgrade",
325+
package_spec
326+
]
327+
try:
328+
subprocess.check_call(
329+
cmd,
330+
stdout=subprocess.DEVNULL,
331+
stderr=subprocess.STDOUT,
332+
timeout=300
333+
)
334+
except subprocess.CalledProcessError as e:
335+
print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}' failed (exit code {e.returncode}).")
336+
except subprocess.TimeoutExpired:
337+
print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}' timed out.")
338+
except FileNotFoundError:
339+
print("Error: uv command not found")
340+
except Exception as e:
341+
print(f"Error: Installing package '{package_map.get(package_spec, package_spec)}': {e}.")
342342

343343
return True
344344

0 commit comments

Comments
 (0)