From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mKksAHxAMmGFOgEAgWs5BA (envelope-from ) for ; Fri, 03 Sep 2021 17:34:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WKB/N3tAMmGfbQAAB5/wlQ (envelope-from ) for ; Fri, 03 Sep 2021 15:34:19 +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 AE1EC24706 for ; Fri, 3 Sep 2021 17:34:19 +0200 (CEST) Received: from localhost ([::1]:59578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mMBCs-0000vs-P7 for larch@yhetil.org; Fri, 03 Sep 2021 11:34:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mMBAi-0005BC-Dy for guix-patches@gnu.org; Fri, 03 Sep 2021 11:32:08 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34225) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mMBAh-0005Ae-1S for guix-patches@gnu.org; Fri, 03 Sep 2021 11:32:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mMBAg-0007VF-Up for guix-patches@gnu.org; Fri, 03 Sep 2021 11:32:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50358] [PATCH core-updates-frozen 2/8] aux-files: sitecustomize: Cleanup and add explanatory comments. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 03 Sep 2021 15:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50358 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50358@debbugs.gnu.org Cc: Hartmut Goebel , Maxim Cournoyer , Mathieu Othacehe Received: via spool by 50358-submit@debbugs.gnu.org id=B50358.163068311028768 (code B ref 50358); Fri, 03 Sep 2021 15:32:02 +0000 Received: (at 50358) by debbugs.gnu.org; 3 Sep 2021 15:31:50 +0000 Received: from localhost ([127.0.0.1]:45758 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMBAU-0007Tw-37 for submit@debbugs.gnu.org; Fri, 03 Sep 2021 11:31:50 -0400 Received: from mail-qv1-f51.google.com ([209.85.219.51]:35593) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mMBAS-0007TX-GL for 50358@debbugs.gnu.org; Fri, 03 Sep 2021 11:31:49 -0400 Received: by mail-qv1-f51.google.com with SMTP id g11so3377291qvd.2 for <50358@debbugs.gnu.org>; Fri, 03 Sep 2021 08:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XLBpc16ec7gYQsrlLcrJVGe/1kPuf0sn09F+IgeHsH8=; b=JNCiFfyytNUeo07NOpSEfP0E1czhL5hZjt79nSS6GiYhJyU4cBjhj+NeF23BsgiDaj o1oZxAT2pzKxvH4kCs5ucGNk3oQUUa2dTPh3zmcDrBUZ03N9G4ZgsfORNBY9IgzfuGaZ VRFUxkctiYuMa6bZix8iI5hKnJR98QUpyA+5gfoX+ZUSTFPCbDWhymZAElH4U48v8BEq iCwagzF2hw5hVM2ctogrpIOTV6UzD2007E+t+bJqX7QTjB5xaOmcp6NVZzj9M/Xb1hFA pzglAn758oeZyZHMeg0BD2DPOKgsN3Fdqyn0+S5mFLBYOOf2YbA2IWSqpcuB8BAS3QTF c3yg== 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:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XLBpc16ec7gYQsrlLcrJVGe/1kPuf0sn09F+IgeHsH8=; b=W2sBESWnfRveyXhr67NGUqT/tb9AWvRE+ki/D8yI+r57H7XczxxoOhEkACBVxTh0Cg lrUS5jY8gVyGLqjGzRbLLVN6CqLUWJBK18zZ2sw+tLZqG3eEZIyjdIFmZ1oiwy9Mffie hSEc3J4SvIo2kgsPqDh2mda4KrTW5+EoW7nvU3VS4ub4H+obItquXG/RzXccpRmLZOfw 9qsuvpbQrDzHBHOt7X5aJzouPNvT5k2BWaXK5OIGD2Rcti9dkfrCOA+eAcPMON4GB9ah zfdVX+W0Xk65s9XbEctUzGURCo4QRT/UvYHjEb0LbjBXbjH45BtYfwrtvTg0goQxpVPX KxJg== X-Gm-Message-State: AOAM533A9/c1MBtklOhi5onhFwH6DeeLHDhOKShnbODiJ3jlYPy2ukWV G7SC+Np5dmrLkP7TcpWTVGEAvlXdcSA= X-Google-Smtp-Source: ABdhPJywVplPtkU09+jmOwCqvWMASqMuXdbKR/Y1VgSwkvovSlA6WmUz/LWTdjSoAxBC/3n+sW8MEQ== X-Received: by 2002:ad4:55ac:: with SMTP id f12mr4033089qvx.34.1630683102794; Fri, 03 Sep 2021 08:31:42 -0700 (PDT) Received: from localhost.localdomain ([207.35.94.150]) by smtp.gmail.com with ESMTPSA id b25sm3973128qka.23.2021.09.03.08.31.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Sep 2021 08:31:42 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 3 Sep 2021 11:31:10 -0400 Message-Id: <20210903153116.22517-2-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210903153116.22517-1-maxim.cournoyer@gmail.com> References: <20210903153116.22517-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630683259; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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=XLBpc16ec7gYQsrlLcrJVGe/1kPuf0sn09F+IgeHsH8=; b=VWN4QuNi5E1I9UlD2EWJJGJ2zMCmrPOU8PO+P9lLVEgnithFdjlVi7i1p9YJ2eHFsSLpAq cmgPmTo0FK+I/EbR6mFJ1vyLlDmugzoNrXwVMmyA5ofxy9Y4ipKUkTVMy+H/1MBdxbJLXH 8IzKFtIBAuku1z0PADcsSQVAL2XqteiF2/OEwitReFJ84rifTLhnbNSs3QcROuxCWfxGr8 R8r0tykKSUc3m7Gh9PyF67DFWs4FlQiNUxi34mrikqitDALReYd2hxVF8NoKvXtqoBk3oE QaX2XiHErmZK5hvUahLCMOMLgR58Fcrx/lOTQShpLzlBEtmvYP3COvmswdO2gg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630683259; a=rsa-sha256; cv=none; b=RV5JIuuhjMKnk60IbLOA/FOgfOUTB546WbOrHVScHEM9MIA1VuD9zcGJUjUD4uIGyK0fcN oje65ZlTyIssby370a86hukkw5BYKNRZjwa2UF2WFgXJgFZZqSOpGr9gWMeI4uFNCryWeO vd215QBYBA1V3/mtg14xYCZRStj4fBkQfXKt2KQBM3k1Mf0rGKNdneLpGK1xgNq4jxfiim 10CLrkbbYpgTFe6Rq+h5NiRBglpuz3XvscTxddJi18Hhsp88qXuVrPxPACAVugPDYgEv36 wcXMuUYSl9BZuwKhac6cVQkEd8LtArHOzRaXIpTE/GVz6c4bgBUCj0JcugrPfw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=JNCiFfyy; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Spam-Score: 4.18 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=JNCiFfyy; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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-Migadu-Queue-Id: AE1EC24706 X-Spam-Score: 4.18 X-Migadu-Scanner: scn1.migadu.com X-TUID: ZpcWyZRILt+5 Fixes . * gnu/packages/aux-files/python/sitecustomize.py: Add a comment explaining the general idea, and use sys.prefix instead of sys.executable. (major_minor): Use the unpacking operator (*) to provide the arguments. (site_packages_prefix): Use os.path.join to form the path. (python_site): Likewise. Use sys.prefix instead of sys.executable. (all_sites_raw): Split on os.path.pathsep. (sys.path): Directly splice the result in the list. Suggested-by: Hartmut Goebel Reported-by: Mathieu Othacehe Signed-off-by: Maxim Cournoyer --- .../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.33.0