Something with a similar subject line has been asked here before, but the context differs a bit, so I’ll try it again. The project I work on has more dependencies to run the full test suite than to run the package. As just one example, some tests fire off a separate process, and use psutil to watch it and possibly kill it (maybe not the perfect design, but that’s not the point here). And even more stuff to build for release, as there are deps that apply only to doc building. In the past we’ve had requirements.txt files to express those, so for a developer who has done some work and wants to run the tests, pip -r requirements-dev.txt takes care of it. We do the same provisioning a CI instance. Expressing the dependencies in pyproject.toml doesn’t seem to allow the same thing - “just install these dependencies, don’t try to install the package”. Am I missing something? Or do we still need to keep parallel lists in two places? How to you best provision an environment where you’re going to test against a git checkout and aren’t at all interested in installing the package in this context.
I believe this is what dependency groups are for. Instead of pip -r requirements-dev.txt you would do pip install --group dev (Note: this requires pip 25.1 or later).
The dev group is also special cased by uv in that it will be installed automatically when running uv sync in a project folder along with the package.
I think this pip issue tracks the feature you want, at least if you’re using pip. It’s not possible to do this right now with dependency groups, pip will always try to build and install the package.
This is the case if you want to specifically install the dependencies in the project.dependencies table for the package without installing the package itself.
But if the dependencies are for other tasks, pip install --group <name> will install that group without including the package.
Ah… thanks. I was aware of dependency groups and didn’t think they quite handled it, sounds like that’s at least in discussion. It looks like as an interim, this is at least serviceable:
pip install --group dev --editable .
TIL, thanks!
Hey,
With pip, you can’t install only the test or dev dependencies from pyproject.toml, so you still need a requirement-dev.txt file. But newer tools like uv, hatch or PDM let install the dev or test dependencies without installing the package, so you wouldn’t need separate files if you use them.
This is outdated since pip added support for dependency groups in 25.1. pip install --group dev will just install the “dev” dependency group.