Subject: Re: bug#26136: core-updates: [email-masked] fails due to missing zlib

From: Leo Famulari <[email-masked]>
Date: Sun, 19 Mar 2017 15:19:50 -0400

On Sat, Mar 18, 2017 at 09:19:01PM +0100, Danny Milosavljevic wrote:
> An alternative workaround is to use this instead:
> 
> diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
> index be452f062..04c944d84 100644
> --- a/gnu/packages/python.scm12/bin/shore-updates/guix$ /gnu/store/k7029k5va68lka
> +++ b/gnu/packages/python.scm
> @@ -229,6 +229,8 @@
>             ;; before 1980".  Work around this by setting the file times in the
>             ;; source tree to sometime in early 1980.
>             (lambda _
> +             (setenv "CONFIG_SHELL" (which "bash"))
> +

I think this is the better solution to the libffi / ctypes issue. It
also fixes python-minimal@3 to use the bundled libffi. We added libffi
to python-minimal@3's inputs in
d0b73960db051baa468fc1a0fbab21fa9f89f885 to work around a similar issue.

In Python 3.7, the bundled libffi will be removed, and we will have to
build our minimal Python-3 variant with an external libffi package:

https://bugs.python.org/issue27976

Here's a patch that fixes this problem for python-minimal@2. I don't
want to change python-minimal@3 this late in the core-updates cycle; we
can do it in a python-updates branch after core-updates.
From 9d7eef243fca8e53fb89bb17a999f0678d191caf Mon Sep 17 00:00:00 2001
From: Leo Famulari <[email-masked]>
Date: Sun, 19 Mar 2017 02:43:37 -0400
Subject: [PATCH] gnu: python-minimal@2: Fix build failure due to missing
 libffi.

* gnu/packages/python.scm (python-2)[arguments]: Add 'setenv' phase.
(python2-minimal)[inputs]: Add zlib.

Co-authored-by: Danny Milosavljevic <[email-masked]>
---
 gnu/packages/python.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index be452f062..95bf53c8f 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -17,7 +17,7 @@
 ;;; Copyright © 2015, 2016 Efraim Flashner <[email-masked]>
 ;;; Copyright © 2015 Kyle Meyer <[email-masked]>
 ;;; Copyright © 2015, 2016 Chris Marusich <[email-masked]>
-;;; Copyright © 2016 Danny Milosavljevic <[email-masked]>
+;;; Copyright © 2016, 2017 Danny Milosavljevic <[email-masked]>
 ;;; Copyright © 2016 Lukas Gradl <[email-masked]>
 ;;; Copyright © 2016 Hartmut Goebel <[email-masked]>
 ;;; Copyright © 2016 Daniel Pimentel <[email-masked]>
@@ -223,6 +223,19 @@
              (setenv "HOME" (getcwd))
              #t))
           (add-after
+           'unpack 'setenv
+           (lambda _
+             ;; 'Modules/_ctypes/libffi/configure' contains scripts embedded in
+             ;; HEREDOCs whose shebangs aren't patched by the patch-shebang
+             ;; phase.  Setting this variables works around that shortcoming and
+             ;; allows us to keep using the bundled libffi in python-minimal and
+             ;; python2-minimal.
+             ;; XXX The bundled libffi will be removed in Python 3.7:
+             ;; https://bugs.python.org/issue27976
+             ;; https://github.com/python/cpython/commit/935043d1ac19d07ac48233c6175250e66a7bbebd
+             ;; https://github.com/python/cpython/commit/f40d4ddff3c800b3c956a5e8820aabe3aa87cddd
+             (setenv "CONFIG_SHELL" (which "sh"))))
+          (add-after
            'unpack 'set-source-file-times-to-1980
            ;; XXX One of the tests uses a ZIP library to pack up some of the
            ;; source tree, and fails with "ZIP does not support timestamps
@@ -363,7 +376,7 @@ data types.")
      (substitute-keyword-arguments (package-arguments python-2)
        ((#:configure-flags cf)
         `(append ,cf '("--without-system-ffi")))))
-    (inputs '())))                          ;none of the optional dependencies
+    (inputs `(("zlib" ,zlib)))))
 
 (define-public python-minimal
   (package (inherit python)
-- 
2.12.0