Python Packaging
Package Python projects with pyproject.toml and build a wheel to publish to PyPI.
Package Python projects with pyproject.toml and build a wheel to publish to PyPI.
# pyproject.toml
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "mypackage"
version = "1.0.0"
description = "A useful library"
requires-python = ">=3.10"
dependencies = ["requests>=2.28"]
[project.scripts]
mycli = "mypackage.cli:main"
# Build and publish
pip install build twine
python -m build
twine upload dist/*
Use hatch or flit for zero-config packaging — setuptools is still valid but more verbose.