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
Cc: leo@famulari.name
Subject: [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument.
Date: Mon,  6 Apr 2020 16:48:09 +0200	[thread overview]
Message-ID: <20200406144809.30928-1-kuba@kadziolka.net> (raw)

This simplifies packages that ship Python bindings in a separate output.

* guix/build-system/python.scm (python-build): Add the argument, pass it
  build-side.
* guix/build/python-build-system.scm (site-packages): Add an #:output
  argument.
  (add-installed-pythonpath): Likewise.
  (install): Use the #:python-output argument.
  (wrap): Likewise.
  (rename-pth-file): Likewise. Use the site-packages procedure.
---

See #40267 for an example of what this change wants to accomplish.

 guix/build-system/python.scm       |  2 ++
 guix/build/python-build-system.scm | 27 ++++++++++++++-------------
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm
index e39c06528e..34cc487c8c 100644
--- a/guix/build-system/python.scm
+++ b/guix/build-system/python.scm
@@ -170,6 +170,7 @@ pre-defined variants."
                        (phases '(@ (guix build python-build-system)
                                    %standard-phases))
                        (outputs '("out"))
+                       (python-output "out")
                        (search-paths '())
                        (system (%current-system))
                        (guile #f)
@@ -196,6 +197,7 @@ provides a 'setup.py' file as its build system."
                      #:use-setuptools? ,use-setuptools?
                      #:phases ,phases
                      #:outputs %outputs
+                     #:python-output ,python-output
                      #:search-paths ',(map search-path-specification->sexp
                                            search-paths)
                      #:inputs %build-inputs)))
diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm
index 09bd8465c8..3b19072264 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -154,28 +154,29 @@
          (major+minor (take components 2)))
     (string-join major+minor ".")))
 
-(define (site-packages inputs outputs)
+(define* (site-packages inputs outputs #:key (output "out"))
   "Return the path of the current output's Python site-package."
-  (let* ((out (assoc-ref outputs "out"))
+  (let* ((out (assoc-ref outputs output))
          (python (assoc-ref inputs "python")))
     (string-append out "/lib/python"
                    (python-version python)
                    "/site-packages/")))
 
-(define (add-installed-pythonpath inputs outputs)
+(define* (add-installed-pythonpath inputs outputs #:key (output "out"))
   "Prepend the Python site-package of OUTPUT to PYTHONPATH.  This is useful
 when running checks after installing the package."
   (let ((old-path (getenv "PYTHONPATH"))
-        (add-path (site-packages inputs outputs)))
+        (add-path (site-packages inputs outputs #:output output)))
     (setenv "PYTHONPATH"
             (string-append add-path
                            (if old-path (string-append ":" old-path) "")))
     #t))
 
 (define* (install #:key outputs (configure-flags '()) use-setuptools?
+                  (python-output "out")
                   #:allow-other-keys)
   "Install a given Python package."
-  (let* ((out (assoc-ref outputs "out"))
+  (let* ((out (assoc-ref outputs python-output))
          (params (append (list (string-append "--prefix=" out))
                          (if use-setuptools?
                              ;; distutils does not accept these flags
@@ -186,7 +187,9 @@ when running checks after installing the package."
     (call-setuppy "install" params use-setuptools?)
     #t))
 
-(define* (wrap #:key inputs outputs #:allow-other-keys)
+(define* (wrap #:key inputs outputs
+               (python-output "out")
+               #:allow-other-keys)
   (define (list-of-files dir)
     (find-files dir (lambda (file stat)
                       (and (eq? 'regular (stat:type stat))
@@ -199,7 +202,7 @@ when running checks after installing the package."
                         (string-append dir "/sbin"))))
                 outputs))
 
-  (let* ((out  (assoc-ref outputs "out"))
+  (let* ((out  (assoc-ref outputs python-output))
          (python (assoc-ref inputs "python"))
          (var `("PYTHONPATH" prefix
                 ,(cons (string-append out "/lib/python"
@@ -214,17 +217,15 @@ when running checks after installing the package."
               bindirs)
     #t))
 
-(define* (rename-pth-file #:key name inputs outputs #:allow-other-keys)
+(define* (rename-pth-file #:key name inputs outputs
+                          (python-output "out")
+                          #:allow-other-keys)
   "Rename easy-install.pth to NAME.pth to avoid conflicts between packages
 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 #:output python-output))
          (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.0

             reply	other threads:[~2020-04-06 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 14:48 Jakub Kądziołka [this message]
2020-05-29  1:32 ` [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument Leo Famulari
2020-06-21  1:27 ` [bug#40469] [PATCH core-updates v2 1/2] build-system/python: Install to the python output if present Jakub Kądziołka
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=20200406144809.30928-1-kuba@kadziolka.net \
    --to=kuba@kadziolka.net \
    --cc=40469@debbugs.gnu.org \
    --cc=leo@famulari.name \
    /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).