@@ -9,36 +9,60 @@ Declaring project metadata
9
9
packaging-related tools to consume. It defines the following
10
10
specification as the canonical source for the format used.
11
11
12
+
13
+ Specification
14
+ =============
15
+
12
16
There are two kinds of metadata: *static * and *dynamic *. Static
13
17
metadata is specified in the ``pyproject.toml `` file directly and
14
18
cannot be specified or changed by a tool. Dynamic metadata is listed
15
- via the ``dynamic `` field (defined later in this specification) and
19
+ via the ``dynamic `` key (defined later in this specification) and
16
20
represents metadata that a tool will later provide.
17
21
18
- The fields defined in this specification MUST be in a table named
19
- ``[project] `` in ``pyproject.toml ``. No tools may add fields to this
22
+ The keys defined in this specification MUST be in a table named
23
+ ``[project] `` in ``pyproject.toml ``. No tools may add keys to this
20
24
table which are not defined by this specification. For tools wishing
21
25
to store their own settings in ``pyproject.toml ``, they may use the
22
26
``[tool] `` table as defined in the
23
27
:ref: `build dependency declaration specification <declaring-build-dependencies >`.
24
28
The lack of a ``[project] `` table implicitly means the build back-end
25
- will dynamically provide all fields .
29
+ will dynamically provide all keys .
26
30
27
- The only fields required to be statically defined are:
31
+ The only keys required to be statically defined are:
28
32
29
33
- ``name ``
30
34
31
- The fields which are required but may be specified *either * statically
35
+ The keys which are required but may be specified *either * statically
32
36
or listed as dynamic are:
33
37
34
38
- ``version ``
35
39
36
- All other fields are considered optional and may be specified
40
+ All other keys are considered optional and may be specified
37
41
statically, listed as dynamic, or left unspecified.
38
42
43
+ The complete list of keys allowed in the ``[project] `` table are:
44
+
45
+ - ``authors ``
46
+ - ``classifiers ``
47
+ - ``dependencies ``
48
+ - ``description ``
49
+ - ``dynamic ``
50
+ - ``entry-points ``
51
+ - ``gui-scripts ``
52
+ - ``keywords ``
53
+ - ``license ``
54
+ - ``maintainers ``
55
+ - ``name ``
56
+ - ``optional-dependencies ``
57
+ - ``readme ``
58
+ - ``requires-python ``
59
+ - ``scripts ``
60
+ - ``urls ``
61
+ - ``version ``
62
+
39
63
40
64
``name ``
41
- ========
65
+ --------
42
66
43
67
- TOML _ type: string
44
68
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -51,7 +75,7 @@ as it is read for internal consistency.
51
75
52
76
53
77
``version ``
54
- ===========
78
+ -----------
55
79
56
80
- TOML _ type: string
57
81
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -63,7 +87,7 @@ Users SHOULD prefer to specify already-normalized versions.
63
87
64
88
65
89
``description ``
66
- ===============
90
+ ---------------
67
91
68
92
- TOML _ type: string
69
93
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -73,7 +97,7 @@ The summary description of the project.
73
97
74
98
75
99
``readme ``
76
- ==========
100
+ ----------
77
101
78
102
- TOML _ type: string or table
79
103
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -82,28 +106,28 @@ The summary description of the project.
82
106
83
107
The full description of the project (i.e. the README).
84
108
85
- The field accepts either a string or a table. If it is a string then
109
+ The key accepts either a string or a table. If it is a string then
86
110
it is a path relative to ``pyproject.toml `` to a text file containing
87
111
the full description. Tools MUST assume the file's encoding is UTF-8.
88
112
If the file path ends in a case-insensitive ``.md `` suffix, then tools
89
113
MUST assume the content-type is ``text/markdown ``. If the file path
90
114
ends in a case-insensitive ``.rst ``, then tools MUST assume the
91
115
content-type is ``text/x-rst ``. If a tool recognizes more extensions
92
116
than this PEP, they MAY infer the content-type for the user without
93
- specifying this field as ``dynamic ``. For all unrecognized suffixes
117
+ specifying this key as ``dynamic ``. For all unrecognized suffixes
94
118
when a content-type is not provided, tools MUST raise an error.
95
119
96
- The ``readme `` field may also take a table. The ``file `` key has a
120
+ The ``readme `` key may also take a table. The ``file `` key has a
97
121
string value representing a path relative to ``pyproject.toml `` to a
98
122
file containing the full description. The ``text `` key has a string
99
123
value which is the full description. These keys are
100
124
mutually-exclusive, thus tools MUST raise an error if the metadata
101
125
specifies both keys.
102
126
103
- A table specified in the ``readme `` field also has a ``content-type ``
104
- field which takes a string specifying the content-type of the full
127
+ A table specified in the ``readme `` key also has a ``content-type ``
128
+ key which takes a string specifying the content-type of the full
105
129
description. A tool MUST raise an error if the metadata does not
106
- specify this field in the table. If the metadata does not specify the
130
+ specify this key in the table. If the metadata does not specify the
107
131
``charset `` parameter, then it is assumed to be UTF-8. Tools MAY
108
132
support other encodings if they choose to. Tools MAY support
109
133
alternative content-types which they can transform to a content-type
@@ -112,7 +136,7 @@ tools MUST raise an error for unsupported content-types.
112
136
113
137
114
138
``requires-python ``
115
- ===================
139
+ -------------------
116
140
117
141
- TOML _ type: string
118
142
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -122,7 +146,7 @@ The Python version requirements of the project.
122
146
123
147
124
148
``license ``
125
- ===========
149
+ -----------
126
150
127
151
- TOML _ type: table
128
152
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -137,7 +161,7 @@ tool MUST raise an error if the metadata specifies both keys.
137
161
138
162
139
163
``authors ``/``maintainers ``
140
- ===========================
164
+ ---------------------------
141
165
142
166
- TOML _ type: Array of inline tables with string keys and values
143
167
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -151,10 +175,10 @@ project. The exact meaning is open to interpretation — it may list the
151
175
original or primary authors, current maintainers, or owners of the
152
176
package.
153
177
154
- The "maintainers" field is similar to "authors" in that its exact
178
+ The "maintainers" key is similar to "authors" in that its exact
155
179
meaning is open to interpretation.
156
180
157
- These fields accept an array of tables with 2 keys: ``name `` and
181
+ These keys accept an array of tables with 2 keys: ``name `` and
158
182
``email ``. Both values must be strings. The ``name `` value MUST be a
159
183
valid email name (i.e. whatever can be put as a name, before an email,
160
184
in :rfc: `822 `) and not contain commas. The ``email `` value MUST be a
@@ -179,7 +203,7 @@ follows:
179
203
180
204
181
205
``keywords ``
182
- ============
206
+ ------------
183
207
184
208
- TOML _ type: array of strings
185
209
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -189,7 +213,7 @@ The keywords for the project.
189
213
190
214
191
215
``classifiers ``
192
- ===============
216
+ ---------------
193
217
194
218
- TOML _ type: array of strings
195
219
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -199,7 +223,7 @@ Trove classifiers which apply to the project.
199
223
200
224
201
225
``urls ``
202
- ========
226
+ --------
203
227
204
228
- TOML _ type: table with keys and values of strings
205
229
- Corresponding :ref: `core metadata <core-metadata >` field:
@@ -210,7 +234,7 @@ URL itself.
210
234
211
235
212
236
Entry points
213
- ============
237
+ ------------
214
238
215
239
- TOML _ type: table (``[project.scripts] ``, ``[project.gui-scripts] ``,
216
240
and ``[project.entry-points] ``)
@@ -240,7 +264,7 @@ be ambiguous in the face of ``[project.scripts]`` and
240
264
241
265
242
266
``dependencies ``/``optional-dependencies ``
243
- ==========================================
267
+ ------------------------------------------
244
268
245
269
- TOML _ type: Array of :pep: `508 ` strings (``dependencies ``), and a
246
270
table with values of arrays of :pep: `508 ` strings
@@ -267,41 +291,101 @@ metadata.
267
291
268
292
269
293
``dynamic ``
270
- ===========
294
+ -----------
271
295
272
296
- TOML _ type: array of string
273
- - A corresponding :ref: `core metadata <core-metadata >` field does not
274
- exist
297
+ - Corresponding :ref: `core metadata <core-metadata >` field:
298
+ :ref: ` Dynamic < core-metadata-dynamic >`
275
299
276
- Specifies which fields listed by this PEP were intentionally
300
+ Specifies which keys listed by this PEP were intentionally
277
301
unspecified so another tool can/will provide such metadata
278
302
dynamically. This clearly delineates which metadata is purposefully
279
303
unspecified and expected to stay unspecified compared to being
280
304
provided via tooling later on.
281
305
282
306
- A build back-end MUST honour statically-specified metadata (which
283
- means the metadata did not list the field in ``dynamic ``).
307
+ means the metadata did not list the key in ``dynamic ``).
284
308
- A build back-end MUST raise an error if the metadata specifies
285
309
``name `` in ``dynamic ``.
286
310
- If the :ref: `core metadata <core-metadata >` specification lists a
287
- field as "Required", then the metadata MUST specify the field
311
+ field as "Required", then the metadata MUST specify the key
288
312
statically or list it in ``dynamic `` (build back-ends MUST raise an
289
- error otherwise, i.e. it should not be possible for a required field
313
+ error otherwise, i.e. it should not be possible for a required key
290
314
to not be listed somehow in the ``[project] `` table).
291
315
- If the :ref: `core metadata <core-metadata >` specification lists a
292
316
field as "Optional", the metadata MAY list it in ``dynamic `` if the
293
- expectation is a build back-end will provide the data for the field
317
+ expectation is a build back-end will provide the data for the key
294
318
later.
295
319
- Build back-ends MUST raise an error if the metadata specifies a
296
- field statically as well as being listed in ``dynamic ``.
297
- - If the metadata does not list a field in ``dynamic ``, then a build
320
+ key statically as well as being listed in ``dynamic ``.
321
+ - If the metadata does not list a key in ``dynamic ``, then a build
298
322
back-end CANNOT fill in the requisite metadata on behalf of the user
299
323
(i.e. ``dynamic `` is the only way to allow a tool to fill in
300
324
metadata and the user must opt into the filling in).
301
325
- Build back-ends MUST raise an error if the metadata specifies a
302
- field in ``dynamic `` but the build back-end was unable to determine
326
+ key in ``dynamic `` but the build back-end was unable to determine
303
327
the data for it (omitting the data, if determined to be the accurate
304
328
value, is acceptable).
305
329
306
330
331
+ Example
332
+ =======
333
+
334
+ .. code-block :: toml
335
+
336
+ [project]
337
+ name = "spam"
338
+ version = "2020.0.0"
339
+ description = "Lovely Spam! Wonderful Spam!"
340
+ readme = "README.rst"
341
+ requires-python = ">=3.8"
342
+ license = {file = "LICENSE.txt"}
343
+ keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
344
+ authors = [
345
+
346
+ {name = "Tzu-Ping Chung"}
347
+ ]
348
+ maintainers = [
349
+ {name = "Brett Cannon", email = "[email protected] "}
350
+ ]
351
+ classifiers = [
352
+ "Development Status :: 4 - Beta",
353
+ "Programming Language :: Python"
354
+ ]
355
+
356
+ dependencies = [
357
+ "httpx",
358
+ "gidgethub[httpx]>4.0.0",
359
+ "django>2.1; os_name != 'nt'",
360
+ "django>2.0; os_name == 'nt'"
361
+ ]
362
+
363
+ # dynamic = ["version", "description"]
364
+
365
+ [project.optional-dependencies]
366
+ test = [
367
+ "pytest > 5.0.0",
368
+ "pytest-cov[all]"
369
+ ]
370
+ doc = [
371
+ "sphinx",
372
+ "furo"
373
+ ]
374
+
375
+ [project.urls]
376
+ homepage = "https://example.com"
377
+ documentation = "https://readthedocs.org"
378
+ repository = "https://github.com/me/spam.git"
379
+ changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"
380
+
381
+ [project.scripts]
382
+ spam-cli = "spam:main_cli"
383
+
384
+ [project.gui-scripts]
385
+ spam-gui = "spam:main_gui"
386
+
387
+ [project.entry-points."spam.magical"]
388
+ tomatoes = "spam:main_tomatoes"
389
+
390
+
307
391
.. _TOML : https://toml.io
0 commit comments