Generated banner for Python Packaging
Generated logo for Python Packaging

Python Packaging

Seth HobsonCommunityCreated by Seth Hobson

  • Skill
  • Tool integration
  • Software development
  • MIT
  • Low risk

From the author

Create distributable Python packages with proper project structure, setup.py/pyproject.toml, and publishing to PyPI. Use when packaging Python libraries, creating CLI tools, or distributing Python code.
— the description by Seth Hobson

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a structured approach to Python packaging, focusing on modern standards like PEP 517, 518, and 621. It covers project layout strategies, configuration via pyproject.toml, dependency management, and the creation of distributable formats like wheels and source distributions. The guide includes patterns for handling data files, C extensions, namespace packages, and versioning, alongside instructions for publishing to repositories like PyPI.

What it does

  • Defines project directory structures using source or flat layouts
  • Configures build systems and metadata using pyproject.toml
  • Manages dependencies and optional development environments
  • Implements versioning strategies including semantic and git-based versioning
  • Provides patterns for CLI entry points and C extensions
  • Guides the process of building and testing installable distribution packages

When to use it

  • When you need to turn a Python project into an installable library
  • When building command-line tools that require entry points
  • When preparing a Python project for distribution on PyPI or private repositories
  • When standardizing project configuration across multiple Python modules

Advantages

  • Adheres to modern Python packaging standards (PEP 517/518/621)
  • Supports flexible project layouts for better code isolation
  • Centralizes project configuration in a single pyproject.toml file
  • Includes patterns for complex requirements like C extensions and data files

Usage examples

“How do I set up a new Python project for distribution?”
The agent provides a recommended source-layout structure and a template for the pyproject.toml file to define project metadata and dependencies.
“How can I include non-Python data files in my package?”
The agent explains how to use the tool.setuptools.package-data configuration in pyproject.toml and how to access those files using importlib.resources.
“How do I add a CLI command to my Python package?”
The agent shows how to define entry points in the project.scripts section of pyproject.toml to map commands to specific functions.
“How do I manage versions using Git tags?”
The agent demonstrates the use of setuptools-scm to automatically derive package versions from Git tags and commits.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/wshobson/python-packaging/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip python-packaging.zip -d .agents/skills

Documentation by Seth Hobson

Python Packaging

Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI.

When to Use This Skill

  • Creating Python libraries for distribution

  • Building command-line tools with entry points

  • Publishing packages to PyPI or private repositories

  • Setting up Python project structure

  • Creating installable packages with dependencies

  • Building wheels and source distributions

  • Versioning and releasing Python packages

  • Creating namespace packages

  • Implementing package metadata and classifiers

Core Concepts

1. Package Structure
  • Source layout: src/package_name/ (recommended)

  • Flat layout: package_name/ (simpler but less flexible)

  • Package metadata: pyproject.toml, setup.py, or setup.cfg

  • Distribution formats: wheel (.whl) and source distribution (.tar.gz)

2. Modern Packaging Standards
  • PEP 517/518: Build system requirements

  • PEP 621: Metadata in pyproject.toml

  • PEP 660: Editable installs

  • pyproject.toml: Single source of configuration

3. Build Backends
  • setuptools: Traditional, widely used

  • hatchling: Modern, opinionated

  • flit: Lightweight, for pure Python

  • poetry: Dependency management + packaging

4. Distribution
  • PyPI: Python Package Index (public)

  • TestPyPI: Testing before production

  • Private repositories: JFrog, AWS CodeArtifact, etc.

Quick Start

Minimal Package Structure
my-package/
├── pyproject.toml
├── README.md
├── LICENSE
├── src/
│   └── my_package/
│       ├── __init__.py
│       └── module.py
└── tests/
    └── test_module.py
Minimal pyproject.toml
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "my-package"
version = "0.1.0"
description = "A short description"
authors = [{name = "Your Name", email = "[email protected]"}]
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
    "requests>=2.28.0",
]

[project.optional-dependencies]
dev = [
    "pytest>=7.0",
    "black>=22.0",
]

Package Structure Patterns

my-package/
├── pyproject.toml
├── README.md
├── LICENSE
├── .gitignore
├── src/
│   └── my_package/
│       ├── __init__.py
│       ├── core.py
│       ├── utils.py
│       └── py.typed          # For type hints
├── tests/
│   ├── __init__.py
│   ├── test_core.py
│   └── test_utils.py
└── docs/
    └── index.md

Advantages:

  • Prevents accidentally importing from source

  • Cleaner test imports

  • Better isolation

pyproject.toml for source layout:

[tool.setuptools.packages.find]
where = ["src"]
Pattern 2: Flat Layout
my-package/
├── pyproject.toml
├── README.md
├── my_package/
│   ├── __init__.py
│   └── module.py
└── tests/
    └── test_module.py

Simpler but:

  • Can import package without installing

  • Less professional for libraries

Pattern 3: Multi-Package Project
project/
├── pyproject.toml
├── packages/
│   ├── package-a/
│   │   └── src/
│   │       └── package_a/
│   └── package-b/
│       └── src/
│           └── package_b/
└── tests/

Detailed patterns and worked examples

Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.

Files

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs Python

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Created by
Seth Hobson
Publisher
Seth Hobson (Community)
Source
wshobson/agents · plugins/python-development/skills/python-packaging · commit 4bde316
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Seth Hobson or Seth Hobson.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download python-packaging.zip