unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Brian Cully via Guix-patches via <guix-patches@gnu.org>
To: 63044@debbugs.gnu.org
Cc: Brian Cully <bjc@spork.org>
Subject: [bug#63044] [PATCH v2] gnu: python: Disable date checking in bdist_egg.py
Date: Tue, 25 Apr 2023 10:35:31 -0400	[thread overview]
Message-ID: <4c971471e09fa2a57ac26b701f8b8e224899b86e.1682433331.git.bjc@spork.org> (raw)
In-Reply-To: <87ildm3zf6.fsf@psyduck.jhoto.kublai.com>

This fixes errors when packing Python eggs, where ZipFile fails due to Guix
setting file timestamps to 0 epoch seconds, where ZipFile wants all files to
date from at least 1980.

* gnu/packages/python-build.scm (python-setuptools)
[disable-zipfile-date-check]:  new phase
* gnu/packages/python.scm (python-3.10) [disable-zipfile-date-check]: new
phase
---
 gnu/packages/python-build.scm | 16 +++++++++++++++-
 gnu/packages/python.scm       | 25 +++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm
index 70719c44d4..d9f6f5beff 100644
--- a/gnu/packages/python-build.scm
+++ b/gnu/packages/python-build.scm
@@ -299,7 +299,21 @@ (define-public python-setuptools
     (build-system python-build-system)
     ;; FIXME: Tests require pytest, which itself relies on setuptools.
     ;; One could bootstrap with an internal untested setuptools.
-    (arguments (list #:tests? #f))
+    (arguments
+     (list
+      #:tests? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          ;; Disable the check which requires files to be dated from at least
+          ;; 1980.
+          ;;
+          ;; This phase is also in the base python package, as it includes its
+          ;; own setuptools.
+          (add-after 'unpack 'disable-zipfile-date-check
+            (lambda _
+              (substitute* "setuptools/command/bdist_egg.py"
+                (("zipfile.ZipFile\\(zip_filename, mode, compression=compression\\)")
+                 "zipfile.ZipFile(zip_filename, mode, compression=compression, strict_timestamps=False)")))))))
     (home-page "https://pypi.org/project/setuptools/")
     (synopsis "Library designed to facilitate packaging Python projects")
     (description "Setuptools is a fully-featured, stable library designed to
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index bfe8a68352..8e30fc127a 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -518,6 +518,31 @@ (define-public python-3.10
                                (find-files "." #:directories? #t))))
                     (delete-file-recursively dir)))
                 (find-files "Lib/ensurepip" "\\.whl$"))))
+           (add-after 'unpack 'disable-zipfile-date-check
+             (lambda _
+               ;; Disable pre-1980 check in setuptools, because Guix mostly
+               ;; sets timestamps to 0 epoch seconds when building.
+               ;;
+               ;; This phase is also included in the python-setuptools
+               ;; package.
+               (let ((dir "whl-content")
+                     (circa-1980 (* 10 366 24 60 60))
+                     (setuptools-whl "../Lib/ensurepip/_bundled/setuptools-63.2.0-py3-none-any.whl"))
+                 (mkdir-p dir)
+                 (with-directory-excursion dir
+                   (invoke "unzip" setuptools-whl)
+                   (substitute* "setuptools/command/bdist_egg.py"
+                     (("zipfile.ZipFile\\(zip_filename, mode, compression=compression\\)")
+                      "zipfile.ZipFile(zip_filename, mode, compression=compression, strict_timestamps=False)"))
+                   (delete-file setuptools-whl)
+                   ;; Reset timestamps to prevent them from ending
+                   ;; up in the Zip archive.
+                   (ftw "." (lambda (file stat flag)
+                              (utime file circa-1980 circa-1980)
+                              #t))
+                   (apply invoke "zip" "-X" setuptools-whl
+                               (find-files "." #:directories? #t)))
+                 (delete-file-recursively dir))))
            (add-before 'check 'set-TZDIR
              (lambda* (#:key inputs native-inputs #:allow-other-keys)
                ;; test_email requires the Olson time zone database.
-- 
2.39.2





  parent reply	other threads:[~2023-04-25 14:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24  0:14 [bug#63044] [PATCH core-updates] Fix criu and sssd Brian Cully via Guix-patches via
2023-04-24  1:18 ` [bug#63044] [PATCH 1/4] gnu: criu: Use gexps Brian Cully via Guix-patches via
2023-04-24  1:18   ` [bug#63044] [PATCH 2/4] guix: utils: add `change-file-timestamps-recursively' procedure Brian Cully via Guix-patches via
2023-04-24  1:18   ` [bug#63044] [PATCH 3/4] gnu: sssd: Change timestamps to 1-Jan-1980 before compressing Brian Cully via Guix-patches via
2023-04-24  1:18   ` [bug#63044] [PATCH 4/4] gnu: criu: " Brian Cully via Guix-patches via
2023-04-24 15:49 ` [bug#63044] [PATCH core-updates] Fix criu and sssd Brian Cully via Guix-patches via
2023-04-30 20:39   ` [bug#63044] [PATCH] gnu: python-setuptools: Disable date checking in bdist_egg.py Ludovic Courtès
2023-05-01  6:32     ` Lars-Dominik Braun
2023-05-01 17:36       ` Brian Cully via Guix-patches via
2023-05-03 20:05         ` Ludovic Courtès
2023-05-03 22:05           ` Brian Cully via Guix-patches via
2023-05-04  0:37             ` Brian Cully via Guix-patches via
2023-05-10 15:18               ` Ludovic Courtès
2023-05-12 22:37                 ` Brian Cully via Guix-patches via
2023-05-13  7:11               ` Lars-Dominik Braun
2023-05-02  0:32   ` jgart via Guix-patches via
2023-04-25 14:35 ` Brian Cully via Guix-patches via [this message]
2023-04-28 13:59   ` [bug#63044] [PATCH core-updates] Fix criu and sssd Brian Cully via Guix-patches via
2023-04-28 14:01 ` [bug#63044] [PATCH v3] gnu: python-setuptools: Disable date checking in bdist_egg.py Brian Cully via Guix-patches via

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=4c971471e09fa2a57ac26b701f8b8e224899b86e.1682433331.git.bjc@spork.org \
    --to=guix-patches@gnu.org \
    --cc=63044@debbugs.gnu.org \
    --cc=bjc@spork.org \
    /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).