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

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 10 Nov 2019 21:51:02 +0000

Your bug report

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

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
38128: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=38128
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: [bug#38128] [PATCH] gnu: Add boost-with-python3
From: Marius Bakke <[email-masked]>
To: [email-masked], [email-masked]
Date: Sun, 10 Nov 2019 22:50:18 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Giacomo,

[email-masked] writes:

> Hello Guixers!
>
> Given the recent discussion about dropping python 2 completely I thought 
> it's time to build our libboost against python 3. I didn't have the time 
> to check if every boost dependency (there are a lot ;) ) supported 
> python 3, so I added a new variable "boost-with-python3". I'm not sure 
> if I should have made it hidden or if I should have update directly 
> boost definition so any feedback is welcome.

Thank you for this patch!  Have you tried building anything with this
new Boost yet?

Boost has 4623 dependent packages according to 'guix refresh -l boost',
so we can not change the package definition on the master branch.  Such
changes has to go through the 'core-updates' branch.  Adding a separate
variable was the right choice.

It would be great if you could work on a follow-up patch for
'core-updates' that merges this variant with the regular 'Boost'.  I
left that as a TODO comment.  :-)

> From 6eef72ea2bc904ff1371fbbe1211a3890625d99c Mon Sep 17 00:00:00 2001
> From: Giacomo Leidi <[email-masked]>
> Date: Fri, 8 Nov 2019 11:52:42 +0100
> Subject: [PATCH] gnu: Add boost-with-python3.
>
> * gnu/packages/boost.scm (boost-with-python3): New variable.

[...]
  
> +(define-public boost-with-python3
> +  (package
> +    (inherit boost)
> +    (source (origin
> +              (inherit (package-source boost))))

I removed this part, as the source is already inherited.

I also gave it a different name (boost-python3) to avoid a naming
conflict on the CLI.

[...]

> +                     (replace 'provide-libboost_python
> +                       (lambda* (#:key outputs #:allow-other-keys)
> +                         (let ((out (assoc-ref outputs "out")))
> +                           (with-directory-excursion (string-append out "/lib")
> +                             ;; 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>.

...and dropped this comment, since it is already explained in the
regular Boost package.

Applied, thanks!

Subject: [PATCH] gnu: Add boost-with-python3
From: [email-masked]
To: [email-masked]
Date: Fri, 08 Nov 2019 10:59:26 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello Guixers!

Given the recent discussion about dropping python 2 completely I thought 
it's time to build our libboost against python 3. I didn't have the time 
to check if every boost dependency (there are a lot ;) ) supported 
python 3, so I added a new variable "boost-with-python3". I'm not sure 
if I should have made it hidden or if I should have update directly 
boost definition so any feedback is welcome.

Thanks for your patience reviewing this patch,

Giacomo

From 6eef72ea2bc904ff1371fbbe1211a3890625d99c Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <[email-masked]>
Date: Fri, 8 Nov 2019 11:52:42 +0100
Subject: [PATCH] gnu: Add boost-with-python3.

* gnu/packages/boost.scm (boost-with-python3): New variable.
---
 gnu/packages/boost.scm | 55 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/gnu/packages/boost.scm b/gnu/packages/boost.scm
index a2253a9efc..4007c34993 100644
--- a/gnu/packages/boost.scm
+++ b/gnu/packages/boost.scm
@@ -10,6 +10,7 @@
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2018 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2018 Efraim Flashner <[email-masked]>
+;;; Copyright © 2019 Giacomo Leidi <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -128,6 +129,60 @@ across a broad spectrum of applications.")
     (license (license:x11-style "https://www.boost.org/LICENSE_1_0.txt"
                                 "Some components have other similar licences."))))
 
+(define-public boost-with-python3
+  (package
+    (inherit boost)
+    (source (origin
+              (inherit (package-source boost))))
+    (native-inputs
+     `(("perl" ,perl)
+       ("python" ,python)
+       ("tcsh" ,tcsh)))
+    (arguments (substitute-keyword-arguments (package-arguments boost)
+                 ((#:phases phases)
+                  `(modify-phases ,phases
+                     (replace 'configure
+                       (lambda* (#:key inputs outputs #:allow-other-keys)
+                         (let ((icu (assoc-ref inputs "icu4c"))
+                               (python (assoc-ref inputs "python"))
+                               (out (assoc-ref outputs "out")))
+                           (substitute* '("libs/config/configure"
+                                          "libs/spirit/classic/phoenix/test/runtest.sh"
+                                          "tools/build/src/engine/execunix.c"
+                                          "tools/build/src/engine/Jambase"
+                                          "tools/build/src/engine/jambase.c")
+                             (("/bin/sh") (which "sh")))
+
+                           (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 dependencies only
+                                   ;; in traditional install locations.
+                                   (string-append "--with-icu=" icu)
+                                   (string-append "--with-python=" python "/bin/python3")
+                                   (string-append "--with-python-root=" python)
+                                   "--with-python-version=3.7"
+                                   "--with-toolset=gcc"))))
+                     (replace 'provide-libboost_python
+                       (lambda* (#:key outputs #:allow-other-keys)
+                         (let ((out (assoc-ref outputs "out")))
+                           (with-directory-excursion (string-append out "/lib")
+                             ;; 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>.
+                             (symlink "libboost_python37.so" "libboost_python.so")
+                             ;; Some packages also look for libboost_python3.so
+                             (symlink "libboost_python37.so" "libboost_python3.so"))
+                           #t)))))))))
+
 (define-public boost-for-mysql
   ;; Older version for MySQL 5.7.23.
   (package
-- 
2.24.0