From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:35479) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLT3f-0000oj-Fj for guix-patches@gnu.org; Mon, 06 Apr 2020 10:49:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLT3e-0005Os-9m for guix-patches@gnu.org; Mon, 06 Apr 2020 10:49:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37481) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLT3e-0005Oh-6y for guix-patches@gnu.org; Mon, 06 Apr 2020 10:49:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jLT3e-0002Bv-0B for guix-patches@gnu.org; Mon, 06 Apr 2020 10:49:02 -0400 Subject: [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:35384) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLT2s-0000Ca-J2 for guix-patches@gnu.org; Mon, 06 Apr 2020 10:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLT2r-0004qD-8E for guix-patches@gnu.org; Mon, 06 Apr 2020 10:48:14 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:40146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jLT2q-0004pI-U7 for guix-patches@gnu.org; Mon, 06 Apr 2020 10:48:13 -0400 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Mon, 6 Apr 2020 16:48:09 +0200 Message-Id: <20200406144809.30928-1-kuba@kadziolka.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 40469@debbugs.gnu.org Cc: leo@famulari.name 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