browniebroke.com

Using uv.lock file in tox

5 December 2025
Edit on Github

I’ve migrated all my open source packages to uv a while back, and the ones which are Django packages are using tox to run the tests against all supported combination of Django + Python versions.

However, I didn’t realise that the tox-uv plugin does not install dependencies from the uv lockfile by default.

The realisation came in the django-money project: the test were running fine despite the lockfile being out of date.

This is explicitly documented on the tox plugin project, but I completely missed that, and assumed it would just magically work.

The fix I suggested is heavily inspired by Adam Johnson’s setup (example from django-cors-headers). When I don’t know how to do something in Django 3rd party packages, I often check one of his packages and always learn something from it.

Here are the key points:

  1. Add runner = uv-venv-lock-runner to the tox test envs
  2. Move the Django versions from tox.ini to pyproject.toml in dependency-groups and replace them by dependency groups
  3. Add tool.uv.conflicts to mark the dependency groups as incompatible for uv (documentation)

That’s it! Once again, thanks Adam!

Liked it? Please share it!