unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Leo Famulari <leo@famulari.name>
Cc: 22010@debbugs.gnu.org
Subject: bug#22010: bytecode timestamps
Date: Tue, 05 Feb 2019 13:25:54 +0100	[thread overview]
Message-ID: <87sgx2h165.fsf@elephly.net> (raw)
In-Reply-To: <20160207235839.GA4994@jasmine> (Leo Famulari's message of "Sun, 7 Feb 2016 18:58:39 -0500")

Leo Famulari <leo@famulari.name> writes:

> Those differing bytes are the timestamps of the .py sources files that
> correspond to the compiled .pyc / .pyo files. So, the
> python-2.7-source-date-epoch.patch is working for software compiled by
> the patched compiler, but not on python-2.7 itself.
>
> It's related to <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=22533>.

It looks easy to fix this:

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 1c4ea720f..34c01bd50 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -276,6 +276,38 @@ data types.")
                         (search-patches "python2-CVE-2018-14647.patch"
                                         "python2-CVE-2018-1000802.patch")))))))
 
+(define-public python-2-rekado
+  (package
+    (inherit python-2)
+    (name "python2-rekado")
+    (arguments
+     `(#:tests? #f ; XXX
+       ,@(substitute-keyword-arguments (package-arguments python-2)
+           ((#:phases phases)
+            `(modify-phases ,phases
+               (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))))))))))
+
 (define-public python2-called-python
   ;; Both 2.x and 3.x used to be called "python".  In commit
   ;; a7714d42de2c3082f3609d1e63c83d703fb39cf9 (March 2018), we renamed
   the
--8<---------------cut here---------------end--------------->8---

This Python variant builds reproducibly (I disabled the tests for speed
and did this in a separate package to avoid grafting shenanigans and
rebuilds).  The phase is virtually the same as the phase of the same
name in the Python 3 package; only difference is the use of
“/bin/python” instead of “/bin/python3”.

I wonder if we can simplify this with (setenv "PYTHONHASHSEED" "0")
before any pyc files are built, but I expect that to be problematic.

~~ Ricardo

  reply	other threads:[~2019-02-05 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 14:38 bug#22010: Python 2.7.10 not deterministic Ludovic Courtès
2015-12-13 18:17 ` Ludovic Courtès
2016-02-07 23:58 ` bug#22010: bytecode timestamps Leo Famulari
2019-02-05 12:25   ` Ricardo Wurmus [this message]
2019-02-05 20:29     ` Ricardo Wurmus
2019-02-08  9:45       ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sgx2h165.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=22010@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).