python-packaging

Create, build, and publish Python packages using pyproject.toml and PyPI.

Updated Jun 12, 2026
One-click install
npx skills add https://github.com/bilacchi/agents-skills --skill python-packaging-bilacchi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: python-packaging
Source: https://github.com/bilacchi/agents-skills/tree/main/skills/python-packaging
Command: npx skills add https://github.com/bilacchi/agents-skills --skill python-packaging-bilacchi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It guides developers through structuring, building, and distributing Python packages correctly, avoiding common mistakes with pyproject.toml configuration, versioning, and PyPI publishing. ## Core Features & Use Cases - Project Structure Patterns: Set up src layout, flat layout, namespace packages, and multi-package projects with correct setuptools configuration. - CLI Tool Creation: Register command-line entry points using Click or argparse and expose them via project.scripts. - Build and Publish Workflows: Build wheels and source distributions with python -m build, validate with twine, and publish to PyPI, TestPyPI, or private indexes. - Use Case: You have written a Python library and want to release it. Use this Skill to generate a complete pyproject.toml, add a CLI entry point, build the wheel, and publish it to PyPI with a GitHub Actions workflow. ## Quick Start Help me create a publishable Python package with pyproject.toml, a src layout, and a CLI entry point, then show me how to build and upload it to PyPI.

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 pyproject.toml with a [build-system] section specifying setuptools, then add a [project] table with name, version, description, and dependencies. Use a src layout with [tool.setuptools.packages.find] where = ["src"] to locate your package.

How to publish a Python package to PyPI?▼

Build the package with python -m build, verify it with twine check dist/*, then upload with twine upload dist/*. Test first on TestPyPI using twine upload --repository testpypi, and authenticate with an API token instead of a password.

What is the difference between src layout and flat layout in Python packaging?▼

Src layout places the package under src/package_name/, preventing accidental imports from the working directory and giving cleaner test isolation. Flat layout puts the package at the project root, which is simpler but riskier for libraries.

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

Define a [project.scripts] table in pyproject.toml mapping a command name to a function, such as my-cli = "my_package.cli:main". After installation, the command becomes available in the shell and can be built with Click or argparse.

How do I include data files in a Python wheel?▼

Declare them under [tool.setuptools.package-data], for example my_package = ["data/*.json", "py.typed"]. At runtime, read them with importlib.resources.files("my_package").joinpath("data/config.json") instead of relative file paths.

When should I use setuptools-scm for versioning?▼

Use setuptools-scm when you want versions derived from git tags instead of hardcoding them. Add it to build-system requires, set dynamic = ["version"], and it generates versions like 1.0.1.dev3+g1234567 for commits after a tag.