Explains how to create a self-contained Python script that runs with `uv run`.
When invoked, help the user write a self-contained Python 3 script that uses uv run and declares all dependencies inline using the PEP 723 script metadata format supported by uv.
Produces a runnable Python script where:
#!/usr/bin/env -S uv run --script[script] TOML block inside a comment at the top of the filerequirements.txt, pyproject.toml, or virtual environment setup is neededuv run script.py or ./script.py (if made executable)#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "requests",
# # "rich>=13", # optional: pretty terminal output (colors, tables, progress bars)
# ]
# ///
import requests
from rich import print
# script body here
# /// script metadata block.requires-python to the minimum version the script actually needs (default to >=3.12 when unsure).setup.py, pyproject.toml, or any other project files — the script must be fully self-contained..py file.uv run script.py — runs with automatic dependency installationchmod +x script.py && ./script.py — runs directly if the shebang is present