[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: guix: python-build-system: Make bytecode compilation deterministi
From: |
Ricardo Wurmus |
Subject: |
02/02: guix: python-build-system: Make bytecode compilation deterministic. |
Date: |
Thu, 15 Mar 2018 04:26:51 -0400 (EDT) |
rekado pushed a commit to branch core-updates
in repository guix.
commit d57888a819dae65ef923cb5c92eb15375a2f3f9f
Author: Ricardo Wurmus <address@hidden>
Date: Wed Mar 7 10:53:11 2018 +0100
guix: python-build-system: Make bytecode compilation deterministic.
* guix/build/python-build-system.scm (enable-bytecode-determinism): New
procedure.
(%standard-phases): Add "enable-bytecode-determinism" phase.
---
guix/build/python-build-system.scm | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/guix/build/python-build-system.scm
b/guix/build/python-build-system.scm
index 0366571..507cc27 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -4,6 +4,7 @@
;;; Copyright © 2013 Nikita Karetnikov <address@hidden>
;;; Copyright © 2015 Mark H Weaver <address@hidden>
;;; Copyright © 2016 Hartmut Goebel <address@hidden>
+;;; Copyright © 2018 Ricardo Wurmus <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -243,10 +244,20 @@ installed with setuptools."
#t))
#t))
+(define* (enable-bytecode-determinism #:rest _)
+ "Improve determinism of pyc files."
+ ;; Set DETERMINISTIC_BUILD to override the embedded mtime in pyc files.
+ (setenv "DETERMINISTIC_BUILD" "1")
+ ;; Use deterministic hashes for strings, bytes, and datetime objects.
+ (setenv "PYTHONHASHSEED" "0")
+ #t)
+
(define %standard-phases
;; 'configure' phase is not needed.
(modify-phases gnu:%standard-phases
(add-after 'unpack 'ensure-no-mtimes-pre-1980 ensure-no-mtimes-pre-1980)
+ (add-after 'ensure-no-mtimes-pre-1980 'enable-bytecode-determinism
+ enable-bytecode-determinism)
(delete 'bootstrap)
(delete 'configure)
(replace 'install install)