self-contained-python-script

Create self-contained Python scripts with PEP 723 inline metadata.

60|2|Updated Apr 16, 2015
One-click install
npx skills add https://github.com/davidgasquez/dotfiles --skill self-contained-python-script
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: self-contained-python-script
Source: https://github.com/davidgasquez/dotfiles/tree/main/agents/skills/self-contained-python-script
Command: npx skills add https://github.com/davidgasquez/dotfiles --skill self-contained-python-script

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill simplifies the creation and execution of Python scripts by allowing them to declare their own dependencies directly within the script file, eliminating the need for manual environment setup.

Core Features & Use Cases

  • PEP 723 Compliance: Utilizes inline metadata for dependency declaration.
  • Dependency Management: Automatically installs required packages using uv.
  • Use Case: Quickly create and run a Python script that requires the httpx library without first creating a virtual environment or running pip install.

Quick Start

Create a Python script with the provided shebang and metadata to define its dependencies.

Frequently Asked Questions about self-contained-python-script

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a Python script with dependencies without setting up a virtual environment?

You can run a Python script with dependencies without a virtual environment by using PEP 723 inline metadata to declare packages and executing it with uv. This automatically installs the required libraries in an isolated environment at runtime.

What is PEP 723 inline metadata for self-contained Python scripts?

PEP 723 inline metadata is a standard for declaring dependencies directly within a Python script file. It eliminates manual environment setup by allowing tools like uv to read the script header and automatically install required packages.

How do I create a Python script that automatically installs packages using uv?

To create a Python script that automatically installs packages using uv, add the provided uv shebang and PEP 723 inline metadata to your file. This configures the script to run in an isolated environment with the declared dependencies.

Can I share a single Python file that requires external libraries like httpx?

Yes, you can share a single Python file requiring external libraries like httpx by using PEP 23 inline metadata. The script becomes self-contained and reproducible, executing correctly on other systems without requiring manual pip installs.

Does uv support executing standalone Python CLIs with declared dependencies?

Yes, uv supports executing standalone Python CLIs with declared dependencies. It reads the PEP 723 metadata embedded in the script to manage the isolated environment and automatically satisfy the required packages.

What are the limitations of using PEP 723 for Python dependency management?

PEP 723 is limited to single-file Python scripts and does not replace full project environments. It is best suited for standalone tools and CLIs managed by uv, rather than complex applications requiring multi-file dependency tracking.