[PATCH] gnu: Add boost-with-python3

  • Done
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • goodoldpaul
  • Marius Bakke
Owner
unassigned
Submitted by
goodoldpaul
Severity
normal
G
G
goodoldpaul wrote on 8 Nov 2019 11:59
(address . guix-patches@gnu.org)
2894916c81c703293e028556070cd964@autistici.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 <goodoldpaul@autistici.org>
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(+)

Toggle diff (75 lines)
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 <rekado@elephly.net>
;;; Copyright © 2018 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2019 Giacomo Leidi <goodoldpaul@autistici.org>
;;;
;;; 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
M
M
Marius Bakke wrote on 10 Nov 2019 22:50
87d0dzl7tx.fsf@devup.no
Giacomo,

goodoldpaul@autistici.org writes:

Toggle quote (9 lines)
> 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. :-)

Toggle quote (7 lines)
> From 6eef72ea2bc904ff1371fbbe1211a3890625d99c Mon Sep 17 00:00:00 2001
> From: Giacomo Leidi <goodoldpaul@autistici.org>
> 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.

[...]
Toggle quote (6 lines)
> +(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.

[...]

Toggle quote (10 lines)
> + (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!
-----BEGIN PGP SIGNATURE-----

iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAl3IhhoACgkQoqBt8qM6
VPoRdwf/YhNbR0ERUqOqQblIu+XEP4uyi8QaHesJ/miQamF3ME5Lk8SsN8I5IUOh
WneRyKivoyc6NxrqgJx7xFRN2Zd/fi51vDpBlBu7WrDXHXII0pNXaD7hxUU5RBB9
sFkTgei5qX1+PVlUpgXr6AnRH7BWIb0UhMTrvlLOLEZWVPDW9Q7ZSvh6mjYACpv0
6QXGSjQvoVZ4Snb0Tf1oQMCibnpeoUP7zl7wddXHgER6zkugmYOluEvyWf9y5ynK
UeQC3p8U3/Uxg4LOniHr/x3tw9gkTr5bTvq8vCrfPfoDLs9pSVkTeDK8uGobMZEN
Uf7FqNpBexdYoMyYFiG9l5m62leaLA==
=393b
-----END PGP SIGNATURE-----

Closed
E
E
Efraim Flashner wrote on 11 Nov 2019 10:36
Re: bug#38128: [PATCH] gnu: Add boost-with-python3
20191111093637.GH3954@E5400
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 :)


--
Efraim Flashner <efraim@flashner.co.il> ????? ?????
GPG key = A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
;;; Copyright © 2016, 2017, 2018, 2019 Efraim Flashner <efraim@flashner.co.il> ;;; ;;; This file is an addendum to GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (wip epour) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix download) #:use-module (guix git-download) #:use-module (guix packages) #:use-module (guix utils) #:use-module (guix build-system gnu) #:use-module (guix build-system python) #:use-module (gnu packages bittorrent) #:use-module (gnu packages boost) #:use-module (gnu packages enlightenment) #:use-module (gnu packages freedesktop) #:use-module (gnu packages glib) ; intltool #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) #:use-module (gnu packages python-web) #:use-module (gnu packages python-xyz) #:use-module (srfi srfi-1)) (define-public epour (package (name "epour") (version "0.7.0") (source (origin (method url-fetch) (uri (string-append "https://download.enlightenment.org/rel/apps/epour" "/epour-" version ".tar.xz")) (sha256 (base32 "0g9f9p01hsq6dcf4cs1pwq95g6fpkyjgwqlvdjk1km1i5gj5ygqw")))) (build-system python-build-system) (arguments `(#:tests? #f ; no test target #:phases (modify-phases %standard-phases (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (invoke "python" "setup.py" "install" (string-append "--prefix=" out)) #t)))))) (native-inputs `(("intltool" ,intltool))) (propagated-inputs `(("libtorrent-rasterbar-local" ,libtorrent-rasterbar-local) ("python-dbus" ,python-dbus) ("python-distutils-extra" ,python-distutils-extra) ("python-efl" ,python-efl) ;("python-parse" ,python-parse) ("python-pyxdg" ,python-pyxdg) ;("python-urllib3" ,python-urllib3) )) (home-page "https://www.enlightenment.org") (synopsis "EFL Bittorrent client") (description "Epour is a BitTorrent client based on the @dfn{Enlightenment Foundation Libraries} (EFL) and rb-libtorrent.") (license license:gpl3+))) (define libtorrent-rasterbar-local (package (inherit libtorrent-rasterbar) (inputs `(("boost" ,boost-with-python3) ,@(alist-delete "boost" (package-inputs libtorrent-rasterbar)))) (native-inputs `(("python" ,python-3) ,@(alist-delete "python" (package-native-inputs libtorrent-rasterbar)))))) (define boost-local (package (inherit boost) (arguments `(#:imported-modules (,@%gnu-build-system-modules (guix build python-build-system)) ,@(substitute-keyword-arguments (package-arguments boost) ((#:phases phases) `(modify-phases ,phases (replace 'provide-libboost_python (lambda* (#:key outputs inputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (py-version ((@@ (guix build python-build-system) get-python-version) (assoc-ref inputs "python"))) (py-suffix (string-join (string-split py-version #\.) ""))) ;; 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>. (with-directory-excursion (string-append out "/lib") (symlink (string-append "libboost_python" py-suffix ".so") "libboost_python.so")) #t)))))))) (native-inputs `(("python" ,python-wrapper) ,@(alist-delete "python" (package-native-inputs boost))))))
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl3JK6UACgkQQarn3Mo9
g1H47A/8CZIrhtp8x+Aqkc3fBWIVVKGusFNar+hdzIpOais+h1rHTWTxdTh+hDXK
gAbXPv4cWf7sTTQ+loCudpQRcPqGhpLizYe1grA86IMMt1GkaTspq9ZinZLzoGE+
peD4HCSGsmeI3zxVOqFSbXzHrx00ohPNFRpX6ks2VJy3gwM1kGwl/85+aFUFhfh/
zQejED4RQRdMso0Jst9btAYcjkN9O3nJkrxstyCeF7kjuu39o9QPamhMGRM+F69k
cM5fTLHO7dwj4ymp40TMO9vjK/sg78TeVRzUe18S3YfK5wpXJHgrPhW4jNr9CCHp
xm7KjKFDCzN7IrIDacxD4Zik1osa3I+sF9yUTS0dmDvzwEb1tL8yUzQPKuGFf9on
qKwq7DNskJVREpwQLYQsIndPdijqWcU1tSv7+8urJtaATfaDcCEW3/MBzXLmhY8z
wg0IjeK1SUHXX6IPo1m/JIoGmkXtxZZPoZa5MF4aT2r6AgpSu0RtmHYWX+UrWJ20
t78JJYcSfnBUt7k+DzseEVaKJiVBJqKwkHoINlbXxqX3nzYWsZnISS+tkf7A2wiA
UdvzdbkNrJadpDwNoeLKwk+6X5TNxpSaXk8nQ50FSh5I57yxxCpCVjMt1SdphnFO
2P3hVgOSC/ePasJXuxmdgGW0KO5aMMrhre+OBybs5BDa+B6H3vs=
=UjA6
-----END PGP SIGNATURE-----


G
G
goodoldpaul wrote on 12 Nov 2019 01:06
(name . Efraim Flashner)(address . efraim@flashner.co.il)
0755dc96f75da487259457a88d8e23ff@autistici.org
On 2019-11-11 09:36, Efraim Flashner wrote:
Toggle quote (10 lines)
> 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 <goodoldpaul@autistici.org>
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(-)

Toggle diff (81 lines)
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
Attachment: epour.log (.29 MiB)
?