Self-contained Python scripts with uv

TLDR: The author uses uv to create self-contained Python scripts with dependencies embedded in the shebang line, making it easy to run without managing virtual environments or cluttering system Python. It’s particularly useful for testing endpoints and interacting with PostgreSQL databases. The author initially had doubts about using special script tags in Python scripts but found them helpful for managing dependencies. By using uv, the author can run scripts on any Unix system with uv installed without worrying about dependencies. This approach makes sharing and running scripts painless for users. Overall, it’s a convenient solution for creating executable Python scripts.

http://blog.dusktreader.dev/2025/03/29/self-contained-python-scripts-with-uv/

To top