[1] https://www.youtube.com/watch?v=gSKTfG1GXYQ
edit: NP-complete not NP-hard
How does uv’s sat solver compare?
https://www.anaconda.com/blog/a-faster-conda-for-a-growing-c...
We run internal benchmarks of our custom container image builder and in the 'install torch' benchmark the p50 time saved when using `uv` is 25 seconds! (71.4s vs. 43.74s)
---
Aside 2: Seems there's a missing "involves" in this sentence: "As such, installing PyTorch typically often configuring a project to use the PyTorch index."
Between that latter feature, the proxy, the parallelization we've reduced build times across ~100 engineers by a solid 10 minutes. There are other things we do as well, but uv is a must have nowadays.
# Setup virtual env
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN python3 -m venv $VIRTUAL_ENV
RUN . $VIRTUAL_ENV/bin/activate
# install using uv
RUN pip install uv
RUN uv pip install torch==${TORCH_VERSION} --index-url https://download.pytorch.org/whl/cpu
The index-url makes it really convenient.https://docs.astral.sh/uv/guides/integration/docker/#install...
[[tool.uv.index]]
name = "pytorch-cu124"
url = "https://download.pytorch.org/whl/cu124"
explicit = trueWhen installed with brew on my MacBook, uv currently has PyTorch 3.13 as a dependency, which is fine. But PyTorch does not currently have a stable wheel that's compatable with Python 3.13! This resulted in very confusing errors. (Solution was to point to the Nightly index)
That's technically PyTorch's fault, but it's indicitave why a specific page on installing PyTorch is necessary, and it's good to know the documentation specifically calls it out.
The pace of development on uv is really impressive.
Or via the global "python-preference" option set to "only-system".
Cf https://docs.astral.sh/uv/concepts/python-versions/#adjustin... and https://docs.astral.sh/uv/reference/settings/#python-prefere...
The work can be tracked in https://github.com/astral-sh/uv/issues/6265
"When Python is installed by uv, it will not be available globally (i.e. via the python command). Support for this feature is planned for a future release. In the meantime, use uv run or create and activate a virtual environment to use python directly."
So yes, one needs mise/asdf/pyenv or similar for global installs for now.
Conda (and Mamba) allows to avoid duplicating packages on the disk between environments (not just the downloaded archives, but the resulting expanded files too).
How does uv compare in this regard?
One limitation I know of are the inability to detect stale packages.
Apart from „blazing fast“, which I‘m not convinced it really matters to me as I rarely touch the dependencies, what are the main reasons why uv is gaining traction?
No need to activate venvs and the almost inevitable Python pathing "murder mysteries". uv installs in venvs first, and only then someplace else (e.g., globally).
No more clunky typing `python -m pip install foo` even when you have activated your venv (or you think you have). `uv pip install foo` is nicer and easier to remember.
uv add will add new dependencies to your pyproject.toml so you don't have to.
uv can setup skeletons for new projects in a nice, modern way
For older projects, you can have uv to resolve dependencies as of a certain date. I imagine this is great for older projects, especially with numerous dependencies.
It might remove the need for pyenv or the need to rely on your system provided Python, since uv can install Python for your project.
Cross-platform lock files
I've just started looking in to uv, so maybe my list isn't complete/very good. Some down sides include, it's still green (has some bugs naturally and lacks some features) and some might not trust/like that it's VC backed.
Interesting. I imagine this is a selling point for corporate environments.
Is this worth switching to?
Migrating is not super hard, we wrote a small script that moves all the information from a Pipfile to a pyproject.toml and it works like a charm.
Now I have switched to uv with new projects. No problems so far. I definitely recommend giving it a go.