Migrate from setup.py to pyproject.toml (PEP 621)

Author: mahdirajaeeCreated Mar 28, 2026Updated Sep 5, 2026
Labelsfeature

Description

The project currently uses the legacy setup.py for packaging. The Python packaging ecosystem has standardized on pyproject.toml as defined by PEP 517, PEP 518, and PEP 621.

Why This Matters

  • setuptools deprecation path: setup.py-based builds are being phased out. pip already emits deprecation warnings for projects without pyproject.toml.
  • Build isolation: pyproject.toml enables proper build isolation, preventing dependency conflicts during installation.
  • Declarative metadata: All project metadata (name, version, dependencies, entry points) lives in one standard file instead of being split between setup.py, setup.cfg, and requirements.txt.
  • Tool configuration: Tools like black, ruff, mypy, and pytest can all be configured in pyproject.toml, reducing the number of config files.

Migration

The current setup.py is straightforward enough that migration would be a direct translation:

toml
[build-system]
requires = ["setuptools>=68.0", "wheel"]
build-backend = "setuptools.backends._legacy:_Backend"

[project]
name = "platformio"
dynamic = ["version", "dependencies"]
requires-python = ">=3.9"

The get_pip_dependencies() function and dynamic version import can be handled via setuptools dynamic fields.

This is a non-functional change that modernizes the packaging without affecting runtime behavior.

Source: platformio/platformio-core