
Python Packaging
FreeEfficiently create and distribute Python packages.
Free · Opens the source repo
What Python Packaging does
The Python Packaging skill provides a comprehensive guide for developers looking to create, structure, and distribute Python packages effectively. This skill focuses on modern packaging standards, including the use of pyproject.toml, which serves as a single source of configuration for your projects. By following the guidelines provided, you can ensure that your Python libraries, command-line tools, and other code distributions are well-structured and easy to manage.
With this skill, you will learn how to set up the appropriate project structure, whether you choose a source layout or a flat layout. The skill covers essential topics like package metadata, distribution formats, and various build backends such as setuptools and poetry. By mastering these concepts, you can streamline your packaging process and ensure compatibility with Python's evolving ecosystem.
The skill also includes practical examples and patterns for creating installable packages with dependencies, versioning, and releasing your packages to PyPI or private repositories. It is particularly useful for developers who are new to Python packaging or those who want to adopt best practices in their workflow. By implementing the strategies outlined in this skill, you can enhance the quality and maintainability of your Python projects.
Whether you're building libraries for public use or internal tools for your organization, this skill equips you with the knowledge to package your Python code efficiently and effectively, ensuring a smooth distribution process.
When to use it
Use this skill when you need to create Python libraries, command-line tools, or any other Python code that requires proper packaging and distribution.
When not to use it
This skill may not be suitable for users looking for a quick solution without understanding the underlying packaging concepts or for those who do not need to distribute Python code.
What you can build with it
Creating a Python Library
Use this skill to set up a well-structured Python library that can be easily distributed and reused.
Building a Command-Line Tool
Follow the guidelines to create a command-line interface tool with proper entry points and dependencies.
Publishing to Private Repositories
Learn how to package and publish your Python projects to private repositories for internal use.
How to install Python Packaging
View source1. Install with the skills CLI
npx skills add wshobson/agents/python-packaging --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by wshobsonPython 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 = "you@example.com"}]
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
Pattern 1: Source Layout (Recommended)
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.
Frequently asked questions about Python Packaging
Similar skills
Spring Boot Testing
Master testing techniques for Spring Boot 4 applications.
GitHub Issues
Manage GitHub issues efficiently with MCP tools.
Geofeed Tuner
Optimize your IP geolocation feeds in CSV format.
Batch Files
Master Windows batch scripting for automation and task management.
Adobe Illustrator Scripting
Automate your Illustrator workflows with ExtendScript.
Plugin Structure
Create and organize Claude Code plugins effectively.
