What is uv(Python)?

114 Views
English
#python#uv#package#poetry#pip

A Beginner's Guide to the uv Package Manager in Python | by Jack Smith |  Medium

Overview

Development Astral Software Inc.
Release date February 16, 2024
Type Package Manager
Languages ​​spoken Rust

 

Released in 2024, uv is rapidly establishing itself as a new "de facto standard" in the Python ecosystem, earning approximately 50,000 GitHub stars within a year of its release. Its most notable feature is its speed. Written in Rust, it installs dependency packages 10-100 times faster than pip, as shown in the graph.

Around the same time, MCP servers, a hot topic in the AI ​​development community, were also supported as a deployment tool, leading to rapid adoption due to its superior user experience. Python code used in machine learning, such as PyTorch, often relies on a large number of dependent packages, making the package installation process time-consuming when setting up a new environment. This is where uv's unique strengths truly shine. It also natively supports the existing pip interface, previously managed through requirements.txt, and deployments can also be made in pip format.

As a modern package manager, it performs the functions of traditional virtual environment managers and project managers, while maintaining a simple user experience. This is a must-try package manager for Python programmers who have felt frustrated with the speed of the existing pip.

 

All you have to do is write down your project information and dependent packages in the pyproject.toml file and you're ready to go.

[project]
name = "my-simple-project"
version = "0.1.0"
authors = [{name="Gildong Hong", email="gildong@example.com"}]
description = "A very simple Python project"
requires-python = ">=3.8"
dependencies = [
    "requests>=2.31.0",
    "pandas>=2.2.1",
    "numpy>=1.26.4",
]
uv sync

 

It can be run immediately without any separate preparation process.

uv run file.py

 

Specificity

  • Speed: Written in Rust, it offers dependency resolution, package download, and installation speeds tens to hundreds of times faster than existing Python-based package management tools (e.g., pip).
  • Unified Toolchain: Core functions previously distributed across multiple tools, such as package installation, dependency resolution and lock file creation, and virtual environment management, are now integrated into a single CLI.
  • Compatibility: Full support for requirements.txt files and most of the main pip commands and options are identical or similar, making it easy for existing pip users to transition.
  • Virtual Environment Management: Create and manage Python virtual environments very quickly and easily.
  • Sophisticated Dependency Resolution and Locking: Quickly generate a lock file containing a reproducible list of dependencies from a pyproject.toml file or requirements.txt file.
  • Caching: Leveraging global and local caches to minimize duplicate package downloads and builds, it further improves installation speed and optimizes disk space usage.
  • Support for the Latest Standards: Complies with the latest Python packaging standards, including PEP 517, PEP 518, PEP 621, and PEP 735. It natively supports project configuration and dependency management via the pyproject.toml file.
  • Cross-platform: Provides a consistent user experience across major operating systems, including Windows, macOS, and Linux.

Related Posts