Using uv.lock file in tox
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:
- Add
runner = uv-venv-lock-runnerto the tox test envs - Move the Django versions from
tox.initopyproject.tomlindependency-groupsand replace them by dependency groups - Add
tool.uv.conflictsto mark the dependency groups as incompatible for uv (documentation)
That’s it! Once again, thanks Adam!