Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db2a96f

Browse files
befelemehroncok
andauthored
PEP 639: Incorporate the latest discussion feedback (#3866)
* Remove the requirement of license-files defaults * Cover all rejected subkeysideas in one paragraph * Change the deprecation policy around classifiers * Flatten the value of the license-files key, only globs are specified * Update the Rejected ideas to match the current license-files proposal --------- Co-authored-by: Miro Hrončok <[email protected]>
1 parent 3dc383a commit db2a96f

File tree

3 files changed

+94
-317
lines changed

3 files changed

+94
-317
lines changed

peps/pep-0639.rst

Lines changed: 29 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -451,22 +451,18 @@ in the ``Classifier`` :term:`Core Metadata field`
451451
(`described in the Core Metadata specification <coremetadataclassifiers_>`__)
452452
is deprecated and replaced by the more precise ``License-Expression`` field.
453453

454-
If the ``License-Expression`` field is present, build tools SHOULD and
455-
publishing tools MUST raise an error if one or more license classifiers
454+
If the ``License-Expression`` field is present, build tools MAY raise an error
455+
if one or more license classifiers
456456
is included in a ``Classifier`` field, and MUST NOT add
457457
such classifiers themselves.
458458

459-
Otherwise, if this field contains a license classifier, build tools MAY
460-
and publishing tools SHOULD issue a warning informing users such classifiers
459+
Otherwise, if this field contains a license classifier,
460+
tools MAY issue a warning informing users such classifiers
461461
are deprecated, and recommending ``License-Expression`` instead.
462462
For compatibility with existing publishing and installation processes,
463463
the presence of license classifiers SHOULD NOT raise an error unless
464464
``License-Expression`` is also provided.
465465

466-
For all newly-uploaded distributions that include a
467-
``License-Expression`` field, the `Python Package Index (PyPI) <pypi_>`__ MUST
468-
reject any that also specify any license classifiers.
469-
470466
New license classifiers MUST NOT be `added to PyPI <classifiersrepo_>`__;
471467
users needing them SHOULD use the ``License-Expression`` field instead.
472468
License classifiers may be removed from a new version of the specification
@@ -524,104 +520,62 @@ paths in the project source tree relative to ``pyproject.toml`` to file(s)
524520
containing licenses and other legal notices to be distributed with the package.
525521
It corresponds to the ``License-File`` fields in the Core Metadata.
526522

527-
Its value is a table, which if present MUST contain one of two optional,
528-
mutually exclusive subkeys, ``paths`` and ``globs``; if both are specified,
529-
tools MUST raise an error. Both are arrays of strings; the ``paths`` subkey
530-
contains verbatim file paths, and the ``globs`` subkey valid glob patterns,
531-
which MUST be parsable by the ``glob`` `module <globmodule_>`__ in the
532-
Python standard library.
533-
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.
534527
Path delimiters MUST be the forward slash character (``/``),
535528
and parent directory indicators (``..``) MUST NOT be used.
536529
Tools MUST assume that license file content is valid UTF-8 encoded text,
537530
and SHOULD validate this and raise an error if it is not.
538531

539-
If the ``paths`` subkey is a non-empty array, build tools:
540-
541-
- MUST treat each value as a verbatim, literal file path, and
542-
MUST NOT treat them as glob patterns.
543-
544-
- MUST include each listed file in all distribution archives.
545-
546-
- MUST NOT match any additional license files beyond those explicitly
547-
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.
548534

549-
- 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, underscores (``_``), hyphens (``-``)
537+
and dots (``.``).
550538

551-
- MUST raise an error if one or more paths do not correspond to a valid file
552-
in the project source that can be copied into the distribution archive.
553-
554-
If the ``globs`` subkey is a non-empty array, build tools:
539+
Build tools:
555540

556541
- MUST treat each value as a glob pattern, and MUST raise an error if the
557542
pattern contains invalid glob syntax.
558543

559-
- MUST include all files matched by at least one listed pattern in all
544+
- MUST include all files matched by a listed pattern in all
560545
distribution archives.
561546

562-
- MAY exclude files matched by glob patterns that can be unambiguously
563-
determined to be backup, temporary, hidden, OS-generated or VCS-ignored.
564-
565547
- MUST list each matched file path under a ``License-File`` field in the
566548
Core Metadata.
567549

568-
- SHOULD issue a warning and MAY raise an error if no files are matched.
569-
570-
- MAY issue a warning if any individual user-specified pattern
550+
- MUST raise an error if any individual user-specified pattern
571551
does not match at least one file.
572552

573-
If the ``license-files`` key is present, and the ``paths`` or ``globs`` subkey
553+
If the ``license-files`` key is present and
574554
is set to a value of an empty array, then tools MUST NOT include any
575555
license files and MUST NOT raise an error.
576556

577-
.. _639-default-patterns:
578-
579-
If the ``license-files`` key is not present and not explicitly marked as
580-
``dynamic``, tools MUST assume a default value of the following:
581-
582-
.. code-block:: toml
583-
584-
license-files.globs = ["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"]
585-
586-
In this case, tools MAY issue a warning if no license files are matched,
587-
but MUST NOT raise an error.
588-
589-
If the ``license-files`` key is marked as ``dynamic`` (and not present),
590-
to preserve consistent behavior with current tools and help ensure the packages
591-
they create are legally distributable, build tools SHOULD default to
592-
including at least the license files matching the above patterns, unless the
593-
user has explicitly specified their own.
594-
595557
Examples of valid license files declaration:
596558

597559
.. code-block:: toml
598560
599561
[project]
600-
license-files = { globs = ["LICEN[CS]E*", "AUTHORS*"] }
562+
license-files = ["LICEN[CS]E*", "AUTHORS*"]
601563
602564
[project]
603-
license-files.paths = ["licenses/LICENSE.MIT", "licenses/LICENSE.CC0"]
565+
license-files = ["licenses/LICENSE.MIT", "licenses/LICENSE.CC0"]
604566
605567
[project]
606-
license-files = { paths = [] }
568+
license-files = ["LICENSE.txt", "licenses/*"]
607569
608570
[project]
609-
license-files.globs = []
571+
license-files = []
610572
611573
Examples of invalid license files declaration:
612574

613575
.. code-block:: toml
614576
615577
[project]
616-
license-files.globs = ["LICEN[CS]E*", "AUTHORS*"]
617-
license-files.paths = ["LICENSE.MIT"]
618-
619-
Reason: license-files.paths and license-files.globs are mutually exclusive.
620-
621-
.. code-block:: toml
622-
623-
[project]
624-
license-files = { paths = ["..\LICENSE.MIT"] }
578+
license-files = ["..\LICENSE.MIT"]
625579
626580
Reason: ``..`` must not be used.
627581
``\`` is an invalid path delimiter, ``/`` must be used.
@@ -630,7 +584,7 @@ Reason: ``..`` must not be used.
630584
.. code-block:: toml
631585
632586
[project]
633-
license-files = { globs = ["LICEN{CSE*"] }
587+
license-files = ["LICEN{CSE*"]
634588
635589
Reason: "LICEN{CSE*" is not a valid glob.
636590

@@ -659,14 +613,9 @@ the ``license-files`` key instead.
659613
If the specified license ``file`` is present in the source tree,
660614
build tools SHOULD use it to fill the ``License-File`` field
661615
in the core metadata, and MUST include the specified file
662-
as if it were specified in a ``license-file.paths`` field.
616+
as if it were specified in a ``license-file`` field.
663617
If the file does not exist at the specified path,
664618
tools MUST raise an informative error as previously specified.
665-
However, tools MUST also still assume the
666-
:ref:`specified default value <639-default-patterns>`
667-
for the ``license-files`` key and also include,
668-
in addition to a license file specified under the ``license.file`` subkey,
669-
any license files that match the specified list of patterns.
670619

671620
Table values for the ``license`` key MAY be removed
672621
from a new version of the specification in a future PEP.
@@ -751,9 +700,9 @@ and license classifiers retain backwards compatibility. A removal is
751700
left to a future PEP and a new version of the Core Metadata specification.
752701

753702
Specification of the new ``License-File`` Core Metadata field and adding the
754-
files in the distribution codifies the existing practices of many packaging
755-
tools. It is designed to be largely backwards-compatible with their existing
756-
use of that field. The new ``license-files`` key in the ``[project]`` table of
703+
files in the distribution is designed to be largely backwards-compatible with
704+
the existing use of that field in many packaging tools.
705+
The new ``license-files`` key in the ``[project]`` table of
757706
``pyproject.toml`` will only have an effect once users and tools adopt it.
758707

759708
This PEP specifies that license files should be placed in a dedicated
@@ -807,7 +756,8 @@ If an invalid ``License-Expression`` is used, the users will not be able
807756
to publish their package to PyPI and an error message will help them
808757
understand they need to use SPDX identifiers.
809758
It will be possible to generate a distribution with incorrect license metadata,
810-
but not to publish one on PyPI or any other index server that enforces ``License-Expression`` validity.
759+
but not to publish one on PyPI or any other index server that enforces
760+
``License-Expression`` validity.
811761
For authors using the now-deprecated ``License`` field or license classifiers,
812762
packaging tools may warn them and inform them of the replacement,
813763
``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)