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.
This commit is contained in:
Ricardo Wurmus 2018-03-07 10:53:11 +01:00
parent 9b7e389d41
commit d57888a819
No known key found for this signature in database
GPG Key ID: 197A5888235FACAC
1 changed files with 11 additions and 0 deletions

View File

@ -4,6 +4,7 @@
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -243,10 +244,20 @@ installed with setuptools."
#t)) #t))
#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 (define %standard-phases
;; 'configure' phase is not needed. ;; 'configure' phase is not needed.
(modify-phases gnu:%standard-phases (modify-phases gnu:%standard-phases
(add-after 'unpack 'ensure-no-mtimes-pre-1980 ensure-no-mtimes-pre-1980) (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 'bootstrap)
(delete 'configure) (delete 'configure)
(replace 'install install) (replace 'install install)