Skip to content

uv

An ultra-fast Python project manager that simplifies working with dependencies and tools without unnecessary steps.


What is it used for here?

!

  • Installs all current project dependencies and features (main and dev) after cloning (project initialization)
  • Automatically creates an isolated environment (similar to venv, but without manual steps)
  • Allows running any Python tools (e.g., pytest, ruff, mypy) without activating venv or extra configuration
  • Ensures a consistent environment for local development, CI/CD, and devcontainer

How it works in this template

  • After cloning the project, just run:

    make init
    
    This command:

    • Installs all dependencies via uv
    • Sets up pre-commit hooks
  • To run Python tools (tests, linters, etc.), you needn't activate venv:

    uv run pytest
    uv run ruff check ./src/
    uv run mypy ./src/
    

  • To add a new dependency:

    uv add <package-name>
    
    or for dev dependencies:
    uv add --group dev <package-name>
    


How to update or change the Python version for the project

!

  1. Edit the Python version in pyproject.toml, for example:

    pyproject.toml
    [project]
    requires-python = ">=3.11"
    
  2. Remove the old environment (optional):

    rm -r .venv
    
  3. Change the Python version in your .python-version file:

    uv python pin 3.11
    
    • You can specify any interpreter available on your system (python3.12, python3.10, etc.).
    • If the specified Python version is not installed, uv will automatically install it.
    • If you don't specify a version, uv uses the current Python version installed on your system.
  4. Reinstall dependencies:

    make init
    
    # or only dependencies without reinstalling hooks
    uv sync --link-mode=copy
    
  5. The project now uses the desired Python version in its venv.


Configuration

  • All configuration for uv in this template is located in pyproject.toml (file is generated automatically by uv).

For more details on configuration, see the uv Documentation