Key Points
Introduction
- Software packaging bundles code, metadata, dependencies and documentation into a distributable artefact.
- Packaging makes software easier to share, install, reuse and reproduce.
- Python packages are commonly distributed as source distributions (sdists) or wheels.
- Modern Python packaging is built around the
pyproject.tomlstandard. - Package managers such as
uvsimplify dependency management, environment creation and package installation. - Lock files help create reproducible software environments by recording exact dependency versions.
- Package repositories such as PyPI provide a central location for publishing and installing software.
Example Code
-
pipandvenvare traditional tools for installing dependencies and setting up virtual environments for running and developing Python code. -
requirements.txtfile can be used to record and share a snapshot of the virtual environment.
Software packaging with uv
-
uvcombines Python installation, dependency management, virtual environments, packaging and publishing into a single, high-performance tool. -
pyproject.tomlis the standard configuration file for modern Python projects and stores project metadata, dependencies and tool configuration. - Dependencies are declared in
pyproject.toml, whileuv.lockrecords the exact package versions needed to reproduce the project environment withuv. -
uvautomatically keeps the project environment and lock file synchronised, reducing manual environment management. -
uvrun executes commands in the correct project environment without requiring manual activation of a virtual environment. - Python packages are typically distributed as source distributions
(.tar.gz) and wheels (.whl), which can be built using
uvbuild. - Existing
pipandvenvdevelopment workflows can be migrated touvwith only a few commands for most projects.