Quickly checking Python dependencies
A short snippet for using `uv` to iterate on changing Python project dependencies.
Use this snippet to quickly identify which Python dependencies you can remove or update. It’s useful when productizing applications or managing upgrades, especially to locate breaking changes.
Iteration speed is essential in software engineering. The right tooling and environment help you move faster, so I’m sharing this script.
The snippet:
- Deletes your local virtual environment
- Creates a fresh one with uv
- Installs dependencies from requirements.txt and your local package in editable mode
This lets you modify dependencies and test for breakage by running your test suite.
rm -rf .venv && \
uv venv && \
uv pip install -r requirements.txt -e . && \
make test
Machine learning dependencies evolve quickly. Package maintainers may pin minimum versions (allowing free updates) or specific versions for stability. Fast triaging of version issues helps you streamline dependencies, diagnose compatibility problems, and execute upgrades when vulnerabilities appear.
I recommend uv for new and legacy projects. It’s fast, feature-rich, and compatible with pip.