Why You Should Replace setup.py with pyproject.toml in Modern Python Projects
The article explains why the traditional setup.py build script is outdated, outlines the problems it causes, and shows how adopting a declarative pyproject.toml file modernizes Python packaging, improves maintainability, and unifies tool configuration.
Many projects still contain a setup.py file, which serves as a simple build entry point by writing the project name, version, dependencies, package information, and entry points into a Python script for installation and packaging.
This traditional approach was common for a long time but brings problems: it is hard to maintain, opaque, inconsistent, and tools cannot safely analyze what code will be executed.
These issues no longer fit the modern Python ecosystem, especially in 2026, and projects should move away from setup.py.
What we need now is a universal, modern project file that can define metadata and also:
Manage project configuration declaratively (no Python script needed for build logic).
Replace the deprecated setup.py (and the discouraged setup.cfg).
Define the build system so tools know how to build without executing arbitrary scripts.
Host unified configuration for additional tools such as Ruff, pytest, mypy, Black, isort, etc.
Make build results more predictable, safer, and easier to automate.
The answer to all of this is the pyproject.toml file.
pyproject.tomlhas become the modern standard recommended by the official Python documentation, packaging tool authors, and ecosystem maintainers. Whether you are building an application, library, CLI tool, or internal component, using pyproject.toml makes your project structure clearer, simpler, and more maintainable.
If your project still relies on setup.py, now is an excellent time to upgrade, switching from the legacy script‑based build to a unified, modern, and transparent Python ecosystem.
DevOps Engineer
DevOps engineer, Pythonista and FOSS contributor. Created cpp-linter, commit-check, etc.; contributed to PyPA.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
