DevTools Logo

pyproject.toml Generator

pyproject.toml Generator

Generate a complete, commented PEP 621 pyproject.toml.

Runs in your browser
Try an example

Input

1 line · 10 chars

Result

22 lines · 405 chars

Pyproject Generator turns form fields into a complete, commented pyproject.toml. Pick a build backend and the emitted build-system and tool sections follow it; fill in PEP 621 project metadata, dependencies, optional-dependency groups and console scripts, and toggle pytest, ruff, mypy or coverage sections. The output is checked for TOML validity before you copy or download it, and per-line dependency validation catches malformed PEP 508 requirements.

Examples

Input
backend=setuptools, name=demo
Output
[build-system]
requires = ["setuptools>=61"]
build-backend = "setuptools.build_meta"

Every generated file starts with the correct build-system table.

Input
dependencies: requests>=2, click
Output
dependencies = [
  "requests>=2",
  "click",
]

Requirements are emitted as a TOML array, one per line.

Input
script: mycli = mypkg.cli:main
Output
[project.scripts]
mycli = "mypkg.cli:main"

Console scripts map names to module:function entry points.

About this tool

Python packaging moved from setup.py to pyproject.toml, but the PEP 621 table syntax is easy to get subtly wrong. This generator starts from a form and emits a valid, commented file you can adapt rather than a fragment you have to assemble.

Choosing a backend matters: setuptools, hatchling, poetry-core, flit_core and pdm-backend each use different build-backend strings and different tool sections. The generator keeps those in sync so the emitted file is internally consistent.

Validation is part of the workflow. Dependency lines are checked as PEP 508 requirements and the assembled document is checked for TOML syntax basics before the download button is enabled.

What this tool does not do

  • The TOML check is a structural self-check, not a full TOML parser implementation.
  • The setup.py import helper reads simple literal assignments only; dynamic values and function calls need manual review.
  • Backend-specific options beyond the emitted starter sections are out of scope.

How to use this tool

  1. Pick a backend

    Choose setuptools, hatchling, poetry-core, flit_core or pdm-backend. The tool sections below adapt to that choice.

  2. Fill in metadata

    Set name, version, description, readme, requires-python, authors, license, keywords, classifiers and URLs.

  3. Add dependencies

    Enter one PEP 508 requirement per line and create optional-dependency groups such as dev or test. Console scripts use name = module:function.

  4. Copy or download

    Review the commented TOML preview, fix any flagged lines, then copy or download pyproject.toml.

Use cases

Start a new library

Generate a correct PEP 621 skeleton with the backend and tool sections already wired up.

Migrate from setup.py

Carry name, version and install_requires into a modern pyproject.toml without hand-writing table syntax.

Standardize templates

Create a consistent starting file for internal packages with the same tool configuration across teams.

Build backends

Backendbuild-backend
setuptoolssetuptools.build_meta
hatchlinghatchling.build
poetry-corepoetry.core.masonry.api
flit_coreflit_core.buildapi
pdm-backendpdm.backend

Poetry 2.x supports PEP 621 directly; the emitted note explains the legacy [tool.poetry] alternative.

Common mistakes

Mistake:Mixing the wrong build-backend with tool sections.

Fix:Keep the backend selector authoritative: the emitted [build-system] and the conditional [tool.*] table always match.

Mistake:Putting requirements.txt content into optional-dependencies by accident.

Fix:Core runtime dependencies belong in project.dependencies; only extra groups such as dev or test go under [project.optional-dependencies].

Mistake:Using setuptools without a version constraint.

Fix:PEP 621 metadata support needs a modern setuptools; the emitted requires includes a lower bound.

Frequently asked questions

Which backend should I choose?

Hatchling and flit_core are light and good for most pure-Python libraries. setuptools is the safest default when you need broad tooling compatibility or package data. poetry-core and pdm-backend fit projects already using those workflows. The generator emits the matching build-system and tool sections for whichever you pick.

Where do requirements go now?

Runtime requirements go into the dependencies array under [project] as PEP 508 strings. Development, test and documentation requirements go into [project.optional-dependencies] groups, which users install with syntax like pip install "myproj[dev]".

What is [project.scripts]?

It maps command names to callable entry points, for example mycli = "mypkg.cli:main". Installing the package then creates a mycli command. Use [project.gui-scripts] for GUI launchers.

Do I still need setup.py?

Usually not. With PEP 621 metadata and a build backend that supports it, setup.py can be removed. Some legacy workflows still read it, so keep a shim only if a tool in your pipeline actually requires one.

How do optional-dependencies groups work?

Each group is a key under [project.optional-dependencies] mapped to a list of requirement strings, such as dev = ["pytest>=8", "ruff"]. Consumers install a group with the extras syntax: pip install "package[dev]".

References & standards