@@ -146,11 +146,11 @@ used to download the given distribution package, such as
146
146
compliant with :pep: `503 `.
147
147
148
148
The value of ``archive_info `` MUST be a dictionary with a single key
149
- ``hashes ``. The value of ``hashes `` is a dictionary mapping hash function names to a
150
- hex-encoded digest of the file referenced by the ``url `` value. Multiple hashes
151
- can be included, and it is up to the consumer to decide what to do with
152
- multiple hashes (it may validate all of them or a subset of them, or nothing at
153
- all).
149
+ ``hashes ``. The value of ``hashes `` is a dictionary mapping hash function
150
+ names to a hex-encoded digest of the file referenced by the ``url `` value. At
151
+ least one hash MUST be recorded. Multiple hashes MAY be included, and it is up
152
+ to the consumer to decide what to do with multiple hashes (it may validate all
153
+ of them or a subset of them, or nothing at all).
154
154
155
155
Each hash MUST be one of the single argument hashes provided by
156
156
:data: `py3.11:hashlib.algorithms_guaranteed `, excluding ``sha1 `` and ``md5 `` which MUST NOT be used.
@@ -341,6 +341,17 @@ in the Python docs under :attr:`py3.11:hashlib.hash.name`.
341
341
"url" : " https://files.pythonhosted.org/packages/07/51/2c0959c5adf988c44d9e1e0d940f5b074516ecc87e96b1af25f59de9ba38/pip-23.0.1-py3-none-any.whl"
342
342
}
343
343
344
+ The last example demonstrates a ``provenance_url.json `` file with no hashes
345
+ available for the downloaded artifact:
346
+
347
+ .. code-block :: json
348
+
349
+ {
350
+ "archive_info" : {
351
+ "hashes" : {}
352
+ }
353
+ "url" : " https://files.pythonhosted.org/packages/07/51/2c0959c5adf988c44d9e1e0d940f5b074516ecc87e96b1af25f59de9ba38/pip-23.0.1-py3-none-any.whl"
354
+ }
344
355
345
356
Example pip commands and their effect on provenance_url.json and direct_url.json
346
357
--------------------------------------------------------------------------------
@@ -424,6 +435,18 @@ By doing so we eliminate possible redundancy in the file, possible confusion,
424
435
and any additional checks that would need to be done to make sure the hashes are in
425
436
sync.
426
437
438
+ Allowing no hashes stated
439
+ -------------------------
440
+
441
+ For cases when a wheel file is installed from pip's cache and built using an
442
+ older version of pip, pip does not record hashes of the downloaded source
443
+ distributions. As we do not have hashes of these downloaded source
444
+ distributions, the ``hashes `` key in the ``provenance_url.json `` file would not
445
+ contain any entries. In such cases, pip does not create any
446
+ ``provenance_url.json `` file as the provenance information is not complete. It
447
+ is encouraged for consumers to rebuild wheels with a newer version of pip in
448
+ these cases.
449
+
427
450
Making the hashes key optional
428
451
------------------------------
429
452
0 commit comments