Check if uv is available and probe whether --system is needed.
()
| 1771 | |
| 1772 | |
| 1773 | def _bootstrap_uv() -> bool: |
| 1774 | """Check if uv is available and probe whether --system is needed.""" |
| 1775 | global UV_NEEDS_SYSTEM |
| 1776 | if not shutil.which("uv"): |
| 1777 | return False |
| 1778 | # Probe: try a dry-run install targeting the current Python explicitly. |
| 1779 | # Without --python, uv can ignore the activated venv on some platforms. |
| 1780 | probe = subprocess.run( |
| 1781 | ["uv", "pip", "install", "--dry-run", "--python", sys.executable, "pip"], |
| 1782 | stdout = subprocess.PIPE, |
| 1783 | stderr = subprocess.STDOUT, |
| 1784 | **_windows_hidden_subprocess_kwargs(), |
| 1785 | ) |
| 1786 | if probe.returncode != 0: |
| 1787 | # Retry with --system (some envs need it when uv can't find a venv) |
| 1788 | probe_sys = subprocess.run( |
| 1789 | ["uv", "pip", "install", "--dry-run", "--system", "pip"], |
| 1790 | stdout = subprocess.PIPE, |
| 1791 | stderr = subprocess.STDOUT, |
| 1792 | **_windows_hidden_subprocess_kwargs(), |
| 1793 | ) |
| 1794 | if probe_sys.returncode != 0: |
| 1795 | return False # uv is broken, fall back to pip |
| 1796 | UV_NEEDS_SYSTEM = True |
| 1797 | return True |
| 1798 | |
| 1799 | |
| 1800 | def _filter_requirements(req: Path, skip: set[str]) -> Path: |
no test coverage detected
searching dependent graphs…