[Distutils] add hash algorithm agility to RECORD

Daniel Holth dholth at gmail.com
Thu Sep 6 18:34:54 CEST 2012


Proposed edits to https://bitbucket.org/dholth/python-peps/changeset/9c26fa50

In wheel I use urlsafe_b64encode_nopad() which omits the trailing =
characters, but although very easy to implement isn't included in the
stdlib. In this spec I use the stdlib urlsafe_b64encode().

diff -r 23f9640c2020 -r 9c26fa508424 pep-0376.txt
--- a/pep-0376.txt      Thu Sep 06 12:09:58 2012 -0400
+++ b/pep-0376.txt      Thu Sep 06 12:24:40 2012 -0400
@@ -218,11 +218,16 @@

   - an absolute path, using the local platform separator

-- the **MD5** hash of the file, encoded in hex. Notice that `pyc` and `pyo`
-  generated files don't have any hash because they are automatically produced
-  from `py` files. So checking the hash of the corresponding `py` file is
-  enough to decide if the file and its associated `pyc` or `pyo` files have
-  changed.
+- a hash of the file's contents.
+  Notice that `pyc` and `pyo` generated files don't have any hash because
+  they are automatically produced from `py` files. So checking the hash
+  of the corresponding `py` file is enough to decide if the file and
+  its associated `pyc` or `pyo` files have changed.
+
+  The hash is either the empty string, the **MD5** hash of
+  the file, encoded in hex, or the hash algorithm as named in
+  ``hashlib.algorithms``, followed by the equals character ``=``,
+  followed by the hash digest as encoded with ``urlsafe_b64encode``.

 - the file's size in bytes

@@ -391,9 +396,9 @@

 And following methods:

-- ``get_installed_files(local=False)`` -> iterator of (path, md5, size)
+- ``get_installed_files(local=False)`` -> iterator of (path, hash, size)

-  Iterates over the `RECORD` entries and return a tuple ``(path, md5, size)``
+  Iterates over the `RECORD` entries and return a tuple ``(path, hash, size)``
   for each line. If ``local`` is ``True``, the path is transformed into a
   local absolute path. Otherwise the raw value from `RECORD` is returned.


More information about the Distutils-SIG mailing list