Just use uv
When you're building a Python library, take care with your dependency specifiers. Overly-specific or overly-restrictive dependencies can quickly lead to dependency hell for your dependents. I've written two articles on the topic, the first one in 2022:
- In Dependency protection with Python and Github actions, I outlined a scheme to test minimum versions against a manually-maintained
requirements-min.txt
. - The follow-on Dependency protection with pyproject.toml "simplified" the workflow with a utility script to calculate and install the minimum versions of dependencies.
All these backflips were required because pip doesn't support resolving to minimum versions. Various utilities and package management systems did, but none of them felt like the right solution to me — until now.
Just use uv
uv is a Python package and project manager from Astral, the folks who brought us ruff. Astral, in my opinion, are those rare folks whose tools actually live up to their hype. uv does a lot of stuff, including solving our minimum dependency problem.
uv pip install . --resolution lowest # or --resolution lowest-direct
If you're using uv projects (which I would recommend) you can sync
to your lowest versions as well:
uv sync --resolution lowest
This makes things pretty darn simple, especially compared to the mess that was the solutions I wrote about above. To see this in action, I just updated antimeridian to use uv in its CI to test against minimum versions:
- uses: astral-sh/setup-uv@v3
- name: Sync
run: uv sync --resolution lowest-direct
- name: pytest
run: uv run pytest
- name: Sync w/ all extras
run: uv sync --resolution lowest-direct --all-extras
- name: pytest
run: uv run pytest