guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/02: gnu: python-2.7: Rebuild bytecode.


From: guix-commits
Subject: 02/02: gnu: python-2.7: Rebuild bytecode.
Date: Fri, 8 Feb 2019 04:43:57 -0500 (EST)

rekado pushed a commit to branch core-updates
in repository guix.

commit d41f63942b5df85223f5fae110253bc30869653b
Author: Ricardo Wurmus <address@hidden>
Date:   Fri Feb 8 10:24:11 2019 +0100

    gnu: python-2.7: Rebuild bytecode.
    
    Fixes <https://bugs.gnu.org/22010>.
    
    * gnu/packages/python.scm (python-2.7)[arguments]: Add phase
    "rebuild-bytecode".
    (python-3.7)[arguments]: Replace "rebuild-bytecode" phase; remove outdated
    comment.
---
 gnu/packages/python.scm | 27 +++++++++++++++++++++++----
 1 file changed, 23 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 5c74e8f..ce2e344 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -215,6 +215,28 @@
                                                               file))))))
                        (call-with-output-file "__init__.py" (const #t))
                        #t)))))))
+          (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"
+                           (if (null? opt) "none" (car opt)))
+                   (for-each (lambda (file)
+                               (apply invoke
+                                      `(,(string-append out "/bin/python")
+                                        ,@opt
+                                        "-m" "compileall"
+                                        "-f" ; force rebuild
+                                        ;; Don't build lib2to3, because it 
contains Python 3 code.
+                                        "-x" "lib2to3/.*"
+                                        ,file)))
+                             (find-files out "\\.py$")))
+                 (list '() '("-O") '("-OO")))
+                #t)))
           (add-after 'install 'move-tk-inter
             (lambda* (#:key outputs #:allow-other-keys)
               ;; When Tkinter support is built move it to a separate output so
@@ -316,10 +338,7 @@ data types.")
             (lambda _ (unsetenv "SOURCE_DATE_EPOCH") #t))
           (add-after 'check 'reset-SOURCE_DATE_EPOCH
             (lambda _ (setenv "SOURCE_DATE_EPOCH" "1") #t))
-           ;; FIXME: Without this phase we have close to 400 files that
-           ;; differ across different builds of this package.  With this phase
-           ;; there are 44 files left that differ.
-           (add-after 'remove-tests 'rebuild-bytecode
+           (replace 'rebuild-bytecode
              (lambda* (#:key outputs #:allow-other-keys)
                (let ((out (assoc-ref outputs "out")))
                  ;; Disable hash randomization to ensure the generated .pycs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]