pyproject.toml

Replaces requirements.txt

To install pip install -e .

my_project/
├── pyproject.toml
└── my_package/
    ├── __init__.py
    └── main.py

   1 # my_package/main.py
   2 
   3 def say_hello():
   4     print("Hello from the world of TOML-configured Python!")
   5 
   6 if __name__ == "__main__":
   7     say_hello()

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

[project]
name = "my_hello_app"
version = "0.1.0"
dependencies = []

[project.scripts]
# This creates a command 'hello-world' that runs say_hello()
hello-world = "my_package.main:say_hello"

[tool.setuptools]
packages = ["my_package"]

Other example

hello_project/
├── pyproject.toml
├── Makefile
├── .gitignore
├── src/
│   └── main.py
└── tests/
    └── test_main.py

[project]
name = "hello_world_example"
version = "0.1.0"
dependencies = []

[project.optional-dependencies]
dev = [
    "coverage",
    "ruff",
]

[tool.ruff]
target-version = "py310"
lint.select = ["E", "F", "I"]
line-length = 88

[tool.coverage.run]
source = ["src"]
branch = true

[tool.coverage.report]
show_missing = true

Python/pyproject.toml (last edited 2026-02-25 20:26:43 by vitor)