Skip to main content
Python Packaging Modernization

Convert pyproject.toml to setup.py Converter

Easily convert pyproject toml to setup py, manage pyproject toml dependencies, validate PEP 621 pyproject toml schema, and explore live pyproject toml example templates.

Presets:
Input: pyproject.toml
Generated: setup.py
Package Name:

-

Version:

-

Dependencies Count:

0

Build Backend:

setuptools.build_meta

Python Packaging Evolution: setup py or pyproject toml?

For over two decades, the Python community used setup.py for package configuration and distribution. However, running arbitrary Python code during the build process caused serious dependency resolution and security bottlenecks. In response, PEP 518 and PEP 621 introduced pyproject toml as the universal, static declarative standard.

When deciding whether to use setup py or pyproject toml, PyPA recommends adopting pyproject.toml for all new projects. However, legacy deployment pipelines, enterprise packaging mirrors, or air-gapped systems still require standard setup.py files. This tool bridges both worlds by automating the process to convert pyproject toml to setup py.

Declaring Dependencies in pyproject toml

Handling pyproject toml dependencies under the PEP 621 specification uses a standardized array of PEP 508 requirement strings:

[project]
dependencies = [
  "requests >= 2.28.0",
  "pydantic >= 2.0.0",
  "click >= 8.1.0"
]

Our parser automatically translates these into the legacy install_requires list in setup.py or install_requires key in setup.cfg.

Packages Discovery & setup cfg pyproject toml Mapping

When configuring packages pyproject toml, modern Setuptools 61+ supports automatic package discovery. When transitioning between setup cfg pyproject toml configurations, Setuptools finds all Python modules under the src/ directory or project root.

This tool also validates compliance with the official pyproject toml schema, ensuring your metadata fields (like description, authors, license, and scripts) align seamlessly.

Real-World pyproject toml Example

Here is a comprehensive pyproject toml example showcasing the PEP 621 declarative specification:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "my-awesome-tool"
version = "1.0.0"
description = "A high-performance Python analytics utility."
readme = "README.md"
requires-python = ">=3.9"
authors = [
  { name = "Developer", email = "dev@example.com" }
]
dependencies = [
  "httpx>=0.24.0",
  "rich>=13.0.0"
]

[project.scripts]
mytool = "my_awesome_tool.cli:main"

Frequently Asked Questions

Can I still install a package if it only has a pyproject.toml and no setup.py? ▼

Yes! Modern pip (version 19.0+) fully supports PEP 517 build systems. Running `pip install .` or `pip install -e .` will automatically build the package using the backend defined in your pyproject.toml [build-system].

What build backends are supported by pyproject.toml? ▼

Common build backends include Setuptools (setuptools.build_meta), Poetry (poetry.core.masonry.api), Hatch (hatchling.build), Flit (flit_core.buildapi), and Meson-Python.

How does this converter handle packages pyproject toml and find_packages? ▼

In setup.py, it generates packages=find_packages(), which inspects directories for __init__.py files, replicating modern declarative package discovery.