Python Packaging with pyproject.toml: The Modern Standard
Setup.py is legacy. Pyproject.toml is the modern way to configure Python projects. Here is how I set up packaging, dependencies, and tooling. Python packaging went through years of confusion. setup.py , setup.cfg , requirements.txt , Pipfile , and various tool-specific files. PEP 518 introduced pyproject.toml as a single configuration file for the entire build system, and PEP 621 standardized how project metadata is declared in it. I now start every Python project with a pyproject.toml and no setup.py . The Basic Structure A pyproject.toml file uses TOML format. The [project] table contains metadata that PEP 621 standardized. name, version, description, dependencies. The [build-system] table tells pip which build backend to use. [build-system] requires = ['hatchling'] build-backend = 'hatchling.build' [project] name = 'my-package' version = '1.0.0' description = 'A tool for processing data' readme = 'README.md' requires-python = '>=3.10' license = {text = 'MIT'} authors = [{name = 'Mei Zhang', email = 'mei@example.com'}] dependencies = [ 'requests>=2.28', 'pydantic>=2.0', ] The build-system section is what pip uses to build the package. Common backends are hatchling , setuptools , flit , and poetry-core . I use hatchling for new projects because it is fast and…