From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id qDcFKuO37l6sCQAA0tVLHw (envelope-from ) for ; Sun, 21 Jun 2020 01:29:07 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id YH3AJeO37l5jHgAAbx9fmQ (envelope-from ) for ; Sun, 21 Jun 2020 01:29:07 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 131F2940222 for ; Sun, 21 Jun 2020 01:29:07 +0000 (UTC) Received: from localhost ([::1]:53190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmonC-0002Kf-13 for larch@yhetil.org; Sat, 20 Jun 2020 21:29:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmon8-0002KN-P4 for guix-patches@gnu.org; Sat, 20 Jun 2020 21:29:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:47463) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jmon8-0004xn-Er for guix-patches@gnu.org; Sat, 20 Jun 2020 21:29:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jmon8-0004Sa-BO for guix-patches@gnu.org; Sat, 20 Jun 2020 21:29:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40469] [PATCH core-updates v2 1/2] build-system/python: Install to the python output if present. References: <20200406144809.30928-1-kuba@kadziolka.net> In-Reply-To: <20200406144809.30928-1-kuba@kadziolka.net> Resent-From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 21 Jun 2020 01:29:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40469 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40469@debbugs.gnu.org Received: via spool by 40469-submit@debbugs.gnu.org id=B40469.159270288517077 (code B ref 40469); Sun, 21 Jun 2020 01:29:02 +0000 Received: (at 40469) by debbugs.gnu.org; 21 Jun 2020 01:28:05 +0000 Received: from localhost ([127.0.0.1]:59009 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmom9-0004R9-T7 for submit@debbugs.gnu.org; Sat, 20 Jun 2020 21:28:05 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:55900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jmom5-0004QR-3N for 40469@debbugs.gnu.org; Sat, 20 Jun 2020 21:27:59 -0400 Received: (qmail 32483 invoked by uid 1009); 21 Jun 2020 03:27:55 +0200 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25848. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.00941 secs); 21 Jun 2020 01:27:55 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 21 Jun 2020 03:27:55 +0200 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Sun, 21 Jun 2020 03:27:48 +0200 Message-Id: <20200621012749.3742-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -0.01 X-TUID: Mtgc09vhTR9m * gnu/build/python-build-system.scm (python-output): New procedure. (site-packages, install): Use python-output to find the output path. (wrap, rename-pth-file): Use site-packages where appropriate. * doc/guix.texi (Build Systems): Mention the new behavior. --- Following a discussion on IRC, I am changing the approach a bit. Also, should this go on core-updates or staging? I'm not sure how to account for all the dependent packages, but just grepping for python-build-system puts this in the staging range. $ rg python-build-system gnu/packages | wc -l 1474 doc/guix.texi | 7 +++++++ guix/build/python-build-system.scm | 24 +++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 2268e159a2..7af98d3e00 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6685,6 +6685,13 @@ By default guix calls @code{setup.py} under control of @code{setuptools}, much like @command{pip} does. Some packages are not compatible with setuptools (and pip), thus you can disable this by setting the @code{#:use-setuptools?} parameter to @code{#f}. + +If a @code{"python"} output is available, the package is installed into it +instead of the default @code{"out"} output. This is useful for packages that +include a Python package as only a part of the software, and thus want to +combine the phases of @code{python-build-system} with another build system. +Python bindings are a common usecase. + @end defvr @defvr {Scheme Variable} perl-build-system diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm index 09bd8465c8..62e7a7b305 100644 --- a/guix/build/python-build-system.scm +++ b/guix/build/python-build-system.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2016 Hartmut Goebel ;;; Copyright © 2018 Ricardo Wurmus ;;; Copyright © 2018 Arun Isaac +;;; Copyright © 2020 Jakub Kądziołka ;;; ;;; This file is part of GNU Guix. ;;; @@ -154,9 +155,14 @@ (major+minor (take components 2))) (string-join major+minor "."))) +(define (python-output outputs) + "Return the path of the python output, if there is one, or fall-back to out." + (or (assoc-ref outputs "python") + (assoc-ref outputs "out"))) + (define (site-packages inputs outputs) "Return the path of the current output's Python site-package." - (let* ((out (assoc-ref outputs "out")) + (let* ((out (python-output outputs)) (python (assoc-ref inputs "python"))) (string-append out "/lib/python" (python-version python) @@ -175,7 +181,7 @@ when running checks after installing the package." (define* (install #:key outputs (configure-flags '()) use-setuptools? #:allow-other-keys) "Install a given Python package." - (let* ((out (assoc-ref outputs "out")) + (let* ((out (python-output outputs)) (params (append (list (string-append "--prefix=" out)) (if use-setuptools? ;; distutils does not accept these flags @@ -199,12 +205,8 @@ when running checks after installing the package." (string-append dir "/sbin")))) outputs)) - (let* ((out (assoc-ref outputs "out")) - (python (assoc-ref inputs "python")) - (var `("PYTHONPATH" prefix - ,(cons (string-append out "/lib/python" - (python-version python) - "/site-packages") + (let* ((var `("PYTHONPATH" prefix + ,(cons (site-packages inputs outputs) (search-path-as-string->list (or (getenv "PYTHONPATH") "")))))) (for-each (lambda (dir) @@ -220,11 +222,7 @@ 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)) (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.2