Quickly checking Python dependencies
1 minute read
This post is about a snippet I’ve been using to identify which dependencies in a Python project I can remove or update. Often, the key trick with software engineering is about figuring out what tooling and environment you need to iterate quickly, so I thought I’d save this script here.
The snippet below:
- Deletes a local virtual environment.
- Creates a new virtual environment with uv.
uv
then installs dependencies as defined by the requirements.txt file and the package found in the local context in an editable state.
The idea is that you can modify the dependencies or installation for a given package and see what broke by running the test suite - insert your own call to a test suite if you like.
1
2
3
4
rm -rf .venv && \
uv venv && \
uv pip install -r requirements.txt -e . && \
make test
Python dependencies used in the AI space are changing rapidly, and developers of a given package are just as likely to pin to a minimum version (so you can get updates for free) as opposed to a single version that can be used to provide a stable platform for development. Being able to triage issues with specific versions quickly helps slim down the stack, diagnose issues with versions, and help perform upgrades as a consequence of vulnerabilities being reported.
I’ve been really impressed with the uv tool. Its performance, wide feature set, and support for the pip API makes it a no-brainer to use for new projects as well as for legacy production workloads.