@@ -291,22 +291,43 @@ You can also specify the format explicitly, like this:
291291 readme = {file = "README.txt", content-type = "text/x-rst"}
292292
293293
294- .. _license :
294+ .. _license-and-license-files :
295295
296- ``license ``
297- -----------
296+ ``license `` and ``license-files ``
297+ ---------------------------------
298+
299+ As per :pep: `639 ` licenses should be declared with two fields:
300+
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.
304+
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
298311
299- :pep: `639 ` (accepted in August 2024) has changed the way the ``license `` field
300- is declared. Make sure your preferred build backend supports :pep: `639 ` before
301- trying to apply the newer guidelines.
302- As of February 2025, :doc: `setuptools <setuptools:userguide/pyproject_config >`
303- and :ref: `flit <flit:pyproject_toml_project >` don't support :pep: `639 ` yet.
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 _>`_
304322
305- :pep: `639 ` license declaration
306- ''''''''''''''''''''''''''''''
307323
308- This is a valid :term: `SPDX license expression <License Expression> ` consisting
309- of one or more :term: `license identifiers <License Identifier> `.
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> `.
310331The full license list is available at the
311332`SPDX license list page <spdxlicenselist _>`_. The supported list version is
3123333.17 or any later compatible one.
@@ -318,6 +339,11 @@ The full license list is available at the
318339 # or
319340 license = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
320341
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+
321347As a general rule, it is a good idea to use a standard, well-known
322348license, both to avoid confusion and because some organizations avoid software
323349whose license is unapproved.
@@ -332,41 +358,11 @@ The custom identifiers must follow the SPDX specification,
332358 [project]
333359 license = "LicenseRef-My-Custom-License"
334360
335- Legacy license declaration
336- ''''''''''''''''''''''''''
337-
338- This can take two forms. You can put your license in a file, typically
339- :file: `LICENSE ` or :file: `LICENSE.txt `, and link that file here:
340-
341- .. code-block :: toml
342-
343- [project]
344- license = {file = "LICENSE"}
345-
346- or you can write the name of the license:
347-
348- .. code-block :: toml
349-
350- [project]
351- license = {text = "MIT License"}
352-
353- If you are using a standard, well-known license, it is not necessary to use this
354- field. Instead, you should use one of the :ref: `classifiers ` starting with ``License
355- :: ``. (As a general rule, it is a good idea to use a standard, well-known
356- license, both to avoid confusion and because some organizations avoid software
357- whose license is unapproved.)
358-
359361
360362 .. _license-files :
361363
362364``license-files ``
363- -----------------
364-
365- :pep: `639 ` (accepted in August 2024) has introduced the ``license-files `` field.
366- Make sure your preferred build backend supports :pep: `639 ` before declaring the
367- field.
368- As of February 2025, :doc: `setuptools <setuptools:userguide/pyproject_config >`
369- and :ref: `flit <flit:pyproject_toml_project >` don't support :pep: `639 ` yet.
365+ '''''''''''''''''
370366
371367This is a list of license files and files containing other legal
372368information you want to distribute with your package.
@@ -541,7 +537,7 @@ A full example
541537 ]
542538 description = "Lovely Spam! Wonderful Spam!"
543539 readme = "README.rst"
544- license = "MIT" # or license = {file = "LICENSE.txt"} for legacy declaration
540+ license = "MIT"
545541 license-files = ["LICEN[CS]E.*"]
546542 keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
547543 classifiers = [
@@ -579,13 +575,17 @@ A full example
579575 like ``requires-python = "<= 3.10" `` here. `This blog post <requires-python-blog-post _>`_
580576 contains some information regarding possible problems.
581577
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
582581.. _gfm : https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax
583582.. _setuptools : https://setuptools.pypa.io
584583.. _poetry : https://python-poetry.org
585584.. _pypi-pip : https://pypi.org/project/pip
586585.. _pypi-search-pip : https://pypi.org/search?q=pip
587586.. _classifier-list : https://pypi.org/classifiers
588587.. _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
589589.. _pytest : https://pytest.org
590590.. _pygments : https://pygments.org
591591.. _rest : https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html
0 commit comments