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.toml standard.
  • Package managers such as uv simplify 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


  • pip and venv are traditional tools for installing dependencies and setting up virtual environments for running and developing Python code.
  • requirements.txt file can be used to record and share a snapshot of the virtual environment.

Software packaging with uv


  • uv combines Python installation, dependency management, virtual environments, packaging and publishing into a single, high-performance tool.
  • pyproject.toml is the standard configuration file for modern Python projects and stores project metadata, dependencies and tool configuration.
  • Dependencies are declared in pyproject.toml, while uv.lock records the exact package versions needed to reproduce the project environment with uv.
  • uv automatically keeps the project environment and lock file synchronised, reducing manual environment management.
  • uv run 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 uv build.
  • Existing pip and venv development workflows can be migrated to uv with only a few commands for most projects.