diff --git a/ultralytics/utils/checks.py b/ultralytics/utils/checks.py index 832090dd..9ae7209b 100644 --- a/ultralytics/utils/checks.py +++ b/ultralytics/utils/checks.py @@ -388,21 +388,28 @@ def check_requirements(requirements=ROOT.parent / "requirements.txt", exclude=() pkgs.append(r) @Retry(times=2, delay=1) - def attempt_install(packages, commands): - """Attempt pip install command with retries on failure.""" - return subprocess.check_output(f"pip install --no-cache-dir {packages} {commands}", shell=True).decode() + def attempt_install(packages, commands, use_uv): + """Attempt package installation with uv if available, falling back to pip.""" + if use_uv: + # Note requires --break-system-packages on ARM64 dockerfile + cmd = f"uv pip install --system --no-cache-dir {packages} {commands} --index-strategy=unsafe-best-match --break-system-packages --prerelease=allow" + else: + cmd = f"pip install --no-cache-dir {packages} {commands}" + return subprocess.check_output(cmd, shell=True).decode() s = " ".join(f'"{x}"' for x in pkgs) # console string if s: if install and AUTOINSTALL: # check environment variable + # Note uv fails on arm64 macOS and Raspberry Pi runners + uv = not ARM64 and subprocess.run(["command", "-v", "uv"], capture_output=True, shell=True).returncode == 0 n = len(pkgs) # number of packages updates LOGGER.info(f"{prefix} Ultralytics requirement{'s' * (n > 1)} {pkgs} not found, attempting AutoUpdate...") try: t = time.time() assert ONLINE, "AutoUpdate skipped (offline)" - LOGGER.info(attempt_install(s, cmds)) + LOGGER.info(attempt_install(s, cmds, use_uv=uv)) dt = time.time() - t - LOGGER.info(f"{prefix} AutoUpdate success ✅ {dt:.1f}s, installed {n} package{'s' * (n > 1)}: {pkgs}") + LOGGER.info(f"{prefix} AutoUpdate success ✅ {dt:.1f}s") LOGGER.warning( f"{prefix} {colorstr('bold', 'Restart runtime or rerun command for updates to take effect')}\n" )