From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:5f26::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IKlFLYofmWWvGgAAkFu2QA (envelope-from ) for ; Sat, 06 Jan 2024 10:38:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id iF1FKoofmWVLnQAAqHPOHw (envelope-from ) for ; Sat, 06 Jan 2024 10:38:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=fastmail.net header.s=fm2 header.b=GHo3VDeL; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b=Zj0+v42h; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=fastmail.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1704533898; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ZyjO1UMWmjb+1MHGEfjXUVDVcX8tsCJwWuc1RJ876n8=; b=sHsd41/HjYvjJR2NNfxb4IIAk+xcxQwc99KplDNhGuVZfBfB5LYiTtJuj+BZS/vu88dB9u E9+KAZlpNaYkquGKeizJf5vFPhy1YtK/Sx1W65xNId63MW/w0PbX5viIw1iEByNgQYG9Br /eCxv3baQ3ykiScM+Rwvzq0POa+JnQ3ONASaTyoIiwctAH5VU9r6qN3pX0oF3WoHG9mOhw hFo7vgMZnINzXZpIlDGIiMmRzB02d17+bX+rcOB+xfSRkuk0u9lUiDntxiUdjapwvzPgC3 4zZerlrrXKipUp1EX2BZsztlc/lPa3Y+szeu7hNqP19i+jvJ49yTN44jueZY7A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=fastmail.net header.s=fm2 header.b=GHo3VDeL; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm2 header.b=Zj0+v42h; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=fastmail.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1704533898; a=rsa-sha256; cv=none; b=rOvP22TrNplWSpBDNtVNDH2Py2Wh9RafiRMbQAkKuiYjERUTkK4UrrlDYTp5OJ+9HkdCa2 nuPEsf8YWiKr0u0Kk3bM3vo4iX19QKlgJulqxp7vK4tMKgnb4Ur4Q3+uZdNv5lv1qw4dod pJNUJldsNvBuAT65fWEXaLlAApNg9zaQqoWjJoQ4HLKrRRUxdcmJgoItd72uSjyAAo+9xx e8o5aN1ijMpLH/vI39TjDUc1Hc1DDl0oXxR78Z/l88VIIP3W/2/EZUtM4AaHSvG4Ykg2KB W1GSMjwHa5riHAyurYp99EDpV2d/bZG3a7EP1wn5q+RmGvK5ZaAN7OyVy8kQow== 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 5C18C108F7 for ; Sat, 6 Jan 2024 10:38:17 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rM37v-0006Y1-F8; Sat, 06 Jan 2024 04:37:59 -0500 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 1rM37t-0006Xf-Q6 for guix-patches@gnu.org; Sat, 06 Jan 2024 04:37:57 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rM37t-0002Oj-IR for guix-patches@gnu.org; Sat, 06 Jan 2024 04:37:57 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rM37x-0004tc-On for guix-patches@gnu.org; Sat, 06 Jan 2024 04:38:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68241] [PATCH] gnu: python: Fix sitecustomize.py References: In-Reply-To: Resent-From: Konrad Hinsen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 06 Jan 2024 09:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68241 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68241@debbugs.gnu.org Received: via spool by 68241-submit@debbugs.gnu.org id=B68241.170453385818790 (code B ref 68241); Sat, 06 Jan 2024 09:38:01 +0000 Received: (at 68241) by debbugs.gnu.org; 6 Jan 2024 09:37:38 +0000 Received: from localhost ([127.0.0.1]:58595 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM37Z-0004sz-OS for submit@debbugs.gnu.org; Sat, 06 Jan 2024 04:37:38 -0500 Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:38771) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rM37W-0004sj-Tv for 68241@debbugs.gnu.org; Sat, 06 Jan 2024 04:37:35 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 53CAA3200B35; Sat, 6 Jan 2024 04:37:24 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sat, 06 Jan 2024 04:37:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.net; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to; s=fm2; t=1704533843; x=1704620243; bh=ZyjO1UMWmj b+1MHGEfjXUVDVcX8tsCJwWuc1RJ876n8=; b=GHo3VDeLehGLacWE/k+gGFa2dS 3U+RkQ7LBZoUJmD8L70Su919r2tAOgQzsE8kqPAmA1M65RRftxQwoKW6CYZnZOXh 0fFmdI503sYUi+JNFn/5DDwQkmy3q0/rCVD3ENJ+kCLlFdDhkVSHswufflw/iV2W qL8YoTzoxXoTyKGFsFfPiwy98glPRHwtumpMmytZkN59Dw5Cjs/+pLrQdyoW4KUZ o05xbPjNewJqFLVZzcfpCo6RuZqmQcRfV/HomnE90Q0f+3Z0034UKVfb/t+oXJtZ NN/xDQYKiXCygsHBwx0EdESLyzGpwQtYgq84EF3p+6fROI3l0VGfymmlusEg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:message-id:mime-version:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1704533843; x=1704620243; bh=ZyjO1UMWmjb+1MHGEfjXUVDVcX8t sCJwWuc1RJ876n8=; b=Zj0+v42hTrC9n/zzXNa5wQSrUY6R+e4EU92YiOPINViB hCwxo7CFT64QX+imrrxQy07G7fme7BHmTyeiyr9L2LpQFsWGkJ6Us29aTwXWK8eY fooPHnVT50R1jVX85gl0aUH900FEk01Johbhx9wixb4XtQctOWEIWUu07t89H/rj HY0fyeyjL+NbtTIRDxmC08jQzkkwej4qcW5zv6lGP16RcYo+YNp5YWyfYbEaKsO7 Of2qH9RXun+f4vS+fweri0wg4ogU6hW9dASEf5oimOEQ8LMyRX7o/UygJBnzMKeP 0fc2PRaRo8osz4Cswt9+NYC6Sd/q6ueLCudl3QPUyA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdehuddgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkgggtgfesthhqredttd dtjeenucfhrhhomhepmfhonhhrrgguucfjihhnshgvnhcuoehkohhnrhgrugdrhhhinhhs vghnsehfrghsthhmrghilhdrnhgvtheqnecuggftrfgrthhtvghrnhepgfegheehlefhvd ffveffteejueeiffffkeetuddvfeevffevieetfeelveeifeelnecuffhomhgrihhnpehg nhhurdhorhhgpdhprghthhdrthhonecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrg hmpehmrghilhhfrhhomhepkhhonhhrrggurdhhihhnshgvnhesfhgrshhtmhgrihhlrdhn vght X-ME-Proxy: Feedback-ID: i184641e2:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 6 Jan 2024 04:37:22 -0500 (EST) From: Konrad Hinsen Date: Sat, 06 Jan 2024 10:37:23 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: -5.28 X-Spam-Score: -5.28 X-Migadu-Queue-Id: 5C18C108F7 X-TUID: XNig58VY43j0 * gnu/packages/aux-files/python/sitecustomize.py: normalize sys.prefix to deal with situations where it contains "../" This happens in particular when running Python from a Singularity image created by Guix. See https://issues.guix.gnu.org/53258. This is a variant of https://issues.guix.gnu.org/68241 that implements the fix as a graft rather than as a patch to the Python package. Since many packages in Guix depend on Python, the basic patch leads to enormous build times. A graft should be sufficient since the fix has no impact on Python being used within Guix. Change-Id: I3b07f4edf474a12fcabfbf90f37c4c0223278330 --- .../aux-files/python/sitecustomize-fixed.py | 65 +++++++++++++++++++ gnu/packages/python.scm | 22 ++++++- 2 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/aux-files/python/sitecustomize-fixed.py diff --git a/gnu/packages/aux-files/python/sitecustomize-fixed.py b/gnu/pac= kages/aux-files/python/sitecustomize-fixed.py new file mode 100644 index 0000000000..82ea91104d --- /dev/null +++ b/gnu/packages/aux-files/python/sitecustomize-fixed.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# GNU Guix --- Functional package management for GNU +# Copyright =C2=A9 2021 Maxim Cournoyer +# +# This file is part of GNU Guix. +# +# GNU Guix is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or (at +# your option) any later version. +# +# GNU Guix is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Guix. If not, see . + +import os +import site +import sys + +# Commentary: +# +# Site-specific customization for Guix. +# +# The program below honors the GUIX_PYTHONPATH environment variable to +# discover Python packages. File names appearing in this variable that ma= tch +# a predefined versioned installation prefix are added to the sys.path. T= o be +# considered, a Python package must be installed under the +# 'lib/pythonX.Y/site-packages' directory, where X and Y are the major and +# minor version numbers of the Python interpreter. +# +# Code: + +major_minor =3D '{}.{}'.format(*sys.version_info) +site_packages_prefix =3D os.path.join( + 'lib', 'python' + major_minor, 'site-packages') +python_site =3D os.path.normpath(os.path.join(sys.prefix, site_packages_pr= efix)) + +try: + all_sites_raw =3D os.environ['GUIX_PYTHONPATH'].split(os.path.pathsep) +except KeyError: + all_sites_raw =3D [] +# Normalize paths, otherwise a trailing slash would cause it to not match. +all_sites_norm =3D [os.path.normpath(p) for p in all_sites_raw] +matching_sites =3D [p for p in all_sites_norm + if p.endswith(site_packages_prefix)] + +if matching_sites: + # Deduplicate the entries, append them to sys.path, and handle any + # .pth files they contain. + for s in matching_sites: + site.addsitedir(s) + + # Move the entries that were appended to sys.path in front of + # Python's own site-packages directory. This enables Guix + # packages to override Python's bundled packages, such as 'pip'. + python_site_index =3D sys.path.index(python_site) + new_site_start_index =3D sys.path.index(matching_sites[0]) + if python_site_index < new_site_start_index: + sys.path =3D (sys.path[:python_site_index] + + sys.path[new_site_start_index:] + + sys.path[python_site_index:new_site_start_index]) diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index 51d5f598d7..3cc3c08360 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -414,7 +414,16 @@ (define-public python-2.7 packages; exception-based error handling; and very high level dynamic data types.") (properties '((cpe-name . "python"))) - (license license:psfl))) + (license license:psfl) + (replacement python-2.7-fixed))) + +(define-public python-2.7-fixed + (package + (inherit python-2.7) + (native-inputs + (modify-inputs (package-native-inputs python-2.7) + (replace "sitecustomize.py" + (local-file (search-auxiliary-file "python/sitecustomize-fixed.py= "))))))) =20 ;; Current 2.x version. (define-public python-2 python-2.7) @@ -594,7 +603,16 @@ (define-public python-3.10 ;; Python 3.9. (search-path-specification (variable "PYTHONTZPATH") - (files (list "share/zoneinfo"))))))) + (files (list "share/zoneinfo"))))) + (replacement python-3.10-fixed))) + +(define-public python-3.10-fixed + (package + (inherit python-3.10) + (native-inputs + (modify-inputs (package-native-inputs python-3.10) + (replace "sitecustomize.py" + (local-file (search-auxiliary-file "python/sitecustomize-fixed.py= "))))))) =20 ;; Current 3.x version. (define-public python-3 python-3.10) base-commit: 7b0863f07a113caef26fea13909bd97d250b629e --=20 2.41.0