From patchwork Tue Jul 11 18:14:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wojtek Kosior X-Patchwork-Id: 51677 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 B9C1A27BBE9; Tue, 11 Jul 2023 20:56:29 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 9200027BBE9 for ; Tue, 11 Jul 2023 20:56:28 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJJSy-00073f-II; Tue, 11 Jul 2023 15:56:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJHt9-0005l0-AJ for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJHt9-0008KX-09 for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qJHt7-00070T-Rg; Tue, 11 Jul 2023 14:15:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64573] [PATCH 1/3] guix: build: python-build-system: Don't process user site dir Resent-From: Wojtek Kosior Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Tue, 11 Jul 2023 18:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64573 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64573@debbugs.gnu.org Cc: Wojtek Kosior , Lars-Dominik Braun , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , jgart Received: via spool by 64573-submit@debbugs.gnu.org id=B64573.168909929026875 (code B ref 64573); Tue, 11 Jul 2023 18:15:01 +0000 Received: (at 64573) by debbugs.gnu.org; 11 Jul 2023 18:14:50 +0000 Received: from localhost ([127.0.0.1]:51005 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHsw-0006zP-CT for submit@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:50 -0400 Received: from koszko.org ([93.95.227.159]:49658) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHsu-0006zH-KX for 64573@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=koszko.org; s=mail; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=FphfeolugLMMuFUtWAnUxa/GCZAj9KkOVqHLL8GObFs=; b=g3aws3G1f44MCUkrKS62Eq1fg6 IVdIQ40bYFoXDGw/YGiiGnqQc37MMm4HOd45jmUpEzQ18eyTr77SlBUBlcQCpGK7mFHqcpwL8U1kD LdzqTKvIPuJIgp87uh2v5ceXMqZkuDJakoWQwt1bT6Y82nhJipCo6RHBOh+bwbX9JYgV+g4KLsD72 M0gGUGwWF+k6JX725l1iiqeyZ9O8WRYgMobVXGIA3U9P7KiugijL4OnQA5A26QcviUkXI8IEzMUwp IU8RElpIyoImsio4mPxuFGn5reW+RhpYUJTV3kq+T2D3tpgzgtQWw6zMekkXlkYmMdB4LSWXDyv1l ZWyQ6rgz3xqRAGCPvmFTHFdhCIjcJ6wygmU+Xdh6c/8BK8p26/l0djSXMS4YyEmHlMx1fA+YwaH26 3xArYCuFC2Hzr2Sp9bV2RJ1J2wEpdmsAidnfeg9fYxCRYWwRmCXC+YplSr5NQZdyg/di+LZwHZKAT 2PCjwusTIXwGORCUGUyqwXspvUj+zhRi169p8Jo1k6PRwbWKpLAlek/BfXkrbspd5T+iwyHdg8399 gSXgy0xzbj1lpKR0ICTYmkGUCMpRI1fZfaoSbpHP6aIT+VmmL25itCXS3MJus7bnNC56udS93pUhL rbWAtdBxZHQRbs3FQdTiyB2bpd8Sy/ZnB9L1Rlzis=; Received: from [77.252.47.107] (helo=localhost.localdomain) by koszko.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJHst-0007hX-RB; Tue, 11 Jul 2023 20:14:48 +0200 Date: Tue, 11 Jul 2023 20:14:38 +0200 Message-Id: <9a11c2f1af6036714c5e998ddf2554f34da4ffe2.1689093931.git.koszko@koszko.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Tue, 11 Jul 2023 15:56:06 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Wojtek Kosior X-ACL-Warn: , Wojtek Kosior via Guix-patches X-Patchwork-Original-From: Wojtek Kosior via Guix-patches via From: Wojtek Kosior Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build/python-build-system.scm (wrap): Define PYTHONNOUSERSITE for programs so they don't incorrectly pick up local, pip-installed libraries. --- guix/build/python-build-system.scm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm index aa04664b25..93aafc4aa9 100644 --- a/guix/build/python-build-system.scm +++ b/guix/build/python-build-system.scm @@ -241,12 +241,16 @@ (define* (wrap #:key inputs outputs #:allow-other-keys) (define %sh (delay (search-input-file inputs "bin/bash"))) (define (sh) (force %sh)) - (let* ((var `("GUIX_PYTHONPATH" prefix - ,(search-path-as-string->list - (or (getenv "GUIX_PYTHONPATH") ""))))) + (let* ((var-pythonpath `("GUIX_PYTHONPATH" prefix + ,(search-path-as-string->list + (or (getenv "GUIX_PYTHONPATH") "")))) + ;; Harden applications by preventing Python from automatically + ;; picking up libraries in user site directory. + (var-usersite '("PYTHONNOUSERSITE" = ("GUIX_WRAPPER")))) (for-each (lambda (dir) (let ((files (list-of-files dir))) - (for-each (cut wrap-program <> #:sh (sh) var) + (for-each (cut wrap-program <> #:sh (sh) + var-pythonpath var-usersite) files))) bindirs))) From patchwork Tue Jul 11 18:14:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wojtek Kosior X-Patchwork-Id: 51679 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 4EC3527BBE9; Tue, 11 Jul 2023 20:56:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D789327BBE2 for ; Tue, 11 Jul 2023 20:56:40 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJJSy-00073g-8t; Tue, 11 Jul 2023 15:56:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJHt8-0005kr-Pz for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJHt8-0008KY-GU for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qJHt8-00070d-7v; Tue, 11 Jul 2023 14:15:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64573] [PATCH 2/3] gnu: python-pip: Enable user site even with PYTHONNOUSERSITE Resent-From: Wojtek Kosior Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Tue, 11 Jul 2023 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64573 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64573@debbugs.gnu.org Cc: Wojtek Kosior , Lars-Dominik Braun , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , jgart Received: via spool by 64573-submit@debbugs.gnu.org id=B64573.168909929526899 (code B ref 64573); Tue, 11 Jul 2023 18:15:02 +0000 Received: (at 64573) by debbugs.gnu.org; 11 Jul 2023 18:14:55 +0000 Received: from localhost ([127.0.0.1]:51011 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHt0-0006zh-OX for submit@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:55 -0400 Received: from koszko.org ([93.95.227.159]:49660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHsy-0006zX-EY for 64573@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=koszko.org; s=mail; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=s9zli9yJkgHmVaocarH55BXajJ4+aUrC8udkYnUWFo8=; b=UM+RRRi/Ee14Mr21XhJttHqfuv R14+V2lf5MpOjZXPR4qvDnDe0DN+GWbcfbRf1DtRnkEmwLbqESmE0R47MLmMlAIL5HuXvNo+vPGVn CgUnFdFMOIwE0/53kbwmEXXABgB8POaoQSZGFblpGLbNkVPg3w9SPqePafu5hBmhQ4lSQl/lRlUaq +6Ud22MXWJidfuAnSJwovT9gY3zAs1z8DOftsFH0gq3ummA4CZI3sj/RQPN0zIAZSqLpEAzgYUKnP QdpdkmtwaxgjF9mu3agV9Qx32zCnm1iJEVrzysBvOdHtV3Rvge0/+BJBdM+0yps3OWZH9B0XHNOqT ZQR3z++V4t3dRjLHmKkeIIbPKD+giTZgCC8ykOi600NfQFRm5ztQ2ThZCleA1tDn7nk6CeEwReKl/ o2Bu8uCEALCDVcgBlAm63kNCqck6Cx5zx7fR3N6LBcSwCGco5I+41EmdFh0J1xRoL87uTNwN/k8q6 qiyjsOCEYq1pJiFwLcC5UTaBngB0cz8yYx7M0T3BtKzDTu+jky/2F7clVSwyS44ZLM5S9fEITglQj Gp1xNofP9qID1DjERI7a+yRBAeKH/sUuYggDHfJ3PqxOxFfPjnP36R2JF4G/TpKPl6fg74W1wgoXd Kz60mcRQiwdJT8hFqGvtbMOKyPIXDmIG9QASM10zc=; Received: from [77.252.47.107] (helo=localhost.localdomain) by koszko.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJHsx-0007hX-N5; Tue, 11 Jul 2023 20:14:51 +0200 Date: Tue, 11 Jul 2023 20:14:39 +0200 Message-Id: <6165ff7042c6d1269a471924e7e383be04f6c0da.1689093931.git.koszko@koszko.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Tue, 11 Jul 2023 15:56:06 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Wojtek Kosior X-ACL-Warn: , Wojtek Kosior via Guix-patches X-Patchwork-Original-From: Wojtek Kosior via Guix-patches via From: Wojtek Kosior Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/python-build.scm (python-pip): Patch pip to allow installing to user site dir when PYTHONNOUSERSITE is set by Guix wrapper script to 'GUIX_WRAPPER' string. --- gnu/packages/python-build.scm | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gnu/packages/python-build.scm b/gnu/packages/python-build.scm index 154c97e9e4..54d12f3fdc 100644 --- a/gnu/packages/python-build.scm +++ b/gnu/packages/python-build.scm @@ -269,7 +269,15 @@ (define-public python-pip "0jnk639v9h7ghslm4jnlic6rj3v29nygflx1hgxxndg5gs4kk1a0")))) (build-system python-build-system) (arguments - '(#:tests? #f)) ; there are no tests in the pypi archive. + `(#:tests? #f ;there are no tests in the pypi archive + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'allow-installing-to-user-site + (lambda _ + (substitute* "src/pip/_internal/commands/install.py" + (("( *if not site\\.ENABLE_USER_SITE):" match if-clause) + (string-append if-clause + " and not os.environ['PYTHONNOUSERSITE'] == 'GUIX_WRAPPER':")))))))) (home-page "https://pip.pypa.io/") (synopsis "Package manager for Python software") (description From patchwork Tue Jul 11 18:14:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wojtek Kosior X-Patchwork-Id: 51678 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 589F427BBE2; Tue, 11 Jul 2023 20:56:31 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 97AD527BBEA for ; Tue, 11 Jul 2023 20:56:29 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJJSy-000749-QY; Tue, 11 Jul 2023 15:56:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qJHtB-0005lL-FR for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qJHtA-0008Vc-RZ for guix-patches@gnu.org; Tue, 11 Jul 2023 14:15:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qJHt8-00070p-MQ; Tue, 11 Jul 2023 14:15:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64573] [PATCH 3/3] guix: build: python-build-system: Honor disable-user-site? argument Resent-From: Wojtek Kosior Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Tue, 11 Jul 2023 18:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64573 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64573@debbugs.gnu.org Cc: Wojtek Kosior , Lars-Dominik Braun , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , jgart Received: via spool by 64573-submit@debbugs.gnu.org id=B64573.168909929626907 (code B ref 64573); Tue, 11 Jul 2023 18:15:02 +0000 Received: (at 64573) by debbugs.gnu.org; 11 Jul 2023 18:14:56 +0000 Received: from localhost ([127.0.0.1]:51013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHt2-0006zv-74 for submit@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:56 -0400 Received: from koszko.org ([93.95.227.159]:49662) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJHsz-0006ze-LY for 64573@debbugs.gnu.org; Tue, 11 Jul 2023 14:14:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=koszko.org; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=P4j8jnmrCkTEWrV7StmOn94mZDOakLmy64o7dC1jpIM=; b=SbepEovkyAc6neIJLybIFEAJmB WBBWnKFwDpl1wBIzNRwK5yBbq8LQLYOmb+f//N9gdCl6ALRLmzSx6SIfLGS0KYOiAPAIS7S7YoItl g/OI0P7WkH5czQp5UWLsOXitqU0JRzqXrH2MW+8o1ie71a6IiVySQkLm6HinMRxRZsf4nl9rfDaIf ecZkZpKIi1R533yKsEH9ZixZGWa4NYUezv47W+yVB7LUWe50ZNTSw0tb8b2BZYR5lLmzaP5WmkkPt IXq6SPBqp8zNDThOzADMdqqmJuiDZKa3tQ8EfeA3ev+0YlytMKjRmId+FuL0DRrFnM1KGY7RUjdtf zLRpIHO/C2Pdxs8Q2ouefbeX9Hu2TR8tsGWVgsLD1S/wCGXKgYRUbcg4oGHczignO3SYwD1iBlyCu U9/j4Nl+JmIPbrvnferqR4nviMKWkIHAOsW1cfoO3uXG+4ZPmNMoFjtkV4BcD0jmxNme/UXH7lkQQ e4URWIvA5Fj7ea2986qAK7UXnmnppAG7j/c98IE0fYzY31pfgt+rcwEjEOnN752eQ1kI1JQHismN1 uTEGXUtrjLkn32VQgGgeOEcRcQdbirHhoCBkKk+v2noJJMkH5q+s+PZZex9viQBbkbgYuIv2FTrgC WjZh6UtUXraSaO93T/PgaSy+/XEAXG5hcAu450s08=; Received: from [77.252.47.107] (helo=localhost.localdomain) by koszko.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qJHsy-0007hX-Td; Tue, 11 Jul 2023 20:14:53 +0200 Date: Tue, 11 Jul 2023 20:14:40 +0200 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Tue, 11 Jul 2023 15:56:06 -0400 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Wojtek Kosior X-ACL-Warn: , Wojtek Kosior via Guix-patches X-Patchwork-Original-From: Wojtek Kosior via Guix-patches via From: Wojtek Kosior Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * guix/build/python-build-system.scm (wrap): Only define the PYTHONNOUSERSITE wrapper variable if keyword argument disable-user-site? evaluates to true. * guix/build-system/python.scm (python-build): Pass disable-user-site? argument to the build side with the default of #t. --- guix/build-system/python.scm | 2 ++ guix/build/python-build-system.scm | 31 +++++++++++++++++------------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index cca009fb28..dd86cbd4bf 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -171,6 +171,7 @@ (define* (python-build name inputs (tests? #t) (test-target "test") (use-setuptools? #t) + (disable-user-site? #t) (configure-flags ''()) (phases '%standard-phases) (outputs '("out")) @@ -192,6 +193,7 @@ (define* (python-build name inputs #:source #+source #:configure-flags #$configure-flags #:use-setuptools? #$use-setuptools? + #:disable-user-site? #$disable-user-site? #:system #$system #:test-target #$test-target #:tests? #$tests? diff --git a/guix/build/python-build-system.scm b/guix/build/python-build-system.scm index 93aafc4aa9..959d062bb2 100644 --- a/guix/build/python-build-system.scm +++ b/guix/build/python-build-system.scm @@ -11,6 +11,7 @@ ;;; Copyright © 2020 Efraim Flashner ;;; Copyright © 2021 Lars-Dominik Braun ;;; Copyright © 2021 Maxime Devos +;;; Copyright © 2023 Wojtek Kosior ;;; ;;; This file is part of GNU Guix. ;;; @@ -222,7 +223,7 @@ (define* (install #:key inputs outputs (configure-flags '()) use-setuptools? (invoke "python" "-m" "compileall" "--invalidation-mode=unchecked-hash" out)))) -(define* (wrap #:key inputs outputs #:allow-other-keys) +(define* (wrap #:key inputs outputs disable-user-site? #:allow-other-keys) (define (list-of-files dir) (find-files dir (lambda (file stat) (and (eq? 'regular (stat:type stat)) @@ -241,18 +242,22 @@ (define* (wrap #:key inputs outputs #:allow-other-keys) (define %sh (delay (search-input-file inputs "bin/bash"))) (define (sh) (force %sh)) - (let* ((var-pythonpath `("GUIX_PYTHONPATH" prefix - ,(search-path-as-string->list - (or (getenv "GUIX_PYTHONPATH") "")))) - ;; Harden applications by preventing Python from automatically - ;; picking up libraries in user site directory. - (var-usersite '("PYTHONNOUSERSITE" = ("GUIX_WRAPPER")))) - (for-each (lambda (dir) - (let ((files (list-of-files dir))) - (for-each (cut wrap-program <> #:sh (sh) - var-pythonpath var-usersite) - files))) - bindirs))) + (let ((vars (filter identity + `(("GUIX_PYTHONPATH" prefix + ,(search-path-as-string->list + (or (getenv "GUIX_PYTHONPATH") ""))) + ;; Harden applications by preventing Python from + ;; automatically picking up libraries in user site + ;; directory. + ,(and disable-user-site? + '("PYTHONNOUSERSITE" = ("GUIX_WRAPPER"))))))) + (for-each (lambda (var) + (for-each (lambda (dir) + (let ((files (list-of-files dir))) + (for-each (cut wrap-program <> #:sh (sh) var) + files))) + bindirs)) + vars))) (define* (rename-pth-file #:key name inputs outputs #:allow-other-keys) "Rename easy-install.pth to NAME.pth to avoid conflicts between packages