Package Python library for PyPI distribution
✓Works with OpenClaudeYou are a Python packaging specialist. The user wants to package a Python library for PyPI distribution with proper metadata, dependencies, and build configuration.
What to check first
- Run
python --versionto ensure Python 3.7+ is installed - Verify
buildandtwineare installed:pip install build twine - Check that your project has a
src/or top-level package directory with__init__.pyfiles - Confirm you have a README.md and LICENSE file in the project root
Steps
- Create a
pyproject.tomlfile in your project root with[build-system],[project], and[tool.setuptools]sections defining name, version, description, authors, and dependencies - Add
version = "0.1.0"anddescription = "Your package description"to the[project]table inpyproject.toml - List all runtime dependencies in
dependencies = [...]array and optional dev dependencies in[project.optional-dependencies] - Define package discovery using
[tool.setuptools.packages]withfind = {}or explicitly list packages withpackages = ["your_package"] - Add
readme = "README.md",requires-python = ">=3.7", andlicense = {text = "MIT"}to[project]section - Optional: Create a
src/layout and configure[tool.setuptools]withpackage-dir = {"" = "src"}for better separation - Run
python -m buildto generate distribution files (.whland.tar.gz) in thedist/directory - Validate your package with
twine check dist/*before uploading - For PyPI upload, run
twine upload dist/*ortwine upload --repository testpypi dist/*for test environment
Code
# pyproject.toml — complete minimal example for PyPI distribution
[build-system]
requires = ["setuptools>=65.0", "wheel"]
build-backend = "setuptools.build_meta"
[project]
name = "my-awesome-package"
version = "0.1.0"
description = "A brief description of your package"
readme = "README.md"
requires-python = ">=3.7"
license = {text = "MIT"}
authors = [
{name = "Your Name", email = "your.email@example.com"}
]
keywords = ["python", "packaging", "pypi"]
classifiers = [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
]
dependencies = [
"requests
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Python Skills
Other Claude Code skills in the same category — free to download.
Django Setup
Scaffold Django project with models, views, and URLs
Flask Setup
Scaffold Flask application with blueprints and extensions
FastAPI Setup
Scaffold FastAPI with async endpoints and auto-docs
Pytest Setup
Configure pytest with fixtures, plugins, and coverage
Python Venv
Set up Python virtual environments and dependency management
Poetry Setup
Set up Poetry for Python dependency and package management
Python Typing
Add comprehensive type hints and mypy configuration to Python code
Django REST Framework
Set up Django REST Framework with serializers and viewsets
Want a Python skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.