diff mbox series

[bug#36477,02/31] gnu: python: Fix cross compilation.

Message ID 20190708095913.3460-3-m.othacehe@gmail.com
State Accepted
Headers show
Series Fix cross-compilation issues | expand

Commit Message

Mathieu Othacehe July 8, 2019, 9:58 a.m. UTC
* gnu/packages/python.scm (python-2.7)[arguments]: Add a configure flag to
disable a check failing when cross-compiling. This is covered here:
https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html,
[native-inputs]: Add self and which when cross-compiling,
(python-3.7)[arguments]: Refer to native python when cross-compiling.
---
 gnu/packages/python.scm | 34 +++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

Comments

Ludovic Courtès July 15, 2019, 8:20 p.m. UTC | #1
Hello,

Mathieu Othacehe <m.othacehe@gmail.com> skribis:

> * gnu/packages/python.scm (python-2.7)[arguments]: Add a configure flag to
> disable a check failing when cross-compiling. This is covered here:
> https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html,
> [native-inputs]: Add self and which when cross-compiling,
> (python-3.7)[arguments]: Refer to native python when cross-compiling.

LGTM!

If you notice that it doesn’t entail a rebuild of Python 2 or 3, you can
apply it to ‘master’.  Otherwise let’s discuss it (‘core-updates’ is now
frozen.)

Thanks,
Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index aa92e82ac2..1a8cd39de2 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -38,7 +38,7 @@ 
 ;;; Copyright © 2017 Frederick M. Muriithi <fredmanglis@gmail.com>
 ;;; Copyright © 2017, 2018 Adriano Peluso <catonano@gmail.com>
 ;;; Copyright © 2017 Ben Sturmfels <ben@sturm.com.au>
-;;; Copyright © 2017, 2018 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2017, 2018, 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2017 José Miguel Sánchez García <jmi2k@openmailbox.org>
 ;;; Copyright © 2017 Roel Janssen <roel@gnu.org>
 ;;; Copyright © 2017, 2018 Kei Kebreau <kkebreau@posteo.net>
@@ -76,6 +76,7 @@ 
 (define-module (gnu packages python)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages dbm)
@@ -134,6 +135,13 @@ 
              "--with-system-ffi"                  ;build ctypes
              "--with-ensurepip=install"           ;install pip and setuptools
              "--enable-unicode=ucs4"
+             ;; Disable runtime check failing if cross-compiling, see:
+             ;; https://lists.yoctoproject.org/pipermail/poky/2013-June/008997.html
+             ,@(if (%current-target-system)
+                   '("ac_cv_buggy_getaddrinfo=no"
+                     "ac_cv_file__dev_ptmx=no"
+                     "ac_cv_file__dev_ptc=no")
+                   '())
              (string-append "LDFLAGS=-Wl,-rpath="
                             (assoc-ref %outputs "out") "/lib"))
 
@@ -246,7 +254,12 @@ 
        ("tcl" ,tcl)
        ("tk" ,tk)))                               ; for tkinter
     (native-inputs
-     `(("pkg-config" ,pkg-config)))
+     `(("pkg-config" ,pkg-config)
+       ;; When cross-compiling, a native version of Python itself is needed.
+       ,@(if (%current-target-system)
+             `(("self" ,this-package)
+               ("which" ,which))
+             '())))
     (native-search-paths
      (list (search-path-specification
             (variable "PYTHONPATH")
@@ -342,13 +355,16 @@  data types.")
                             (if (null? opt) "none" (car opt)))
                     (for-each (lambda (file)
                                 (apply invoke
-                                       `(,(string-append out "/bin/python3")
-                                         ,@opt
-                                         "-m" "compileall"
-                                         "-f" ; force rebuild
-                                         ;; Don't build lib2to3, because it's Python 2 code.
-                                         "-x" "lib2to3/.*"
-                                         ,file)))
+                                       `(,,(if (%current-target-system)
+                                               "python3"
+                                               '(string-append out
+                                                               "/bin/python3"))
+                                          ,@opt
+                                          "-m" "compileall"
+                                          "-f" ; force rebuild
+                                          ;; Don't build lib2to3, because it's Python 2 code.
+                                          "-x" "lib2to3/.*"
+                                          ,file)))
                               (find-files out "\\.py$")))
                   (list '() '("-O") '("-OO")))
                  #t)))))))