DEV Community

TildAlice
TildAlice

Posted on • Originally published at tildalice.io

setup.py to pyproject.toml: PEP 621 Migration Guide

Why I Finally Ditched setup.py After 6 Years

My 2019 package still had a setup.py with hardcoded version strings scattered across three files. Every release meant manually updating setup.py, __init__.py, and docs/conf.py. Then I'd inevitably push a git tag that didn't match the actual version because I forgot to update one of them.

PEP 621 (finalized in 2021, widely adopted by 2023) solved this with pyproject.toml — a single config file that replaces setup.py, setup.cfg, MANIFEST.in, and half your build scripts. No more python setup.py install footguns. No more "why is my package metadata different on PyPI vs my local install?"

But the migration isn't just copy-paste. The old setuptools APIs leak assumptions (like dynamic version extraction) that break if you move them blindly. Here's what actually works.

A developer typing code on a laptop with a Python book beside in an office.

Photo by Christina Morillo on Pexels

The Old Way: setup.py Archaeology

A typical 2019-era setup.py looked like this:


python
from setuptools import setup, find_packages
import re

# Extract version from __init__.py

---

*Continue reading the full article on [TildAlice](https://tildalice.io/setuptools-to-pyproject-toml-pep621-migration/)*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)