Self Contained Python Script

Write self-installing self-contained Python scripts using uv and PEP 723 Use when this capability is needed.

tomevault-io aeaf764 2 files · 1.5 KB Updated

File contents

Use this to write Python tools / scripts / CLIs as single files.

  • Add dependencies with uv add --script foo.py httpx.
  • Run with uv run foo.py.
  • If inline metadata is present, uv run ignores project dependencies automatically.

Use PEP 723 inline metadata and an executable shebang:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.13"
# dependencies = [
#   "httpx",
# ]
# ///
import httpx
  • dependencies must be present, even if empty: dependencies = [].

Converted and distributed by TomeVault — claim your Tome and manage your conversions.

tomevault-io/skills-registry/tree/main/davidgasquez--dotfiles--self-contained-python-script commit aeaf76442c

Frequently asked questions

npx skillmds@latest add tomevault-io/self-contained-python-script