@@ -56,38 +56,7 @@ Usually, you'll just copy what your build backend's documentation
56
56
suggests (after :ref: `choosing your build backend <choosing-build-backend >`).
57
57
Here are the values for some common build backends:
58
58
59
- .. tab :: Hatchling
60
-
61
- .. code-block :: toml
62
-
63
- [build-system]
64
- requires = ["hatchling"]
65
- build-backend = "hatchling.build"
66
-
67
- .. tab :: setuptools
68
-
69
- .. code-block :: toml
70
-
71
- [build-system]
72
- requires = ["setuptools >= 61.0"]
73
- build-backend = "setuptools.build_meta"
74
-
75
- .. tab :: Flit
76
-
77
- .. code-block :: toml
78
-
79
- [build-system]
80
- requires = ["flit_core >= 3.4"]
81
- build-backend = "flit_core.buildapi"
82
-
83
- .. tab :: PDM
84
-
85
- .. code-block :: toml
86
-
87
- [build-system]
88
- requires = ["pdm-backend"]
89
- build-backend = "pdm.backend"
90
-
59
+ .. include :: ../shared/build-backend-tabs.rst
91
60
92
61
93
62
Static vs. dynamic metadata
@@ -322,22 +291,43 @@ You can also specify the format explicitly, like this:
322
291
readme = {file = "README.txt", content-type = "text/x-rst"}
323
292
324
293
325
- .. _license :
294
+ .. _license-and-license-files :
326
295
327
- ``license ``
328
- -----------
296
+ ``license `` and `` license-files ``
297
+ ---------------------------------
329
298
330
- :pep: `639 ` (accepted in August 2024) has changed the way the ``license `` field
331
- is declared. Make sure your preferred build backend supports :pep: `639 ` before
332
- trying to apply the newer guidelines.
333
- As of February 2025, :doc: `setuptools <setuptools:userguide/pyproject_config >`
334
- and :ref: `flit <flit:pyproject_toml_project >` don't support :pep: `639 ` yet.
299
+ As per :pep: `639 ` licenses should be declared with two fields:
335
300
336
- :pep: `639 ` license declaration
337
- ''''''''''''''''''''''''''''''
301
+ - ``license `` is an :term: `SPDX license expression <License Expression> ` consisting
302
+ of one or more :term: `license identifiers <License Identifier> `.
303
+ - ``license-files `` is a list of license file glob patterns.
338
304
339
- This is a valid :term: `SPDX license expression <License Expression> ` consisting
340
- of one or more :term: `license identifiers <License Identifier> `.
305
+ A previous PEP had specified ``license `` to be a table with a ``file `` or a
306
+ ``text `` key, this format is now deprecated. Most :term: `build backends<build
307
+ backend> ` now support the new format as shown in the following table.
308
+
309
+ .. list-table :: build backend versions that introduced :pep:`639` support
310
+ :header-rows: 1
311
+
312
+ * - hatchling
313
+ - setuptools
314
+ - flit-core [#flit-core-pep639 ]_
315
+ - pdm-backend
316
+ - poetry-core
317
+ * - 1.27.0
318
+ - 77.0.3
319
+ - 3.12
320
+ - 2.4.0
321
+ - `not yet <poetry-pep639-issue _>`_
322
+
323
+
324
+ .. _license :
325
+
326
+ ``license ``
327
+ '''''''''''
328
+
329
+ The new format for ``license `` is a valid :term: `SPDX license expression <License Expression> `
330
+ consisting of one or more :term: `license identifiers <License Identifier> `.
341
331
The full license list is available at the
342
332
`SPDX license list page <spdxlicenselist _>`_. The supported list version is
343
333
3.17 or any later compatible one.
@@ -349,6 +339,11 @@ The full license list is available at the
349
339
# or
350
340
license = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
351
341
342
+ .. note :: If you get a build error that ``license`` should be a dict/table,
343
+ your build backend doesn't yet support the new format. See the
344
+ `above section <license-and-license-files _>`_ for more context.
345
+ The now deprecated format is `described in PEP 621 <https://peps.python.org/pep-0621/#license >`__.
346
+
352
347
As a general rule, it is a good idea to use a standard, well-known
353
348
license, both to avoid confusion and because some organizations avoid software
354
349
whose license is unapproved.
@@ -363,41 +358,11 @@ The custom identifiers must follow the SPDX specification,
363
358
[project]
364
359
license = "LicenseRef-My-Custom-License"
365
360
366
- Legacy license declaration
367
- ''''''''''''''''''''''''''
368
-
369
- This can take two forms. You can put your license in a file, typically
370
- :file: `LICENSE ` or :file: `LICENSE.txt `, and link that file here:
371
-
372
- .. code-block :: toml
373
-
374
- [project]
375
- license = {file = "LICENSE"}
376
-
377
- or you can write the name of the license:
378
-
379
- .. code-block :: toml
380
-
381
- [project]
382
- license = {text = "MIT License"}
383
-
384
- If you are using a standard, well-known license, it is not necessary to use this
385
- field. Instead, you should use one of the :ref: `classifiers ` starting with ``License
386
- :: ``. (As a general rule, it is a good idea to use a standard, well-known
387
- license, both to avoid confusion and because some organizations avoid software
388
- whose license is unapproved.)
389
-
390
361
391
362
.. _license-files :
392
363
393
364
``license-files ``
394
- -----------------
395
-
396
- :pep: `639 ` (accepted in August 2024) has introduced the ``license-files `` field.
397
- Make sure your preferred build backend supports :pep: `639 ` before declaring the
398
- field.
399
- As of February 2025, :doc: `setuptools <setuptools:userguide/pyproject_config >`
400
- and :ref: `flit <flit:pyproject_toml_project >` don't support :pep: `639 ` yet.
365
+ '''''''''''''''''
401
366
402
367
This is a list of license files and files containing other legal
403
368
information you want to distribute with your package.
@@ -572,7 +537,7 @@ A full example
572
537
]
573
538
description = "Lovely Spam! Wonderful Spam!"
574
539
readme = "README.rst"
575
- license = "MIT" # or license = {file = "LICENSE.txt"} for legacy declaration
540
+ license = "MIT"
576
541
license-files = ["LICEN[CS]E.*"]
577
542
keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
578
543
classifiers = [
@@ -610,13 +575,17 @@ A full example
610
575
like ``requires-python = "<= 3.10" `` here. `This blog post <requires-python-blog-post _>`_
611
576
contains some information regarding possible problems.
612
577
578
+ .. [#flit-core-pep639 ] flit-core `does not yet <flit-issue-735 _>`_ support WITH in SPDX license expressions.
579
+
580
+ .. _flit-issue-735 : https://github.com/pypa/flit/issues/735
613
581
.. _gfm : https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
614
582
.. _setuptools : https://setuptools.pypa.io
615
583
.. _poetry : https://python-poetry.org
616
584
.. _pypi-pip : https://pypi.org/project/pip
617
585
.. _pypi-search-pip : https://pypi.org/search?q=pip
618
586
.. _classifier-list : https://pypi.org/classifiers
619
587
.. _requires-python-blog-post : https://iscinumpy.dev/post/bound-version-constraints/#pinning-the-python-version-is-special
588
+ .. _poetry-pep639-issue : https://github.com/python-poetry/poetry/issues/9670
620
589
.. _pytest : https://pytest.org
621
590
.. _pygments : https://pygments.org
622
591
.. _rest : https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
0 commit comments