Skills · Coding

Python Packaging

Unverified30/40

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.

Originally by wshobson · MIT

Claude CodePartialHas SKILL.md but declares no allowed-tools — Claude Code will ask for permission each time
CursorPartialPlain prose you can paste in — but no Cursor rules file
CodexPartialPlain prose you can paste in — but no AGENTS.md
Gemini CLIPartialPlain prose you can paste in
CopilotPartialPlain prose you can paste in — but no Copilot instructions file
npx agentalley add python-packaging

This command does not work yet — the CLI is still being built. Until then, use Raw in the reader below to take the file.

Who is stuck, and on what

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 whole source

No sign-in, no blur, nothing truncated
python-packaging/SKILL.md167 lines3.8 KBRawView on GitHub
Frontmatter — 2 properties
namepython-packaging
descriptionCreate 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.
1---
2name: python-packaging
3description: 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---A5No allowed-tools declared — no way to tell what this skill may touch
5 
6# Python Packaging
7 
8Comprehensive 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```
56my-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```toml
71[build-system]
72requires = ["setuptools>=61.0"]
73build-backend = "setuptools.build_meta"
74 
75[project]
76name = "my-package"
77version = "0.1.0"
78description = "A short description"
79authors = [{name = "Your Name", email = "[email protected]"}]
80readme = "README.md"
81requires-python = ">=3.8"
82dependencies = [
83 "requests>=2.28.0",
84]
85 
86[project.optional-dependencies]
87dev = [
88 "pytest>=7.0",
89 "black>=22.0",
90]
91```
92 
93## Package Structure Patterns
94 
95### Pattern 1: Source Layout (Recommended)
96 
97```
98my-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```toml
126[tool.setuptools.packages.find]
127where = ["src"]
128```
129 
130### Pattern 2: Flat Layout
131 
132```
133my-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```
151project/
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 
165Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
166 
167 

Reviews

Installed this one?Write the first review and take the Trailblazer badge.

Reviews only open after a real install, so this is empty — and we leave it empty rather than invent one.

Alternatives

Also in Coding