@@ -103,15 +103,18 @@ Creating a test directory
103
103
:file: `tests/ ` is a placeholder for test files. Leave it empty for now.
104
104
105
105
106
- Creating pyproject.toml
107
- -----------------------
106
+ Choosing a build backend
107
+ ------------------------
108
+
109
+ Tools like :ref: `pip ` and :ref: `build ` do not actually convert your sources
110
+ into a :term: `distribution package <Distribution Package> ` (like a wheel);
111
+ that job is performed by a *build backend *. The build backend determines how
112
+ your project will specify its configuration, including metadata (information
113
+ about the project, for example, the name and tags that are displayed on PyPI)
114
+ and input files. Build backends have different levels of functionality, such as
115
+ whether they support building :term: `extension modules <Extension Module> `, and
116
+ you should choose one that suits your needs and preferences.
108
117
109
- .. TODO: Add an intro sentence about pyproject.toml, and a sub-heading for
110
- "Configuring build tools"
111
-
112
- :file: `pyproject.toml ` tells "frontend" build tools like :ref: `pip ` and
113
- :ref: `build ` what "backend" tool to use to create
114
- :term: `distribution packages <Distribution Package> ` for your project.
115
118
You can choose from a number of backends; this tutorial uses :ref: `Hatchling
116
119
<hatch>` by default, but it will work identically with :ref: `setuptools `,
117
120
:ref: `Flit <flit >`, :ref: `PDM <pdm >`, and others that support the ``[project] ``
@@ -124,7 +127,10 @@ table for :ref:`metadata <configuring metadata>`.
124
127
management, as well as building, uploading, and installing packages. This
125
128
tutorial uses single-purpose tools that work independently.
126
129
127
- Open :file: `pyproject.toml ` and enter one of these ``[build-system] `` tables:
130
+ The :file: `pyproject.toml ` tells "front end" build tools like :ref: `pip ` and
131
+ :ref: `build ` which backend to use for your project. Below are some
132
+ examples for common build backends, but check your backend's own documentation
133
+ for more details.
128
134
129
135
.. tab :: Hatchling
130
136
@@ -159,14 +165,26 @@ Open :file:`pyproject.toml` and enter one of these ``[build-system]`` tables:
159
165
build-backend = "pdm.backend"
160
166
161
167
162
- - ``requires `` is a list of packages that are needed to build your package. You
163
- don't need to install them; build frontends like :ref: `pip ` will install them
164
- automatically in a temporary, isolated virtual environment for use during the
165
- build process.
166
- - ``build-backend `` is the name of the Python object that frontends will use to
167
- perform the build.
168
+ The ``requires `` key is a list of packages that are needed to build your package.
169
+ The frontend should install them automatically when building your package.
170
+ Frontends usually run builds in isolated environments, so omitting dependencies
171
+ here may cause build-time errors.
172
+ This should always include your backend's package, and might have other build-time
173
+ dependencies.
174
+
175
+ The ``build-backend `` key is the name of the Python object that frontends will use
176
+ to perform the build.
177
+
178
+ Both of these values will be provided by the documentation for your build
179
+ backend, or generated by its command line interface. There should be no need for
180
+ you to customize these settings.
168
181
169
- .. TODO: Add note to check the tools' documentation for the current snippet?
182
+ Additional configuration of the build tool will either be in a ``tool `` section
183
+ of the ``pyproject.toml ``, or in a special file defined by the build tool. For
184
+ example, when using ``setuptools `` as your build backend, additional configuration
185
+ may be added to a ``setup.py `` or ``setup.cfg `` file, and specifying
186
+ ``setuptools.build_meta `` in your build allows the tools to locate and use these
187
+ automatically.
170
188
171
189
.. _configuring metadata :
172
190
0 commit comments