@@ -232,17 +232,30 @@ Alternatives considered for the ``license-files`` key in the
232
232
path/glob type handling.
233
233
234
234
235
- Add a ``type `` subkey to ``license-files ``
236
- ''''''''''''''''''''''''''''''''''''''''''
237
-
238
- Instead of defining mutually exclusive ``paths `` and ``globs `` subkeys
239
- of the ``license-files `` ``[project] `` table key, we could
240
- achieve the same effect with a ``files `` subkey for the list and
241
- a ``type `` subkey for how to interpret it. However, it offers no
242
- real advantage in exchange for requiring more keystrokes,
243
- increased complexity, as well as less flexibility in allowing both,
244
- or another additional subkey in the future, as well as the need to bikeshed
245
- over the subkey name. Therefore, it was rejected.
235
+ Define mutually exclusve ``paths `` and ``globs `` subkeys to ``license-files ``
236
+ '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
237
+
238
+ A previous draft of the PEP specified mutually exclusive ``paths `` and
239
+ ``globs `` subkeys of the ``license-files `` ``[project] `` table key.
240
+ This was proposed to achieve the maximum clarity of the defined values for
241
+ both users and tools.
242
+ Allowing license files to be specified as literal paths would avoid edge cases,
243
+ such as those containing glob characters
244
+ (or those confusingly similar to them, as described in :pep: `672 `).
245
+
246
+ However, this approach introduces an extra level of nesting - in the very same
247
+ way that PEP 639 removes from the ``license `` key. This creates more burden
248
+ on project authors who need to disambiguate and choose one or the other
249
+ approach to specify their license files location. It was pointed out that
250
+ it is easily possible to incorrectly assume that paths also support
251
+ globs.
252
+
253
+ Therfore, it was decided against this approach in favor of a flat array value
254
+ which simplifies the specification and implementation,
255
+ and more closely matches the configuration format of existing tools.
256
+ The PEP recommends not to use other than alphanumerical symbols and dot
257
+ (``. ``) in the filenames to not create confusion
258
+ when interpreting glob patterns.
246
259
247
260
248
261
Only accept verbatim paths
@@ -267,138 +280,10 @@ legal file, creating the package illegal to distribute.
267
280
Tools can still determine the files to be included,
268
281
based only on the glob patterns the user specified and the
269
282
filenames in the package, without installing it, executing its code or even
270
- examining its files. Furthermore, tools are explicitly allowed to warn
271
- if specified glob patterns don't match any files.
283
+ examining its files.
272
284
And, of course, sdists, wheels and others will have the full static list
273
285
of files specified in their distribution metadata.
274
286
275
- Perhaps most importantly, this would also exclude the currently specified
276
- default value widely used by the most popular tools, and thus
277
- be a major break to backward compatibility.
278
- And of course, authors are welcome to specify their license
279
- files explicitly via the ``paths `` table subkey, once they are aware of it and
280
- find it suitable for their project.
281
-
282
-
283
- Only accept glob patterns
284
- '''''''''''''''''''''''''
285
-
286
- Conversely, all ``license-files `` strings could be treated as glob patterns.
287
- This would slightly simplify the spec and implementation, avoid an extra level
288
- of nesting, and more closely match the configuration format of existing tools.
289
-
290
- However, for the cost of a few characters, it ensures users are aware
291
- whether they are entering globs or verbatim paths. Furthermore, allowing
292
- license files to be specified as literal paths avoids edge cases, such as those
293
- containing glob characters (or those confusingly or even maliciously similar
294
- to them, as described in :pep: `672 `).
295
-
296
- Including an explicit ``paths `` value ensures that the resulting
297
- ``License-File `` metadata is correct, complete and purely static in the
298
- strictest sense of the term, with all license paths explicitly specified
299
- in the ``pyproject.toml `` file, guaranteed to be included and with an early
300
- error if any are missing. This is not practical to do, at least without
301
- serious limitations for many workflows, if we must assume the items
302
- are glob patterns rather than literal paths.
303
-
304
- This allows tools to locate them and know the exact values of the
305
- ``License-File `` Core Metadata fields without having to traverse the
306
- source tree of the project and match globs, potentially allowing
307
- more reliable programmatic inspection and processing.
308
-
309
- Therefore, given the relatively small cost and the significant benefits,
310
- this approach was not adopted.
311
-
312
-
313
- Infer whether paths or globs
314
- ''''''''''''''''''''''''''''
315
-
316
- It was considered whether to simply allow specifying an array of strings
317
- directly for the ``license-files `` key, rather than making it a table with
318
- explicit ``paths `` and ``globs ``. This would be simpler and avoid
319
- an extra level of nesting, and more closely match the configuration format
320
- of existing tools. However, it was ultimately rejected in favor of separate,
321
- mutually exclusive ``paths `` and ``globs `` table subkeys.
322
-
323
- In practice, it only saves six extra characters in the ``pyproject.toml ``
324
- (``license-files = [...] `` vs ``license-files.globs = [...] ``), but allows
325
- the user to explicitly declare their intent and serves as an unambiguous
326
- indicator for tools to parse them as globs rather than verbatim paths.
327
-
328
- This, in turn, allows for clearly specified tool
329
- behaviors for each case, many of which would be unreliable or impossible
330
- without it and
331
- behave more intuitively overall. These include, with ``paths ``,
332
- guaranteeing that each specified file is included and immediately
333
- raising an error if one is missing, and with ``globs ``, checking glob syntax,
334
- excluding unwanted backup, temporary, or other such files,
335
- and optionally warning if a glob doesn't match any files.
336
- This also avoids edge cases (e.g. paths that contain glob characters) and
337
- reliance on heuristics to determine interpretation.
338
-
339
-
340
- .. _639-license-files-allow-flat-array :
341
-
342
- Also allow a flat array value
343
- '''''''''''''''''''''''''''''
344
-
345
- Initially, after deciding to define ``license-files `` as a table of ``paths ``
346
- and ``globs ``, thought was given to making a top-level string array under the
347
- ``license-files `` key mean one or the other (probably ``globs ``, to match most
348
- current tools). This is slightly shorter, indicates to
349
- the users which one is a preferred one, and allows a cleaner handling of
350
- the empty case.
351
-
352
- However, this only saves six characters in the best case, and there
353
- isn't an obvious choice.
354
-
355
- Flat may be better than nested, but in the face of ambiguity, users
356
- may not resist the temptation to guess. Requiring users to explicitly specify
357
- one or the other ensures they are aware of how their inputs will be handled,
358
- and is more readable for others. It also makes
359
- the spec and tool implementation slightly more complicated, and it can always
360
- be added in the future, but not removed without breaking backward
361
- compatibility. And finally, for the "preferred" option, it means there is
362
- more than one obvious way to do it.
363
-
364
- Therefore, per :pep: `20 `, the Zen of Python, this approach is rejected.
365
-
366
-
367
- Allow both ``paths `` and ``globs `` subkeys
368
- ''''''''''''''''''''''''''''''''''''''''''
369
-
370
- Allowing both ``paths `` and ``globs `` subkeys to be specified under the
371
- ``license-files `` table was considered, as it could potentially allow
372
- more flexible handling for particularly complex projects.
373
-
374
- However, given the existing proposed approach already matches or exceeds the
375
- capabilities of those offered in tools' config files, there isn't
376
- clear demand for this, and it adds a large
377
- amount of complexity in tool implementations and ``pyproject.toml ``
378
- for relatively minimal gain.
379
-
380
- There would be many more edge cases to deal with, such as how to handle files
381
- matched by both lists, and it conflicts with the current
382
- specification for how tools should behave, such as when
383
- no files match.
384
-
385
- Like the previous, if there is a clear need for it, it can be always allowed
386
- in the future in a backward-compatible manner,
387
- while the same is not true of disallowing it.
388
- Therefore, it was decided to require the two subkeys to be mutually exclusive.
389
-
390
-
391
- Rename ``paths `` subkey to ``files ``
392
- ''''''''''''''''''''''''''''''''''''
393
-
394
- Initially, the name ``files `` was considered instead of the ``paths `` for the
395
- subkey of ``license-files `` table. However, ``paths `` was ultimately
396
- chosen to avoid duplication between
397
- the table name (``license-files ``) and the subkey name (``files ``), i.e.
398
- ``license-files.files = ["LICENSE.txt"] ``. It made it seem like
399
- the preferred subkey when it was not, and didn't describe the format of the
400
- string entry similarly to the existing ``globs ``.
401
-
402
287
403
288
Use a default value for ``license-files `` if not specified
404
289
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
0 commit comments