From patchwork Mon Apr 6 14:48:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Maja_K=C4=85dzio=C5=82ka?= X-Patchwork-Id: 21143 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 6E91527BBE4; Mon, 6 Apr 2020 15:49:16 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id ED99927BBE1 for ; Mon, 6 Apr 2020 15:49:15 +0100 (BST) Received: from localhost ([::1]:33060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLT3r-0000pN-E9 for patchwork@mira.cbaines.net; Mon, 06 Apr 2020 10:49:15 -0400 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 X-Loop: help-debbugs@gnu.org Subject: [bug#40469] [PATCH core-updates] build-system/python: Add a #:python-output argument. Resent-From: Jakub =?utf-8?b?S8SFZHppb8WCa2E=?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 06 Apr 2020 14:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 40469 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40469@debbugs.gnu.org Cc: leo@famulari.name X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.15861844998286 (code B ref -1); Mon, 06 Apr 2020 14:49:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Apr 2020 14:48:19 +0000 Received: from localhost ([127.0.0.1]:49027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLT2w-00029Y-JV for submit@debbugs.gnu.org; Mon, 06 Apr 2020 10:48:18 -0400 Received: from lists.gnu.org ([209.51.188.17]:46056) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLT2u-00029L-1n for submit@debbugs.gnu.org; Mon, 06 Apr 2020 10:48:16 -0400 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 Received: (qmail 26110 invoked by uid 1009); 6 Apr 2020 16:48:11 +0200 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25773. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.00877 secs); 06 Apr 2020 14:48:11 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 6 Apr 2020 16:48:10 +0200 From: Jakub =?utf-8?b?S8SFZHppb8WCa2E=?= Date: Mon, 6 Apr 2020 16:48:09 +0200 Message-Id: <20200406144809.30928-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-Qmailux-2.08st: added fake Content-Type header X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches 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)