Luke Oliff.

TIL: Creating Python Packages With pyproject.toml

·TIL·1 min read·Luke Oliff

setup.py is the old way. pyproject.toml is the standard for Python packaging.

[build-system]
requires = ["setuptools>=61.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "deepgram-sdk"
version = "3.0.0"
description = "Python SDK for the Deepgram API"
readme = "README.md"
requires-python = ">=3.8"
dependencies = [
    "aiohttp>=3.8.0"
]

Install in editable mode.

pip install -e .

Editable mode means changes are reflected immediately, like npm link but for Python.

pip install build
python -m build

Build distribution files. Upload them with twine.

Does pyproject.toml replace setup.cfg?

Yes. PEP 621 defines a standard [project] table that replaces setup.cfg for metadata.