Search GimmeJob

Type at least 2 characters. Enter also searches by meaning.
Python interview question

What is `pyproject.toml`, and what did it replace in modern Python packaging?

Answer

`pyproject.toml` is the standardized, tool-agnostic configuration file (PEP 518 for the build-system table, PEP 621 for project metadata) that a Python project uses to declare its build backend, dependencies, name, version and other metadata in one place. It is the modern standard surface for this, largely replacing the older pattern of a hand-written `setup.py` script plus scattered `setup.cfg` sections as the primary place project metadata lives — but `setup.py` and Setuptools themselves are not deprecated; what the Python Packaging Authority has specifically deprecated is invoking `setup.py` directly as a command (`python setup.py install`, `python setup.py sdist`), in favor of standardized build-frontend tools that read `pyproject.toml`. Modern tools like linters, formatters and test runners also increasingly read their own configuration from `pyproject.toml`, and the standardized `[dependency-groups]` table (PEP 735) now lets a project declare groups of development-only dependencies — test, lint, docs — there as well.

Strong answer includes

  • standardized config file for build system and project metadata (PEP 518/621)
  • setup.py and Setuptools are not deprecated — only invoking setup.py directly as a command is
  • [dependency-groups] (PEP 735) now lets pyproject.toml declare dev dependency groups too

Practical example

A single `pyproject.toml` can declare the build backend under

Python example
[build-system]

, the package metadata and dependencies under

Python example
[project]

, and pytest or ruff configuration under

Python example
[tool.pytest.ini_options]

or

Python example
[tool.ruff]

, all in one file.

#packaging#tooling

Sources

Python Packaging User GuidePython Packaging Authority · Project metadata, wheels, dependency and environment management practices