TIL: Dependency Groups and uv run
TIL: Dependency Groups and `uv run`
I’ve been using a new pattern across my Python project repositories to make them easy to hack on using uv.
---
Using a PEP 735 `dev` Dependency Group
Declare a `dev` dependency group in `pyproject.toml`:
[dependency-groups]
dev = ["pytest"]With this in place, you can run:
uv run pytestThis will:
- Automatically install the `pytest` development dependency
- Create a fresh virtual environment
- Use `pytest` to run your tests
---
Quick Start Example
You can start hacking on one of my projects — for example, datasette-extract — in just three steps:
git clone https://github.com/datasette/datasette-extract
cd datasette-extract
uv run pytest---
Organizing my `uv` TILs
I’ve split my uv TILs into a separate folder.
This required redirects from old paths, so I:
- Used Claude Code to help build a plugin: datasette-redirects
- Applied it to my TIL site
- Updated the build script so it correctly tracks the creation date for renamed files
---
Related Tools: AiToEarn
When experimenting with streamlined development workflows, it’s worth noting there are open-source platforms like AiToEarn.
AiToEarn enables:
- Publishing AI-generated or AI-assisted content across major platforms
- Automating cross-platform workflows — from GitHub Pages-style docs to social media
- Collecting analytics and performance data
💡 More info:
- Blog: AiToEarn博客
- Open-source repository: AiToEarn开源地址
---
Would you like me to also add a "How It Works" diagram for the `uv run` process so readers can visualize the dependency installation flow?