Skip to content

Commit 29e2df4

Browse files
authored
Merge pull request #1838 from befeleme/spdx-def
Specify SPDX license expression
2 parents 99469d7 + 3ccd14f commit 29e2df4

File tree

4 files changed

+76
-4
lines changed

4 files changed

+76
-4
lines changed

source/specifications/core-metadata.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ License-Expression
468468
.. versionadded:: 2.4
469469

470470
Text string that is a valid SPDX
471-
`license expression <https://peps.python.org/pep-0639/#term-license-expression>`__
472-
as `defined in PEP 639 <https://peps.python.org/pep-0639/#spdx>`__.
471+
:term:`license expression <License Expression>`,
472+
as specified in :doc:`/specifications/license-expression`.
473473

474474
Examples::
475475

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
==================
2+
License Expression
3+
==================
4+
5+
:pep:`639` defined a new :ref:`pyproject.toml's license <pyproject-toml-license>`
6+
value and added a corresponding :ref:`core metadata License-Expression field
7+
<core-metadata-license-expression>`.
8+
This specification defines which license expressions are acceptable.
9+
10+
11+
Specification
12+
=============
13+
14+
License can be defined as a text string that is a valid SPDX
15+
:term:`license expression <License Expression>`,
16+
as documented in the `SPDX specification <spdxpression_>`__,
17+
either Version 2.2 or a later compatible version.
18+
19+
A license expression can use the following license identifiers:
20+
21+
- Any SPDX-listed license short-form identifiers that are published in
22+
the `SPDX License List <spdxlist_>`__,
23+
version 3.17 or any later compatible version.
24+
25+
- The custom ``LicenseRef-[idstring]`` string(s), where ``[idstring]`` is
26+
a unique string containing letters, numbers, ``.`` and/or ``-``,
27+
to identify licenses that are not included in the SPDX license list.
28+
The custom identifiers must follow the SPDX specification,
29+
`clause 10.1 <spdxcustom_>`__ of the given specification version.
30+
31+
32+
Examples of valid license expressions:
33+
34+
.. code-block:: yaml
35+
36+
MIT
37+
BSD-3-Clause
38+
MIT AND (Apache-2.0 OR BSD-2-Clause)
39+
MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)
40+
GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
41+
LicenseRef-Special-License OR CC0-1.0 OR Unlicense
42+
LicenseRef-Proprietary
43+
44+
45+
Examples of invalid license expressions:
46+
47+
.. code-block:: yaml
48+
49+
Use-it-after-midnight # No `LicenseRef` prefix
50+
Apache-2.0 OR 2-BSD-Clause # 2-BSD-Clause is not a valid SPDX identifier
51+
LicenseRef-License with spaces # spaces are not allowed
52+
LicenseRef-License_with_underscores # underscore are not allowed
53+
54+
.. _spdxcustom: https://spdx.github.io/spdx-spec/v2.2.2/other-licensing-information-detected/
55+
.. _spdxlist: https://spdx.org/licenses/
56+
.. _spdxpression: https://spdx.github.io/spdx-spec/v2.2.2/SPDX-license-expressions/

source/specifications/pyproject-toml.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,26 @@ The Python version requirements of the project.
254254
- Corresponding :ref:`core metadata <core-metadata>` field:
255255
:ref:`License-Expression <core-metadata-license-expression>`
256256

257-
Text string that is a valid SPDX license expression as defined in :pep:`639`.
257+
Text string that is a valid SPDX
258+
:term:`license expression <License Expression>`,
259+
as specified in :doc:`/specifications/license-expression`.
258260
Tools SHOULD validate and perform case normalization of the expression.
259261

260-
The table subkeys of the ``license`` key are deprecated.
262+
Legacy specification
263+
''''''''''''''''''''
261264

265+
- TOML_ type: table
266+
- Corresponding :ref:`core metadata <core-metadata>` field:
267+
:ref:`License <core-metadata-license>`
268+
269+
The table may have one of two keys. The ``file`` key has a string
270+
value that is a file path relative to :file:`pyproject.toml` to the file
271+
which contains the license for the project. Tools MUST assume the
272+
file's encoding is UTF-8. The ``text`` key has a string value which is
273+
the license of the project. These keys are mutually exclusive, so a
274+
tool MUST raise an error if the metadata specifies both keys.
275+
276+
The table subkeys were deprecated by :pep:`639` in favor of the string value.
262277

263278
.. _pyproject-toml-license-files:
264279

source/specifications/section-distribution-metadata.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Package Distribution Metadata
1515
platform-compatibility-tags
1616
well-known-project-urls
1717
glob-patterns
18+
license-expression

0 commit comments

Comments
 (0)