unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Jakub Kądziołka" <kuba@kadziolka.net>
To: 40469@debbugs.gnu.org
Subject: [bug#40469] [PATCH core-updates v2 1/2] build-system/python: Install to the python output if present.
Date: Sun, 21 Jun 2020 03:27:48 +0200	[thread overview]
Message-ID: <20200621012749.3742-1-kuba@kadziolka.net> (raw)
In-Reply-To: <20200406144809.30928-1-kuba@kadziolka.net>

* gnu/build/python-build-system.scm (python-output): New procedure.
  (site-packages, install): Use python-output to find the output path.
  (wrap, rename-pth-file): Use site-packages where appropriate.
* doc/guix.texi (Build Systems): Mention the new behavior.
---

Following a discussion on IRC, I am changing the approach a bit. Also,
should this go on core-updates or staging? I'm not sure how to account
for all the dependent packages, but just grepping for
python-build-system puts this in the staging range.

$ rg python-build-system gnu/packages | wc -l
1474

 doc/guix.texi                      |  7 +++++++
 guix/build/python-build-system.scm | 24 +++++++++++-------------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 2268e159a2..7af98d3e00 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -6685,6 +6685,13 @@ By default guix calls @code{setup.py} under control of
 @code{setuptools}, much like @command{pip} does.  Some packages are not
 compatible with setuptools (and pip), thus you can disable this by
 setting the @code{#:use-setuptools?} parameter to @code{#f}.
+
+If a @code{"python"} output is available, the package is installed into it
+instead of the default @code{"out"} output. This is useful for packages that
+include a Python package as only a part of the software, and thus want to
+combine the phases of @code{python-build-system} with another build system.
+Python bindings are a common usecase.
+
 @end defvr
 
 @defvr {Scheme Variable} perl-build-system
diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 09bd8465c8..62e7a7b305 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -6,6 +6,7 @@
 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -154,9 +155,14 @@
          (major+minor (take components 2)))
     (string-join major+minor ".")))
 
+(define (python-output outputs)
+  "Return the path of the python output, if there is one, or fall-back to out."
+  (or (assoc-ref outputs "python")
+      (assoc-ref outputs "out")))
+
 (define (site-packages inputs outputs)
   "Return the path of the current output's Python site-package."
-  (let* ((out (assoc-ref outputs "out"))
+  (let* ((out (python-output outputs))
          (python (assoc-ref inputs "python")))
     (string-append out "/lib/python"
                    (python-version python)
@@ -175,7 +181,7 @@ when running checks after installing the package."
 (define* (install #:key outputs (configure-flags '()) use-setuptools?
                   #:allow-other-keys)
   "Install a given Python package."
-  (let* ((out (assoc-ref outputs "out"))
+  (let* ((out (python-output outputs))
          (params (append (list (string-append "--prefix=" out))
                          (if use-setuptools?
                              ;; distutils does not accept these flags
@@ -199,12 +205,8 @@ when running checks after installing the package."
                         (string-append dir "/sbin"))))
                 outputs))
 
-  (let* ((out  (assoc-ref outputs "out"))
-         (python (assoc-ref inputs "python"))
-         (var `("PYTHONPATH" prefix
-                ,(cons (string-append out "/lib/python"
-                                      (python-version python)
-                                      "/site-packages")
+  (let* ((var `("PYTHONPATH" prefix
+                ,(cons (site-packages inputs outputs)
                        (search-path-as-string->list
                         (or (getenv "PYTHONPATH") ""))))))
     (for-each (lambda (dir)
@@ -220,11 +222,7 @@ installed with setuptools."
   ;; Even if the "easy-install.pth" is not longer created, we kept this phase.
   ;; There still may be packages creating an "easy-install.pth" manually for
   ;; some good reason.
-  (let* ((out (assoc-ref outputs "out"))
-         (python (assoc-ref inputs "python"))
-         (site-packages (string-append out "/lib/python"
-                                       (python-version python)
-                                       "/site-packages"))
+  (let* ((site-packages (site-packages inputs outputs))
          (easy-install-pth (string-append site-packages "/easy-install.pth"))
          (new-pth (string-append site-packages "/" name ".pth")))
     (when (file-exists? easy-install-pth)
-- 
2.26.2





  parent reply	other threads:[~2020-06-21  1:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 14:48 [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument Jakub Kądziołka
2020-05-29  1:32 ` Leo Famulari
2020-06-21  1:27 ` Jakub Kądziołka [this message]
2020-06-21  1:27   ` [bug#40469] [PATCH core-updates v2 2/2] gnu: unicorn: Use python-build-system with grace Jakub Kądziołka
     [not found] ` <handler.40469.B.15861844998286.ack@debbugs.gnu.org>
2020-07-18 16:16   ` bug#40469: [PATCH core-updates] build-system/python: Add a #:python-output argument Jakub Kądziołka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200621012749.3742-1-kuba@kadziolka.net \
    --to=kuba@kadziolka.net \
    --cc=40469@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).