Subject: bug#40469: closed (Re: [PATCH core-updates] build-system/python: Add a #:python-output argument.)

From: [email-masked] (GNU bug Tracking System)
Date: Sat, 18 Jul 2020 16:18:01 +0000

Your bug report

#40469: [PATCH core-updates] build-system/python: Add a #:python-output argument.

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

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

Subject: Re: [PATCH core-updates] build-system/python: Add a #:python-output argument.
From: Jakub Kądziołka <[email-masked]>
To: [email-masked]
Date: Sat, 18 Jul 2020 18:16:54 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Patchstack pushed in commits @ 352e6c8a750c1b995ad8a357caf65eeded7e7774,
closing.

Subject: [PATCH core-updates] build-system/python: Add a #:python-output argument.
From: Jakub Kądziołka <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Mon, 6 Apr 2020 16:48:09 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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