MCPcopy Create free account
hub / github.com/unslothai/unsloth / _bootstrap_uv

Function _bootstrap_uv

studio/install_python_stack.py:1773–1797  ·  view source on GitHub ↗

Check if uv is available and probe whether --system is needed.

()

Source from the content-addressed store, hash-verified

1771
1772
1773def _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
1800def _filter_requirements(req: Path, skip: set[str]) -> Path:

Callers 1

install_python_stackFunction · 0.85

Calls 3

whichMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…