Build a uv pip install command with translated flags.
(args: tuple[str, ...])
| 1846 | |
| 1847 | |
| 1848 | def _build_uv_cmd(args: tuple[str, ...]) -> list[str]: |
| 1849 | """Build a uv pip install command with translated flags.""" |
| 1850 | cmd = ["uv", "pip", "install"] |
| 1851 | if UV_NEEDS_SYSTEM: |
| 1852 | cmd.append("--system") |
| 1853 | # Always pass --python so uv targets the right environment. Without it, uv |
| 1854 | # can ignore an activated venv and install into the system Python (seen on |
| 1855 | # Colab and similar). |
| 1856 | cmd.extend(["--python", sys.executable]) |
| 1857 | cmd.extend(_translate_pip_args_for_uv(args)) |
| 1858 | # Torch is pre-installed by install.sh/setup.ps1. Do not add |
| 1859 | # --torch-backend by default -- it can cause solver dead-ends on CPU-only |
| 1860 | # machines. Callers that need it can set UV_TORCH_BACKEND. |
| 1861 | _tb = os.environ.get("UV_TORCH_BACKEND", "") |
| 1862 | if _tb: |
| 1863 | cmd.append(f"--torch-backend={_tb}") |
| 1864 | return cmd |
| 1865 | |
| 1866 | |
| 1867 | def pip_install_try( |
no test coverage detected
searching dependent graphs…