From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id INoWMD2qLWF5CAAAgWs5BA (envelope-from ) for ; Tue, 31 Aug 2021 06:04:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id QDuaKz2qLWE/agAAbx9fmQ (envelope-from ) for ; Tue, 31 Aug 2021 04:04:13 +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 0F0E115D16 for ; Tue, 31 Aug 2021 06:04:13 +0200 (CEST) Received: from localhost ([::1]:47180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKv0N-0006PL-2J for larch@yhetil.org; Tue, 31 Aug 2021 00:04:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42112) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKv0E-0006P2-8R for bug-guix@gnu.org; Tue, 31 Aug 2021 00:04:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKv0E-0002RP-1J for bug-guix@gnu.org; Tue, 31 Aug 2021 00:04:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKv0D-0006K7-Pd for bug-guix@gnu.org; Tue, 31 Aug 2021 00:04:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#50105: [core-updates] Python sitecustomize issue. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 31 Aug 2021 04:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50105 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Mathieu Othacehe Received: via spool by 50105-submit@debbugs.gnu.org id=B50105.163038262024256 (code B ref 50105); Tue, 31 Aug 2021 04:04:01 +0000 Received: (at 50105) by debbugs.gnu.org; 31 Aug 2021 04:03:40 +0000 Received: from localhost ([127.0.0.1]:60846 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKuzo-0006J6-Dx for submit@debbugs.gnu.org; Tue, 31 Aug 2021 00:03:40 -0400 Received: from mail-qk1-f173.google.com ([209.85.222.173]:38833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKuzi-0006Ip-No for 50105@debbugs.gnu.org; Tue, 31 Aug 2021 00:03:35 -0400 Received: by mail-qk1-f173.google.com with SMTP id f22so18185188qkm.5 for <50105@debbugs.gnu.org>; Mon, 30 Aug 2021 21:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=WX5S547bi8PEd9XH4nuu1OHOcbDE11/zF2RA7z1RDOw=; b=HxVYyAlUNJai+SRAeutv8+iTPSFnsLvm6tBcqvwOAfRUyarEiAe2aCgUlWeFFGc6d3 JIpnQIKdewcGRCnW0xjwg357uj0XcQzUTB8KMmbLkLTM/i9XveXTSV0GJPUNUoSUS2zs RCnQFrSbyllfQGgYGVYmDldNh/jDVDuQQybOD5FrXg4hfZJkqBGuYQc0K+0kwfQDhFwI Qpppc1BRK/VIr39vNIX9wsqp3xVwTz7eusht8b7nVY5WXCQixqVMOC89cZ7NXoCvXXr6 a0CR5o652RVIXOy8Oaq3WqT6ZPP0KeHkw/I1NYEJ+MJmx5yX6H/fjLcWnHOhRmqvCfc+ wEKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=WX5S547bi8PEd9XH4nuu1OHOcbDE11/zF2RA7z1RDOw=; b=LGtktjS+aZhxcl0fGsCUMwNkRpdNFKG6j1DSsoSdicTWua/Zbb3HNFrFCBGvy92qr5 riwhMbirm+bswfDysQnwdFhCGMjL+tbm3GAouxo3JBDLGLX1ylYZ7GsmdhznMy3BkV+m vr/7krEqX16JDbzj2Q1ERkSIGl2wlSZfmgowRnzMB+gEuzrs+CQ0fhfQQoxr57A+qbA0 57jKq/6VbK7dqU+UiMMD1T/NvjlR/8wtuXZRCXig+znGetGdgJ3n/frqoyyJTO/SM8wa 0KuHUALVf/0OUh426v29BfKOsY32vEbtNRB6mXBogIYt7u9kO7lCI4bk2EQo7r+M7DwX qfww== X-Gm-Message-State: AOAM531ujjl7QzspHiTPAui/jyyGxbC777+PassbBNZPFvjhhWtLe+8T JWGYlDp/qYSFhwGot0jhHFvXwzLUmV45OQ== X-Google-Smtp-Source: ABdhPJzDoDL5NgdP7Nrvkg1uvXyb3OmOxFLmbj3a8ElmhJrFe31q0UC8WjXRRyb+KVcFEzlE7Ysg3w== X-Received: by 2002:a05:620a:12e4:: with SMTP id f4mr1038371qkl.373.1630382605053; Mon, 30 Aug 2021 21:03:25 -0700 (PDT) Received: from hurd (dsl-10-141-212.b2b2c.ca. [72.10.141.212]) by smtp.gmail.com with ESMTPSA id v8sm9364873qtk.49.2021.08.30.21.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 21:03:24 -0700 (PDT) From: Maxim Cournoyer References: <878s0zoz98.fsf@gnu.org> Date: Tue, 31 Aug 2021 00:03:23 -0400 In-Reply-To: <878s0zoz98.fsf@gnu.org> (Mathieu Othacehe's message of "Wed, 18 Aug 2021 11:53:07 +0200") Message-ID: <87zgsyi7lg.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 50105@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630382653; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: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=WX5S547bi8PEd9XH4nuu1OHOcbDE11/zF2RA7z1RDOw=; b=fg4mHdjQfYreJGaUMt7AXAq52dhxsMBu3VIguK9STf+KifgMKkHmsVXPVEdPYXGAujs5Q0 KH4sCe/vnJHR4RWPBJVhpXkczY82n3+KkMZ0aqeuWQRMKwlGEe7VxVCizzzjin7uww4S4I KQK2wlXNvwOLxqf22khuFn/0ftxc5ab7NK9fT6+KgQVgqVWpPC0GLL9eYOj8iBGmRF7uGK 3tYOJVg30ALAqKupWJ2tj3eJoagA3T1Hy0Mru2RR3V2hUse6n/YjIN+36dQ6ClkwgrU5Fa ucD88OnKDvTEwRnjXW5JIeO+Qc3GkOtDTf8Od1KpYertrH0Lhe+x56or4Ldnbg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630382653; a=rsa-sha256; cv=none; b=Pjo1JuS/K8rmenW6LVKlAEdiCl8WEShT5QdFJSXS6NW2ogU/tOzbuOMcdeW9zy18tQTK1U 2QoNgEZWR2f5CYqUYD2+XRG+DF2JyNq+r/k30/6uEUU2lsqA0xf0or7gYRNoNMCB/J496s X07pNDiSYnvfsHk6MwlfwqTAc3Ud7NnIw0AsjGTdBpCEXP3+wUKKb8jxNuu0rM0nFHQs4+ I25v7MD2toWC3ywAGNzGCNDoHM3kFJztw8HzejA6GH/tIqdwMjIvqhv2utlja7w04YKq/B R5unS0NvW0sR4XH0oV9RhDeSXMqQp+fQVRiSNxM64SQgtzLIsJ+LV4tjPINfiQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=HxVYyAlU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -1.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=HxVYyAlU; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 0F0E115D16 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: 15uqss9rgTY4 --=-=-= Content-Type: text/plain Hi Mathieu, [...] > I think the issue here lies in the sitecustomize.py file introduced with > cb72f9a773e0931ee3758c851d96007ded034e4c. > > python_root = os.path.realpath(sys.executable).split('/bin/')[0] > > > When using the Python C library, sys.executable is not the expected > python binary but the test binary. > > So when we try to find the associated libraries in the Python search > path, this way: > > index = sys_path_absolute.index(python_site) > sys.path = sys.path[:index] + matching_sites + sys.path[index:] > > > we get: > > ValueError: '/home/mathieu/glade-3.38.2/build/lib/python3.9/site-packages' is not in list > > > Running the test with the PYTHONPATH set to: > > PYTHONPATH=/home/mathieu/glade-3.38.2/build/lib/python3.9/site-packages:$PYTHONPATH > > is a way to work around this issue. > > The fix here would be to replace sys.executable in the sitecustomize.py > with something more adequate, but I have no idea what could it be. >From the doc [0], sys.prefix seems to be more correct. This had been suggested by Hartmut some time ago and I had this patch ready recently. Perhaps it already addresses the issue at hand? You'll find it attached. It hasn't gotten much testing yet. [0] https://docs.python.org/3/library/sys.html#sys.prefix --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-aux-files-sitecustomize-Cleanup-and-add-explanatory-.patch >From e693b38a6d5c370e13f795c6303f50871ec78ae4 Mon Sep 17 00:00:00 2001 From: Maxim Cournoyer Date: Tue, 3 Aug 2021 20:41:20 -0400 Subject: [PATCH] aux-files: sitecustomize: Cleanup and add explanatory comments. * gnu/packages/aux-files/python/sitecustomize.py: Add a comment explaining the general idea. (major_minor): Use the unpacking operator (*) to provide the arguments. (site_packages_prefix): Use os.path.join to form the path. (python_site): Likewise. (all_sites_raw): Split on os.path.pathsep. (sys.path): Directly splice the result in the list. Suggested-by: Hartmut Goebel --- .../aux-files/python/sitecustomize.py | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/gnu/packages/aux-files/python/sitecustomize.py b/gnu/packages/aux-files/python/sitecustomize.py index 65d3c7d554..71e328b9ac 100644 --- a/gnu/packages/aux-files/python/sitecustomize.py +++ b/gnu/packages/aux-files/python/sitecustomize.py @@ -20,13 +20,26 @@ import os import sys -python_root = os.path.realpath(sys.executable).split('/bin/')[0] -major_minor = '{}.{}'.format(sys.version_info[0], sys.version_info[1]) -site_packages_prefix = 'lib/python' + major_minor + '/site-packages' -python_site = python_root + '/' + site_packages_prefix +# 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 match +# a predefined versioned installation prefix are added to the sys.path. To 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 = '{}.{}'.format(*sys.version_info) +site_packages_prefix = os.path.join( + 'lib', 'python' + major_minor, 'site-packages') +python_site = os.path.join(sys.prefix, site_packages_prefix) try: - all_sites_raw = os.environ['GUIX_PYTHONPATH'].split(':') + all_sites_raw = os.environ['GUIX_PYTHONPATH'].split(os.path.pathsep) except KeyError: all_sites_raw = [] # Normalize paths, otherwise a trailing slash would cause it to not match. @@ -35,7 +48,8 @@ matching_sites = [p for p in all_sites_norm if p.endswith(site_packages_prefix)] # Insert sites matching the current version into sys.path, right before -# Python's own site. +# Python's own site. This way, the user can override the libraries provided +# by Python itself. sys_path_absolute = [os.path.realpath(p) for p in sys.path] index = sys_path_absolute.index(python_site) -sys.path = sys.path[:index] + matching_sites + sys.path[index:] +sys.path[index:index] = matching_sites -- 2.32.0 --=-=-=--