Pyproject.toml

From NovaOrdis Knowledge Base
Jump to navigation Jump to search

External

Internal

Overview

pyproject.toml is a file that specifies required packages, scripts, plugins and URLs.

Build Backend Configuration

pyproject.toml tells the build frontend tool which backend to use for the specific project it is part of.

The requires key is a list of packages that are needed to build the package. The frontend should install them automatically when building the package. What about the dependencies specified in requirements.txt? The build-backend key is the name of the Python object that frontends will use to perform the build.

Additional configuration of the build tool will either be in a tool section of the pyproject.toml, or in a special file defined by the build tool. For example, when using setuptools as build backend, additional configuration may be added to a setup.py or setup.cfg file.

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Project Metadata

[project]
name = "ofddi"
version = "0.1.0"
authors = [
  { name="Ovidiu Feodorov", email="ovidiu@example.com" },
]
description = "DDI"
readme = "README.md"
requires-python = ">=3.12"
classifiers = [
    "Programming Language :: Python :: 3",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent",
]

[project.urls]
Homepage = "https://github.com/ovidiuf/ofddi"
Issues = "https://github.com/ovidiuf/ofddi/issues"

name

name is the distribution name of the package. For more details, see:

Python Language Modularization | Distribution Packages

version

See:

Python Language Modularization | Distribution Package Version

authors

Used to identify the author of the package. A name and an email for each author is required.

description

A short, one-sentence summary of the package.

readme

A path to a file containing a detailed description of the package. This is shown on the package detail page on PyPI. In this case, the description is loaded from README.md, which is a common pattern. There also is a more advanced table form.

requires-python

The versions of Python supported by the project. An installer like pip will look back through older versions of packages until it finds one that has a matching Python version.

classifiers

This section provides the index and pip additional metadata about the package. In this case, the package is only compatible with Python 3, is licensed under the MIT license, and is OS-independent. You should always include at least which version(s) of Python your package works on, which license your package is available under, and which operating systems your package will work on. For a complete list of classifiers, see:

https://pypi.org/classifiers

urls

Extra links to show on PyPI. Generally this could be to the source, documentation, issue trackers, etc.