unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument.
@ 2020-04-06 14:48 Jakub Kądziołka
  2020-05-29  1:32 ` Leo Famulari
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jakub Kądziołka @ 2020-04-06 14:48 UTC (permalink / raw)
  To: 40469; +Cc: leo

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-07-18 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [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

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).