@@ -153,26 +153,19 @@ can projects begin using the new features. Even with this careful approach it's
153
153
not guaranteed that tools won't break on new metadata versions and fields.
154
154
155
155
To avoid this delay, simplify overall how to include SBOMs, and to give
156
- flexibility to build backends and tools, this PEP proposes a new top-level table
157
- in ``pyproject.toml ``, ``[dist-info.files] ``, to safely add data to a Python
158
- package through a registry of reserved names that
159
- avoids the need for new metadata fields and versions. This mechanism allows
160
- build backends and tools to begin using the features described in this PEP
161
- immediately after acceptance without the head-of-line blocking on other
162
- projects adopting the PEP.
163
-
164
- A new top-level table was chosen over using the ``[project] `` table because,
165
- as described in :pep: `621 `, the ``[project] `` table is used for storing core
166
- metadata and this mechanism doesn't use core metadata.
156
+ flexibility to build backends and tools, this PEP proposes using a subdirectory
157
+ under ``.dist-info `` to safely add data to a Python package while avoiding the
158
+ need for new metadata fields and versions. This mechanism allows build backends
159
+ and tools to begin using the feature described in this PEP immediately after
160
+ acceptance without the head-of-line blocking on other projects adopting the PEP.
167
161
168
162
Storing files in the ``.dist-info `` or ``.data `` directory
169
163
----------------------------------------------------------
170
164
171
165
There are two top-level directories in binary distributions where files beyond
172
166
the software itself can be stored: ``.dist-info `` and ``.data ``.
173
167
This specification chose to use the ``.dist-info `` directory for storing
174
- subdirectories and files from the new ``[dist-info.files] `` top-level table
175
- for two reasons:
168
+ subdirectories and files.
176
169
177
170
Firstly, the ``.data `` directory has no corresponding location in the installed
178
171
package, compared to ``.dist-info `` which does preserve the link between the
@@ -231,37 +224,18 @@ Specification
231
224
232
225
The changes necessary to implement this PEP include:
233
226
234
- * Explicitly reserving all subdirectory names in the ``.dist-info `` directory.
235
- * A new registry of reserved subdirectory names in the ``.dist-info `` directory.
236
- * An optional top-level table, ``[dist-info.files] ``, added to
237
- `project source metadata <770-spec-project-source-metadata _>`_,
238
- * An optional ``sboms `` key in the new ``[dist-info.files] `` table,
227
+ * Explicitly reserving the subdirectory ``.dist-info/sboms ``.
239
228
* `Additions <770-spec-project-formats _>`_ to the built distribution (wheel),
240
229
and installed project specifications
241
230
242
231
In addition to the above, an informational PEP will be created for tools
243
232
consuming included SBOM documents and other Python package metadata to
244
233
generate complete SBOM documents for Python packages.
245
234
246
- .. _770-spec-dist-info-subdirs :
247
-
248
- Reserving all subdirectory names in ``.dist-info ``
249
- --------------------------------------------------
250
-
251
- This PEP explicitly reserves all subdirectory names in the ``.dist-info ``
252
- directory for future usage.
253
-
254
- Build backends MUST NOT create subdirectories in the ``.dist-info `` directory
255
- beyond the names in the `registry <770-spec-dist-info-subdirs-registry >`_
256
- to avoid collisions with future reserved names.
257
-
258
- Build frontends and publishing tools MAY warn users if any ``.dist-info ``
259
- subdirectories aren't in the registry.
260
-
261
235
.. _770-spec-dist-info-subdirs-registry :
262
236
263
- Registry of reserved ``.dist-info `` subdirectory names
264
- ------------------------------------------------------
237
+ Reserving the ``.dist-info/sboms `` directory
238
+ --------------------------------------------
265
239
266
240
This PEP introduces a new registry of reserved subdirectory names allowed in
267
241
the ``.dist-info `` directory for the :term: `distribution archive `
@@ -278,88 +252,7 @@ Subdirectory name PEP / Standard
278
252
================= ==============
279
253
280
254
See :ref: `770-backwards-compat ` for a complete methodology for
281
- creating this initial set of values to avoid backwards incompatibility issues.
282
-
283
- .. _770-spec-project-source-metadata :
284
-
285
- Project source metadata
286
- -----------------------
287
-
288
- This PEP specifies changes to the project's source metadata
289
- in the ``pyproject.toml `` file:
290
-
291
- Add new ``[dist-info.files] `` table
292
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
293
-
294
- A new optional ``[dist-info.files] `` table is added for specifying paths
295
- in the project source tree relative to ``pyproject.toml `` to file(s) which
296
- should be included in the built project to a subdirectory of ``.dist-info ``.
297
-
298
- This new table has only one defined optional key: ``sboms ``. The value of the
299
- ``sboms `` key MUST be an array of valid glob patterns, as specified below:
300
-
301
- * Alphanumeric characters, underscores (``_ ``), hyphens (``- ``) and dots (``. ``)
302
- MUST be matched verbatim.
303
- * Special glob characters: ``* ``, ``? ``, ``** `` and character ranges: ``[] ``
304
- containing only the verbatim matched characters MUST be supported. Within
305
- ``[...] ``, the hyphen indicates a locale-agnostic range (e.g. a-z, order based
306
- on Unicode code points). Hyphens at the start or end are matched literally.
307
- * Path delimiters MUST be the forward slash character (``/ ``). Patterns are
308
- relative to the directory containing ``pyproject.toml ``, therefore the leading
309
- slash character MUST NOT be used.
310
- * Parent directory indicators (``.. ``) MUST NOT be used.
311
-
312
- Any characters or character sequences not covered by this specification are
313
- invalid. Projects MUST NOT use such values. Tools consuming this field SHOULD
314
- reject invalid values with an error.
315
-
316
- Literal paths (e.g. ``bom.cdx.json ``) are treated as valid globs which means
317
- they can also be defined.
318
-
319
- Build tools:
320
-
321
- * MUST treat each value in the array as a glob pattern, and MUST raise an error
322
- if the pattern contains invalid glob syntax.
323
- * MUST include all files matched by a listed pattern in all distribution
324
- archives under the ``.dist-info/sboms `` directory.
325
- * MUST raise an error if any individual user-specified pattern does not match
326
- at least one file.
327
-
328
- If the ``sboms `` key is present and is set to a value of an empty array,
329
- then tools MUST NOT include any SBOM files and MUST NOT raise an error.
330
-
331
- Examples of valid SBOM files declarations:
332
-
333
- .. code-block :: toml
334
-
335
- [dist-info.files]
336
- sboms = ["bom.json"]
337
-
338
- [dist-info.files]
339
- sboms = ["sboms/openssl.cdx.json", "sboms/openssl.spdx.json"]
340
-
341
- [dist-info.files]
342
- sboms = ["sboms/*"]
343
-
344
- [dist-info.files]
345
- sboms = []
346
-
347
- Examples of invalid SBOM files declarations:
348
-
349
- .. code-block :: toml
350
-
351
- [dist-info.files]
352
- sboms = ["..\bom.json"]
353
-
354
- Reason: ``.. `` must not be used. ``\\ `` is an invalid path delimiter, ``/ ``
355
- must be used.
356
-
357
- .. code-block :: toml
358
-
359
- [dist-info.files]
360
- sboms = ["bom{.json*"]
361
-
362
- Reason: ``bom{.json* `` is not a valid glob.
255
+ avoiding backwards incompatibilities with selecting this directory name.
363
256
364
257
.. _770-spec-project-formats :
365
258
@@ -368,12 +261,6 @@ SBOM files in project formats
368
261
369
262
A few additions will be made to the existing specifications.
370
263
371
- :term: `Project source trees <Project source tree> `
372
- Per :ref: `770-spec-project-source-metadata ` section, the
373
- `Declaring Project Metadata specification <pyprojecttoml _>`__
374
- will be updated to add the ``[dist-info.files] `` table
375
- and optional ``sboms `` key.
376
-
377
264
:term: `Built distributions <Built distribution> ` (:term: `wheels <wheel> `)
378
265
The wheel specification will be updated to add the new registry of reserved
379
266
directory names and to reflect that if the ``.dist-info/sboms `` subdirectory
@@ -420,10 +307,10 @@ SBOM standards, versions, or fields.
420
307
Backwards Compatibility
421
308
=======================
422
309
423
- Reserved ``.dist-info `` subdirectories registry
424
- -----------------------------------------------
310
+ Reserved ``.dist-info/sboms `` subdirectory
311
+ ------------------------------------------
425
312
426
- The new registry of reserved ``.dist-info `` subdirectories represents
313
+ The new reserved ``.dist-info/sboms `` subdirectory represents
427
314
a new reservation that wasn't previously documented, thus has the potential to
428
315
break assumptions being made by already existing tools.
429
316
@@ -521,23 +408,6 @@ Typically tools can automatically annotate bundled dependencies when those
521
408
dependencies come from a "packaging ecosystem" (such as PyPI, Linux distros,
522
409
Crates.io, NPM, etc).
523
410
524
- For packages which cannot be automatically annotated and if the package author
525
- wishes to provide an SBOM the approach will be to generate or author SBOM files
526
- and then include those files using ``pyproject.toml ``:
527
-
528
- .. code-block :: toml
529
-
530
- [dist-info.files]
531
- sboms = [
532
- "sboms/bom.cdx.json"
533
- ]
534
-
535
- For projects manually specifying an SBOM document the challenge will be
536
- keeping the document up-to-date. The CPython project has some
537
- `customized tooling <https://github.com/python/cpython/blob/main/Tools/build/generate_sbom.py >`__
538
- for this task, but it can likely be generalized into a tool reusable by other
539
- projects.
540
-
541
411
What do SBOM tool authors need to know?
542
412
---------------------------------------
543
413
@@ -644,11 +514,12 @@ user-involvement or knowledge. Compare this situation to license files which
644
514
are almost always static.
645
515
646
516
The 639-style approach was ultimately dropped in favor of defining SBOMs simply
647
- by their presence in the ``.dist-info/sboms `` directory and using a new table in
648
- ``pyproject.toml `` called ``[dist-info.files] `` to define SBOMs in source
649
- distributions. This approach allows users to specify static SBOM files while
650
- still empowering build backends and tools to add their own SBOM data without the
651
- static/dynamic conflict.
517
+ by their presence in the ``.dist-info/sboms `` directory. This approach allows
518
+ build backends and tools to add their own SBOM data without the static/dynamic
519
+ conflict.
520
+
521
+ A future PEP will define the process for statically defining SBOM files to be
522
+ added to the ``.dist-info/sboms `` directory.
652
523
653
524
Open Issues
654
525
===========
@@ -686,9 +557,8 @@ Acknowledgements
686
557
================
687
558
688
559
Thanks to Karolina Surma for authoring and leading :pep: `639 ` to acceptance.
689
- This PEP's initial design was heavily inspired by :pep: `639 ` and the new
690
- "dist-info.files" mechanism generalizes 639's approach of using a subdirectory
691
- under ``.dist-info ``.
560
+ This PEP's initial design was heavily inspired by :pep: `639 ` and adopts a
561
+ similar approach of using a subdirectory under ``.dist-info `` to store files.
692
562
693
563
Copyright
694
564
=========
0 commit comments