Create distributable Python packages with proper project
Python packaging

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.
--- name: python-packaging description: 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. --- # 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
Overview
Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI.
Manual install (npx, ZIP)
Claude Code
npx skills add wshobson/agents --skill python-packaging -g -a claude-codeClaude Code (manual)
mkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/python-development/skills/python-packagingWindows (PowerShell)
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/2b11bf76aa65dba7903d/python-packaging.zip" -OutFile "$env:TEMP\python-packaging.zip"; Expand-Archive "$env:TEMP\python-packaging.zip" -DestinationPath "$HOME\.claude\skills" -ForceClaude.ai / desktop
Codex, Cursor, other agents
Connects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md3.8 KBreferences/2 files · 13.9 KB
Read the files here
SKILL.md
Show the full text167 lines
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
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.
| 1 | |
| 2 | name python-packaging |
| 3 | description 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. |
| 4 | |
| 5 | |
| 6 | # Python Packaging |
| 7 | |
| 8 | Comprehensive guide to creating, structuring, and distributing Python packages using modern packaging tools, pyproject.toml, and publishing to PyPI. |
| 9 | |
| 10 | ## When to Use This Skill |
| 11 | |
| 12 | Creating Python libraries for distribution |
| 13 | Building command-line tools with entry points |
| 14 | Publishing packages to PyPI or private repositories |
| 15 | Setting up Python project structure |
| 16 | Creating installable packages with dependencies |
| 17 | Building wheels and source distributions |
| 18 | Versioning and releasing Python packages |
| 19 | Creating namespace packages |
| 20 | Implementing package metadata and classifiers |
| 21 | |
| 22 | ## Core Concepts |
| 23 | |
| 24 | ### 1. Package Structure |
| 25 | |
| 26 | **Source layout**: `src/package_name/` (recommended) |
| 27 | **Flat layout**: `package_name/` (simpler but less flexible) |
| 28 | **Package metadata**: pyproject.toml, setup.py, or setup.cfg |
| 29 | **Distribution formats**: wheel (.whl) and source distribution (.tar.gz) |
| 30 | |
| 31 | ### 2. Modern Packaging Standards |
| 32 | |
| 33 | **PEP 517/518**: Build system requirements |
| 34 | **PEP 621**: Metadata in pyproject.toml |
| 35 | **PEP 660**: Editable installs |
| 36 | **pyproject.toml**: Single source of configuration |
| 37 | |
| 38 | ### 3. Build Backends |
| 39 | |
| 40 | **setuptools**: Traditional, widely used |
| 41 | **hatchling**: Modern, opinionated |
| 42 | **flit**: Lightweight, for pure Python |
| 43 | **poetry**: Dependency management + packaging |
| 44 | |
| 45 | ### 4. Distribution |
| 46 | |
| 47 | **PyPI**: Python Package Index (public) |
| 48 | **TestPyPI**: Testing before production |
| 49 | **Private repositories**: JFrog, AWS CodeArtifact, etc. |
| 50 | |
| 51 | ## Quick Start |
| 52 | |
| 53 | ### Minimal Package Structure |
| 54 | |
| 55 | |
| 56 | my-package/ |
| 57 | ├── pyproject.toml |
| 58 | ├── README.md |
| 59 | ├── LICENSE |
| 60 | ├── src/ |
| 61 | │ └── my_package/ |
| 62 | │ ├── __init__.py |
| 63 | │ └── module.py |
| 64 | └── tests/ |
| 65 | └── test_module.py |
| 66 | |
| 67 | |
| 68 | ### Minimal pyproject.toml |
| 69 | |
| 70 | |
| 71 | [build-system] |
| 72 | requires = ["setuptools>=61.0"] |
| 73 | build-backend = "setuptools.build_meta" |
| 74 | |
| 75 | [project] |
| 76 | name = "my-package" |
| 77 | version = "0.1.0" |
| 78 | description = "A short description" |
| 79 | authors = [{name = "Your Name", email = "[email protected]"}] |
| 80 | readme = "README.md" |
| 81 | requires-python = ">=3.8" |
| 82 | dependencies = [ |
| 83 | "requests>=2.28.0", |
| 84 | ] |
| 85 | |
| 86 | [project.optional-dependencies] |
| 87 | dev = [ |
| 88 | "pytest>=7.0", |
| 89 | "black>=22.0", |
| 90 | ] |
| 91 | |
| 92 | |
| 93 | ## Package Structure Patterns |
| 94 | |
| 95 | ### Pattern 1: Source Layout (Recommended) |
| 96 | |
| 97 | |
| 98 | my-package/ |
| 99 | ├── pyproject.toml |
| 100 | ├── README.md |
| 101 | ├── LICENSE |
| 102 | ├── .gitignore |
| 103 | ├── src/ |
| 104 | │ └── my_package/ |
| 105 | │ ├── __init__.py |
| 106 | │ ├── core.py |
| 107 | │ ├── utils.py |
| 108 | │ └── py.typed # For type hints |
| 109 | ├── tests/ |
| 110 | │ ├── __init__.py |
| 111 | │ ├── test_core.py |
| 112 | │ └── test_utils.py |
| 113 | └── docs/ |
| 114 | └── index.md |
| 115 | |
| 116 | |
| 117 | **Advantages:** |
| 118 | |
| 119 | Prevents accidentally importing from source |
| 120 | Cleaner test imports |
| 121 | Better isolation |
| 122 | |
| 123 | **pyproject.toml for source layout:** |
| 124 | |
| 125 | |
| 126 | [tool.setuptools.packages.find] |
| 127 | where = ["src"] |
| 128 | |
| 129 | |
| 130 | ### Pattern 2: Flat Layout |
| 131 | |
| 132 | |
| 133 | my-package/ |
| 134 | ├── pyproject.toml |
| 135 | ├── README.md |
| 136 | ├── my_package/ |
| 137 | │ ├── __init__.py |
| 138 | │ └── module.py |
| 139 | └── tests/ |
| 140 | └── test_module.py |
| 141 | |
| 142 | |
| 143 | **Simpler but:** |
| 144 | |
| 145 | Can import package without installing |
| 146 | Less professional for libraries |
| 147 | |
| 148 | ### Pattern 3: Multi-Package Project |
| 149 | |
| 150 | |
| 151 | project/ |
| 152 | ├── pyproject.toml |
| 153 | ├── packages/ |
| 154 | │ ├── package-a/ |
| 155 | │ │ └── src/ |
| 156 | │ │ └── package_a/ |
| 157 | │ └── package-b/ |
| 158 | │ └── src/ |
| 159 | │ └── package_b/ |
| 160 | └── tests/ |
| 161 | |
| 162 | |
| 163 | ## Detailed patterns and worked examples |
| 164 | |
| 165 | Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient. |
| 166 | |
| 167 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillExtract text, tables, metadataXberg Document Extraction
SkillMove code from one implementation to another functionCode migration
SkillManages Ahrefs API usage in Python using ahrefs-python
MCPDocx LLM translatoradeu
SkillCreate an Amazon-compliant white-background main imageAmazon White-Background Main Image · 亚马逊白底主图
MCPOfficial monorepo of SDKs, CLISendmux sdkMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns