Skip to content

Commit 06e98bc

Browse files
committed
Flatten the value of the license-files key, only globs are specified
1 parent 42a1039 commit 06e98bc

File tree

2 files changed

+33
-59
lines changed

2 files changed

+33
-59
lines changed

peps/pep-0639.rst

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -520,87 +520,58 @@ paths in the project source tree relative to ``pyproject.toml`` to file(s)
520520
containing licenses and other legal notices to be distributed with the package.
521521
It corresponds to the ``License-File`` fields in the Core Metadata.
522522

523-
Its value is a table, which if present MUST contain one of two optional,
524-
mutually exclusive subkeys, ``paths`` and ``globs``; if both are specified,
525-
tools MUST raise an error. Both are arrays of strings; the ``paths`` subkey
526-
contains verbatim file paths, and the ``globs`` subkey valid glob patterns,
527-
which MUST be parsable by the ``glob`` `module <globmodule_>`__ in the
528-
Python standard library.
529-
523+
Its value is an array of strings which MUST contain valid glob patterns,
524+
as specified below.
525+
The glob patterns MAY contain special glob characters: ``*``, ``?``, ``**``
526+
and character ranges: ``[]``, and tools MUST support them.
530527
Path delimiters MUST be the forward slash character (``/``),
531528
and parent directory indicators (``..``) MUST NOT be used.
532529
Tools MUST assume that license file content is valid UTF-8 encoded text,
533530
and SHOULD validate this and raise an error if it is not.
534531

535-
If the ``paths`` subkey is a non-empty array, build tools:
536-
537-
- MUST treat each value as a verbatim, literal file path, and
538-
MUST NOT treat them as glob patterns.
539-
540-
- MUST include each listed file in all distribution archives.
541-
542-
- MUST NOT match any additional license files beyond those explicitly
543-
statically specified by the user under the ``paths`` subkey.
532+
Literal paths (e.g. ``LICENSE``) are treated as valid globs which means they
533+
can also be defined.
544534

545-
- MUST list each file path under a ``License-File`` field in the Core Metadata.
535+
To achieve better portability, the filenames to match should only contain
536+
the alphanumeric characters and dot (``.``).
546537

547-
- MUST raise an error if one or more paths do not correspond to a valid file
548-
in the project source that can be copied into the distribution archive.
549-
550-
If the ``globs`` subkey is a non-empty array, build tools:
538+
Build tools:
551539

552540
- MUST treat each value as a glob pattern, and MUST raise an error if the
553541
pattern contains invalid glob syntax.
554542

555-
- MUST include all files matched by at least one listed pattern in all
543+
- MUST include all files matched by a listed pattern in all
556544
distribution archives.
557545

558-
- MAY exclude files matched by glob patterns that can be unambiguously
559-
determined to be backup, temporary, hidden, OS-generated or VCS-ignored.
560-
561546
- MUST list each matched file path under a ``License-File`` field in the
562547
Core Metadata.
563548

564-
- SHOULD issue a warning and MAY raise an error if no files are matched.
565-
566-
- MAY issue a warning if any individual user-specified pattern
549+
- MUST raise an error if any individual user-specified pattern
567550
does not match at least one file.
568551

569-
If the ``license-files`` key is present, and the ``paths`` or ``globs`` subkey
552+
If the ``license-files`` key is present and
570553
is set to a value of an empty array, then tools MUST NOT include any
571554
license files and MUST NOT raise an error.
572555

573-
574556
Examples of valid license files declaration:
575557

576558
.. code-block:: toml
577559
578560
[project]
579-
license-files = { globs = ["LICEN[CS]E*", "AUTHORS*"] }
561+
license-files = ["LICEN[CS]E*", "AUTHORS*"]
580562
581563
[project]
582-
license-files.paths = ["licenses/LICENSE.MIT", "licenses/LICENSE.CC0"]
564+
license-files = ["licenses/LICENSE.MIT", "licenses/LICENSE.CC0"]
583565
584566
[project]
585-
license-files = { paths = [] }
586-
587-
[project]
588-
license-files.globs = []
567+
license-files = []
589568
590569
Examples of invalid license files declaration:
591570

592571
.. code-block:: toml
593572
594573
[project]
595-
license-files.globs = ["LICEN[CS]E*", "AUTHORS*"]
596-
license-files.paths = ["LICENSE.MIT"]
597-
598-
Reason: license-files.paths and license-files.globs are mutually exclusive.
599-
600-
.. code-block:: toml
601-
602-
[project]
603-
license-files = { paths = ["..\LICENSE.MIT"] }
574+
license-files = ["..\LICENSE.MIT"]
604575
605576
Reason: ``..`` must not be used.
606577
``\`` is an invalid path delimiter, ``/`` must be used.
@@ -609,7 +580,7 @@ Reason: ``..`` must not be used.
609580
.. code-block:: toml
610581
611582
[project]
612-
license-files = { globs = ["LICEN{CSE*"] }
583+
license-files = ["LICEN{CSE*"]
613584
614585
Reason: "LICEN{CSE*" is not a valid glob.
615586

@@ -638,7 +609,7 @@ the ``license-files`` key instead.
638609
If the specified license ``file`` is present in the source tree,
639610
build tools SHOULD use it to fill the ``License-File`` field
640611
in the core metadata, and MUST include the specified file
641-
as if it were specified in a ``license-file.paths`` field.
612+
as if it were specified in a ``license-file`` field.
642613
If the file does not exist at the specified path,
643614
tools MUST raise an informative error as previously specified.
644615

@@ -781,7 +752,8 @@ If an invalid ``License-Expression`` is used, the users will not be able
781752
to publish their package to PyPI and an error message will help them
782753
understand they need to use SPDX identifiers.
783754
It will be possible to generate a distribution with incorrect license metadata,
784-
but not to publish one on PyPI or any other index server that enforces ``License-Expression`` validity.
755+
but not to publish one on PyPI or any other index server that enforces
756+
``License-Expression`` validity.
785757
For authors using the now-deprecated ``License`` field or license classifiers,
786758
packaging tools may warn them and inform them of the replacement,
787759
``License-Expression``.

peps/pep-0639/appendix-examples.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,29 +127,30 @@ Putting it all together, our ``setup.cfg`` would be:
127127
setuptools/_vendor/packaging/LICENSE.APACHE
128128
setuptools/_vendor/packaging/LICENSE.BSD
129129
130-
In the ``[project]`` table of ``pyproject.toml``, with license files
131-
specified explicitly via the ``paths`` subkey, this would look like:
130+
In the ``[project]`` table of ``pyproject.toml``, license files
131+
can be specified via glob patterns:
132132

133133
.. code-block:: toml
134134
135135
[project]
136136
license = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
137-
license-files.paths = [
138-
"LICENSE",
139-
"setuptools/_vendor/LICENSE",
140-
"setuptools/_vendor/LICENSE.APACHE",
141-
"setuptools/_vendor/LICENSE.BSD",
137+
license-files = [
138+
"LICENSE*",
139+
"setuptools/_vendor/LICENSE*",
142140
]
143141
144-
Or alternatively, matched via glob patterns, this could be:
142+
Or alternatively, they can be specified explicitly (paths will be interpreted
143+
as glob patterns):
145144

146145
.. code-block:: toml
147146
148147
[project]
149148
license = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
150-
license-files.globs = [
151-
"LICENSE*",
152-
"setuptools/_vendor/LICENSE*",
149+
license-files = [
150+
"LICENSE",
151+
"setuptools/_vendor/LICENSE",
152+
"setuptools/_vendor/LICENSE.APACHE",
153+
"setuptools/_vendor/LICENSE.BSD",
153154
]
154155
155156
With either approach, the output Core Metadata in the distribution
@@ -211,6 +212,7 @@ Some additional examples of valid ``License-Expression`` values:
211212
License-Expression: GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
212213
License-Expression: LicenseRef-Public-Domain OR CC0-1.0 OR Unlicense
213214
License-Expression: LicenseRef-Proprietary
215+
License-Expression: LicenseRef-Custom-License
214216
215217
216218
.. _packaginglicense: https://github.com/pypa/packaging/blob/21.2/LICENSE

0 commit comments

Comments
 (0)