Subject: Re: bug#38128: [PATCH] gnu: Add boost-with-python3

From: [email-masked]
Date: Tue, 12 Nov 2019 00:06:37 +0000

On 2019-11-11 09:36, Efraim Flashner wrote:
> I'm going to re-open this one, sorry.
> 
> Can we replace the '--with-python-version=3.7' and 
> 'libboost_python37.so'
> with parameterized python variables so we don't have to bump it when we
> get a new python version?
> 
> Also, I've attached a package that I've never actually built that uses
> boost built with python3 if you want something to test it out with :)

I'm not sure how to send a patch for core-updates, I never did it so I 
attached it here. Please tell me if I should open another patch.

The patch builds boost with python3 and parameterizes the python 
version, as Efraim suggested. I built it successfully on core updates. 
When I tried building Epour on core-updates and saw that Guix was 
starting to build Bash 5.0 I renounced (:D) and I built it on master 
with boost-with-python3 .

Libtorrent-rasterbar seems to build fine on master but some tests fail 
to pass and they all seem to be network related but then again this is 
torrent we are talking about. I didn't investigate further but I attach 
the log.

I also tried boost-with-python3 with Malmo ( 
https://github.com/microsoft/malmo ) and it seemed to compile fine just 
but that package has other problems such as trying to start gradle so I 
nerver managed to actually run it.

Let me know what you think about the patch,

Bye

Giacomo

From 91a25fb143ad0e2e20e8ddadea0c0610849adf92 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Tue, 12 Nov 2019 00:24:49 +0100
Subject: [PATCH] gnu: boost: Build with python3.

* gnu/packages/boost.scm (boost):
[arguments]: Parameterize python version.
[native-inputs]: Use python3.
---
 gnu/packages/boost.scm | 41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/gnu/packages/boost.scm b/gnu/packages/boost.scm
index a2253a9efc..389fd1fdb6 100644
--- a/gnu/packages/boost.scm
+++ b/gnu/packages/boost.scm
@@ -62,10 +62,13 @@
               ("zlib" ,zlib)))
     (native-inputs
      `(("perl" ,perl)
-       ("python" ,python-2)
+       ("python" ,python)
        ("tcsh" ,tcsh)))
     (arguments
-     `(#:tests? #f
+     `(#:modules ((guix build gnu-build-system)
+                  (guix build utils)
+                  (srfi srfi-1))
+       #:tests? #f
        #:make-flags
        (list "threading=multi" "link=shared"
 
@@ -83,6 +86,9 @@
          (replace 'configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (let ((icu (assoc-ref inputs "icu4c"))
+                   (python (assoc-ref inputs "python"))
+                   (python-version
+                    (take (string-split ,(package-version python) #\.) 2))
                    (out (assoc-ref outputs "out")))
                (substitute* '("libs/config/configure"
                               "libs/spirit/classic/phoenix/test/runtest.sh"
@@ -94,11 +100,19 @@
                (setenv "SHELL" (which "sh"))
                (setenv "CONFIG_SHELL" (which "sh"))
 
+               (substitute* "tools/build/src/tools/python.jam"
+                 (("include/python\\$\\(version\\)")
+                  "include/python$(version)m"))
+
                (invoke "./bootstrap.sh"
                        (string-append "--prefix=" out)
-                       ;; Auto-detection looks for ICU only in traditional
-                       ;; install locations.
+                       ;; Auto-detection looks for dependencies only
+                       ;; in traditional install locations.
                        (string-append "--with-icu=" icu)
+                       (string-append "--with-python=" python "/bin/python3")
+                       (string-append "--with-python-root=" python)
+                       (string-append "--with-python-version="
+                                      (string-join python-version "."))
                        "--with-toolset=gcc"))))
          (replace 'build
            (lambda* (#:key make-flags #:allow-other-keys)
@@ -109,15 +123,18 @@
            (lambda* (#:key make-flags #:allow-other-keys)
              (apply invoke "./b2" "install" make-flags)))
          (add-after 'install 'provide-libboost_python
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((out (assoc-ref outputs "out")))
-               ;; Boost can build support for both Python 2 and Python 3 since
-               ;; version 1.67.0, and suffixes each library with the Python
-               ;; version.  Many consumers only check for libboost_python
-               ;; however, so we provide it here as suggested in
-               ;; <https://github.com/boostorg/python/issues/203>.
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (python (assoc-ref inputs "python"))
+                    (python-version
+                     (take (string-split ,(package-version python) #\.) 2))
+                    (libboost.so (string-append "libboost_python"
+                                                (string-join python-version "")
+                                                ".so")))
                (with-directory-excursion (string-append out "/lib")
-                 (symlink "libboost_python27.so" "libboost_python.so"))
+                 (symlink libboost.so "libboost_python.so")
+                 ;; Some packages also look for libboost_python3.so
+                 (symlink libboost.so "libboost_python3.so"))
                #t))))))
 
     (home-page "https://www.boost.org")
-- 
2.24.0