python-packaging

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

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Structuring, building, and distributing Python code as an installable package involves many configuration details—pyproject.toml metadata, build backends, entry points, versioning, and PyPI publishing—that are easy to get wrong without a clear guide. ## Core Features & Use Cases - Project Structure Templates: Source layout, flat layout, and multi-package patterns with complete pyproject.toml examples including dependencies, classifiers, and tool configuration. - CLI Tool Creation: Register command-line entry points using Click or argparse so installed packages expose executable commands. - Build & Publish Workflows: Build wheels and source distributions with python -m build, validate with twine, and publish to PyPI or TestPyPI, including GitHub Actions automation. - Advanced Patterns: Data files, namespace packages, C extensions, dynamic git-based versioning, and private package indexes via the references guide. - Use Case: You wrote a Python utility and want teammates to install it with pip. Use this Skill to scaffold the src layout, write a complete pyproject.toml, add a CLI entry point, build the wheel, and publish it to PyPI. ## Quick Start Ask the AI to create a new Python package with a src layout, a complete pyproject.toml, and a CLI entry point, then show how to build and publish 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 src layout with your package under src/package_name, then add a pyproject.toml declaring the build-system (setuptools), project metadata (name, version, dependencies), and [tool.setuptools.packages.find] with where = ["src"]. Build it with python -m build.

How do I 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 the production release.

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 allows importing without installing.

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

Define a main function in a module such as cli.py using Click or argparse, then register it in pyproject.toml under [project.scripts], for example my-tool = "my_package.cli:main". After pip install, the command becomes available in the shell.

setuptools vs hatchling vs poetry: which build backend should I use?

Setuptools is the traditional, widely supported backend declared in the build-system table. Hatchling is a modern opinionated option, flit suits lightweight pure-Python packages, and poetry combines dependency management with packaging. All are configured via pyproject.toml.

How do I include data files in a Python package?

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