I like Python, but it isn’t my primary programming language, so I don’t always have the latest Python installed with the packages I need. uv make all the problems go away!
I generally only have a simple script, so don’t want to have lots of pyproject.toml files lying around. Instead, I use uv’s script mode to declare dependencies right in the script file itself. Here’s what it looks like at the top of each .py file:
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["argparse", "python-frontmatter", "pyyaml"]
# ///