Posted on :: 318 Words :: Tags: , , , ,

uv damaging in large doses ☀️ yet a beautiful package contribution to the Python ecosystem

As a data professional, managing dependencies efficiently is crucial for productivity. I’ve been exploring uv, a cutting-edge Python package manager that revolutionises how to handle dependencies. Previously, I relied on PDM, which served me very well, but I'm excited about the potential uv offers. Here's why:

  • Speed: uv is built in Rust, making it significantly faster than traditional package managers like pip. This speed boost can save you a lot of time, especially on large projects (and during deployments and other CI/CD processes).
  • Efficient Dependency Management: It simplifies workflows by providing a unified interface for managing dependencies, environments, and projects.
  • Compatibility: uv is designed to work seamlessly with existing Python tools and workflows, making it easy to integrate into existing projects.

Getting Started with uv

Setting up a new project is straightforward:

mkdir my_new_project && cd my_new_project
`uv` init && rm main.py  # Remove the sample code placeholder

uv init creates essential files like pyproject.toml and README.md. For a more comprehensive setup, you can use options like --lib, --description, and --python to tailor your project.

Key Commands

  • uv init: Initialises a new project.
  • uv add: Adds dependencies.
  • uv sync: Ensures your environment is up-to-date.

Additional Tips

  • Virtual Environments: uv creates a virtual environment automatically when you add dependencies. You can still activate it using source .venv/bin/activate or just use uv run ... for running each command.
  • Legacy Compatibility: Need a requirements.txt? Use uv pip compile pyproject.toml -o requirements.txt.
  • Great article from the Prefect.io team about their adoption and use of uv: What Data Professionals Need to Know about uv.
  • Hynek Schlawack YouTube playlist: The uv Anthology.

uv is not just a package manager; it's a must-have for contemporary Python development. Its speed, efficiency, and compatibility make it an excellent choice for both small and large projects.