uv - Python Package Manager

Sources:

title: Contents 
style: nestedList # TOC style (nestedList|inlineFirstLevel)
minLevel: 1 # Include headings from the specified level
maxLevel: 4 # Include headings up to the specified level
includeLinks: true # Make headings clickable
debugInConsole: false # Print debug info in Obsidian console

Overview

NOTE

uv is an extremely fast Python package installer and resolver, written in Rust, and designed as a drop-in replacement for pip and pip-tools workflows.

uv represents a milestone in our pursuit of a “Cargo for Python”: a comprehensive Python project and package manager that’s fast, reliable, and easy to use.

NOTE

uv is backed by Astral, the creators of Ruff.

Highlights

  • ⚖️ Drop-in replacement for common pip, pip-tools, and virtualenv commands.
  • ⚡️ 10-100x faster than pip and pip-tools (pip-compile and pip-sync).
  • 💾 Disk-space efficient, with a global cache for dependency deduplication.
  • 🐍 Installable via curl, pip, pipx, etc. uv is a static binary that can be installed without Rust or Python.
  • 🧪 Tested at-scale against the top 10,000 PyPI packages.
  • 🖥️ Support for macOS, Linux, and Windows.
  • 🧰 Advanced features such as dependency version overrides and alternative resolution strategies.
  • ⁉️ Best-in-class error messages with a conflict-tracking resolver.
  • 🤝 Support for a wide range of advanced pip features, including editable installs, Git dependencies, direct URL dependencies, local dependencies, constraints, source distributions, HTML and JSON indexes, and more.

Getting Started

Install:

# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | sh
 
# On Windows.
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
 
# With pip.
pip install uv
 
# With pipx.
pipx install uv
 
# With Homebrew.
brew install uv
 
# With Pacman.
pacman -S uv

Usage

uv pip install flask                # Install Flask.
uv pip install -r requirements.txt  # Install from a requirements.txt file.
uv pip install -e .                 # Install the current project in editable mode.
uv pip install "package @ ."        # Install the current project from disk.
uv pip install "flask[dotenv]"      # Install Flask with "dotenv" extra.

To generate a set of locked dependencies:

uv pip compile requirements.in -o requirements.txt    # Read a requirements.in file.
uv pip compile pyproject.toml -o requirements.txt     # Read a pyproject.toml file.
uv pip compile setup.py -o requirements.txt           # Read a setup.py file.
echo flask | uv pip compile - -o requirements.txt     # Read from stdin.
uv pip freeze | uv pip compile - -o requirements.txt  # Lock the current environment.

To sync a set of locked dependencies with the virtual environment:

uv pip sync requirements.txt  # Install from a requirements.txt file.

uv’s pip-install and pip-compile commands support many of the same command-line arguments as existing tools, including -r requirements.txt, -c constraints.txt, -e . (for editable installs), --index-url, and more.

See Also


Appendix

Note created on 2024-04-10 and last modified on 2024-04-10.

LIST FROM [[Tool - Python uv]] AND -"CHANGELOG" AND -"04-RESOURCES/Tools/Tool - Python uv"

(c) No Clocks, LLC | 2024