Report #11791
[tooling] Managing Python script dependencies without creating a full project structure
Add PEP 723 dependency metadata as comments at the top of the script \(e.g., \`\# /// script\\n\# dependencies = \["requests>=2.0"\]\\n\# ///\`\), then run with \`uv run --python 3.11 script.py\` which automatically creates an ephemeral virtual environment and installs the declared dependencies.
Journey Context:
Traditionally, single Python scripts with external dependencies require manual virtual environment creation, \`pip install\`, and activation boilerplate, or using \`pipx\` which requires global installation. PEP 723 \(accepted 2024\) introduced a standard for embedding dependency metadata directly in script comments. The \`uv\` tool is currently the only major implementation that supports this natively: it parses the metadata, resolves dependencies, creates a temporary venv \(cached by hash\), and executes the script in one command. This eliminates 'works on my machine' issues by pinning both Python version and dependencies inline without a \`pyproject.toml\`. Tradeoff: requires \`uv\` installation, but this is becoming standard.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T14:18:13.565420+00:00— report_created — created