Pyproject.toml: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 12: Line 12:
<code>pyproject.toml</code> tells the [[Python_Language_Modularization#Build_Frontend|build frontend]] tool which [[Python_Language_Modularization#Build_Backend|backend]] to use for the specific project it is part of.
<code>pyproject.toml</code> tells the [[Python_Language_Modularization#Build_Frontend|build frontend]] tool which [[Python_Language_Modularization#Build_Backend|backend]] to use for the specific project it is part of.


The <code>requires</code> key is a list of packages that are needed to build the package. The frontend should install them automatically when building the package. <font color=darkkhaki>What about the dependencies specified in <code>[[requirements.txt|requirements.txt]]</code>?</font>
The <code>requires</code> key is a list of packages that are needed to build the package. The frontend should install them automatically when building the package. <font color=darkkhaki>What about the dependencies specified in <code>[[requirements.txt|requirements.txt]]</code>?</font> The <code>build-backend</code> 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 <code>tool</code> section of the <code>pyproject.toml</code>, or in a special file defined by the build tool. For example, when using <code>setuptools</code> as build backend, additional configuration may be added to a <code>setup.py</code> or <code>setup.cfg</code> file.


<syntaxhighlight lang='toml'>
<syntaxhighlight lang='toml'>

Revision as of 02:17, 6 April 2024

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