summary refs log tree commit diff
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-07-23 20:53:50 +0200
committerMarius Bakke <mbakke@fastmail.com>2018-07-28 15:52:26 +0200
commita422e2478e695bd1211fda827c767134de39fb2c (patch)
tree436f58356faff7a4680017ebe7ed63e76ebe83f1
parent81d967075ebe0facc4cbaf6718b89405ea9195d8 (diff)
downloadguix-a422e2478e695bd1211fda827c767134de39fb2c.tar.gz
gnu: python: Build reproducibly.
\o/

* gnu/packages/python.scm (python-3.7)[arguments]: Set PYTHONHASHSEED before
rebuilding all bytecode.  Adjust regex so that lib2to3_ex.py gets compiled.
-rw-r--r--gnu/packages/python.scm5
1 files changed, 4 insertions, 1 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 3d924f7476..6cab84715a 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -361,6 +361,9 @@ data types.")
            (add-after 'remove-tests 'rebuild-bytecode
              (lambda* (#:key outputs #:allow-other-keys)
                (let ((out (assoc-ref outputs "out")))
+                 ;; Disable hash randomization to ensure the generated .pycs
+                 ;; are reproducible.
+                 (setenv "PYTHONHASHSEED" "0")
                  (for-each
                   (lambda (opt)
                     (format #t "Compiling with optimization level: ~a\n"
@@ -372,7 +375,7 @@ data types.")
                                          "-m" "compileall"
                                          "-f" ; force rebuild
                                          ;; Don't build lib2to3, because it's Python 2 code.
-                                         "-x" "lib2to3.*"
+                                         "-x" "lib2to3/.*"
                                          ,file)))
                               (find-files out "\\.py$")))
                   (list '() '("-O") '("-OO")))