python-packaging

Create distributable Python packages with pyproject.toml and publish them to PyPI.

Updated Jul 29, 2026
One-click install
npx skills add https://github.com/MaiconGambini/opencode-harness-guide --skill python-packaging-maicongambini
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-packaging
Source: https://github.com/MaiconGambini/opencode-harness-guide/tree/main/skills/python-packaging
Command: npx skills add https://github.com/MaiconGambini/opencode-harness-guide --skill python-packaging-maicongambini

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Structuring, building, and publishing Python packages involves many moving parts—project layout, build backends, metadata, versioning, and PyPI uploads—and mistakes in any step produce broken or uninstallable distributions. This Skill provides complete patterns and checklists that guide you from an empty directory to a published package. ## Core Features & Use Cases - Project Structure & Configuration: Set up src-layout or flat-layout packages with complete pyproject.toml files covering metadata, dependencies, entry points, and tool configuration for Black, Ruff, MyPy, and pytest. - CLI Tools & Advanced Packaging: Register command-line entry points with Click or argparse, include package data files, create namespace packages, and build C extensions. - Build & Publish Workflows: Build wheels and source distributions with python -m build, validate with twine, publish to TestPyPI and PyPI, and automate releases with GitHub Actions. - Use Case: You wrote a utility library and want teammates to install it with pip. Use this Skill to generate a src-layout project with pyproject.toml, add a CLI entry point, build the wheel, and publish it to PyPI with an automated GitHub Actions release workflow. ## Quick Start Use the python-packaging skill to scaffold a src-layout package with pyproject.toml and show me how to build and publish it to TestPyPI.

Frequently Asked Questions about python-packaging

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Python package with pyproject.toml?

Create a src-layout directory with your package under src/, then add a pyproject.toml declaring the build-system (setuptools), project metadata (name, version, dependencies), and package discovery via [tool.setuptools.packages.find] with where = ["src"]. Install it locally with pip install -e .

How to publish a Python package to PyPI?

Build distributions with python -m build, validate them with twine check dist/*, then upload with twine upload dist/* using an API token. Test first on TestPyPI with twine upload --repository testpypi dist/* before publishing to production PyPI.

Should I use src layout or flat layout for Python packages?

Src layout (src/package_name/) is recommended because it prevents accidentally importing from the source tree and produces cleaner test imports. Flat layout is simpler but lets you import the package without installing it, which can mask packaging errors.

setuptools vs hatchling vs flit for Python packaging?

Setuptools is the traditional, widely used backend with the most configuration options. Hatchling is modern and opinionated, while flit is lightweight and suited to pure-Python packages. All are declared in the [build-system] table of pyproject.toml.

How do I add a command-line script to my Python package?

Define a main function in your package (using Click or argparse) and register it under [project.scripts] in pyproject.toml, for example my-tool = "my_package.cli:main". After installation, the command becomes available in the shell.

Why does my package fail to install from the built wheel?

Common causes are missing package-data declarations, incorrect packages.find configuration, or unlisted dependencies. Test installation in a clean virtual environment with pip install dist/*.whl and verify imports and CLI entry points before publishing.