[Python] Where should development dependencies go in a post-PEP 735 pyproject.toml?

Discussão em 'Python' iniciado por Stack, Julho 23, 2025.

  1. Stack

    Stack Membro Participativo

    Much has changed in the world of Python dependency management in the last few years and I am looking for some authority regarding where to specify a few classes of dependency in the pyproject.toml file. For context, I am working on a Python project that includes a native extension module.

    Here are the classes:

    1. Dependencies of the installed package (e.g. libraries like imageio or httpx)
    2. Dependencies of the build system (e.g. scikit-build-core or pybind11)
    3. Dependencies of the test environment (e.g. pytest)
    4. Developer tools that would typically be managed by pipx or uvx (e.g. tbump, cmake, ninja, ruff, etc.)

    It is fairly clear that category (1) belongs in [project.dependencies]. The only place that makes sense for (2) is [build-system.requires]. However, even for (2) it is not clear where to place these such that uv will install them into the present environment without duplication (e.g. specifying pybind11 in two places).

    Things get murkier with (3). I have found references to [project.optional-dependencies] (PEP 621) which can be installed with the --extra flag at the uv command line. However, there is now PEP 735, which standardizes the [dependency-groups] section, whose dev group uv treats specially. This feels like the right place, but I am not sure how best to use it.

    What's really throwing me for a loop is (4). These tools are usually expected to be ambient on the system and the common advice is to manage them with pipx (or uvx) so they can be isolated from one another. Where do these belong? In a separate [dependency-groups] group? As an entry in [project.optional-dependencies]?

    Continue reading...

Compartilhe esta Página