From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id d4nTDahOrWQHMQAASxT56A (envelope-from ) for ; Tue, 11 Jul 2023 14:44:24 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id iHBqC6hOrWSTDgEAG6o9tA (envelope-from ) for ; Tue, 11 Jul 2023 14:44:24 +0200 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 AA25D483AD for ; Tue, 11 Jul 2023 14:44:23 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=LuMcV6p9; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1689079464; 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: 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=555hGQKGv0x6vR1snxwSSI21BJ662zzl470qKSqoBco=; b=KL6q5vxi9QUYJVbVU0wn1cUTN41tdDq9lmUHDZKckQWHYbyQ9l0/QJbmKcrJdeWopbmokc BWTGmyRnutv7/sBq1sAEUbhPX+aQYgEceD7OFc1BRbxIaqMebfI7gV8RDKIID9JxsEFGY8 DH3XqOq+h7Urk574x4qG3r6bLYbT6A2oXEEgQ3rGRB5ETXrvhb2+rTi2dD6wGTVfen3Rmo Y7dgZHqdrmVUIlH/FZNt2yPtvT4z0opfyycAuOJojKMHz6du3P/hv7gqg+OhNp68Rvt1Bc NbU5QsseLEFNF6xeh9smw46qwSp5rGG6s9sSMEgHx3TDLCDPxgY8tmZN0WB7MQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=6xq.net header.s=MBO0001 header.b=LuMcV6p9; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=6xq.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1689079464; a=rsa-sha256; cv=none; b=ktgbiJT1HisV7JDlVUxqb1Mg4qAeyPYur2LA69RKDUZ6ByBCHEB8UNVVY6JT7qmrtHXuK/ 6AEQ8gN08qarf2M2Vr4dgXqrDkLCg+Nlf0aIyWheTiXGLrkrk+1VoIc5xfIWh9rp6CTfJ0 mWNmdi/J7aAzuOvuLn7LWtVVJnl3zyyuFlPIusiTfqCTGssVoqjVdlGH8YXMcu4aALMG0g MjKzSv3gRzWCcN51uj2h2FopKv8kZzO42TKEHFJSIsj9bKZgFrKWLEiHyVhRvAXJPP+cH3 SXrVdIkidWkrtAnduEJrKAlbRz6LJih9gyb+vXPn55bFuExXi9NrU+nHx9njig== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qJCit-00053x-NO; Tue, 11 Jul 2023 08:44:07 -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 1qJCiq-00053b-Dv for bug-guix@gnu.org; Tue, 11 Jul 2023 08:44:04 -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 1qJCip-0004dr-Bg for bug-guix@gnu.org; Tue, 11 Jul 2023 08:44:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qJCin-00014u-Ni for bug-guix@gnu.org; Tue, 11 Jul 2023 08:44:01 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#64309: Python dlopen()s musl libc Resent-From: Lars-Dominik Braun Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 11 Jul 2023 12:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64309 X-GNU-PR-Package: guix X-GNU-PR-Keywords: moreinfo To: Josselin Poiret Cc: jgart@dismail.de, Ludovic =?UTF-8?Q?Court=C3=A8s?= , Athena Martin , 64309@debbugs.gnu.org Received: via spool by 64309-submit@debbugs.gnu.org id=B64309.16890794344123 (code B ref 64309); Tue, 11 Jul 2023 12:44:01 +0000 Received: (at 64309) by debbugs.gnu.org; 11 Jul 2023 12:43:54 +0000 Received: from localhost ([127.0.0.1]:49925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJCig-00014R-9Q for submit@debbugs.gnu.org; Tue, 11 Jul 2023 08:43:54 -0400 Received: from mout-p-201.mailbox.org ([80.241.56.171]:52976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qJCib-00014B-8w for 64309@debbugs.gnu.org; Tue, 11 Jul 2023 08:43:53 -0400 Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4R0gXY5QtYz9sSt; Tue, 11 Jul 2023 14:43:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6xq.net; s=MBO0001; t=1689079421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=555hGQKGv0x6vR1snxwSSI21BJ662zzl470qKSqoBco=; b=LuMcV6p9M+xFUbUsYYTueZdQ1+v20FqcXanUEWZLGKnI92a+hyWvbCGQ7Flj43s2FMPchC d6AgXhXezcSG+dJ7oz2df1fZy/94Sh1/PYWUjkGS1n0g9DZcGHrSgV47YDct5LFMPVasgh z/yX8Yxsac6uNI3MjPDlwmwHQRjloFPfnTi8MtD3dG58HDX8wpBuJPB5fSmdb034ju5nQ2 uV6lHTh2VXUMFpMVzw7SUX7wz1P6BEKrz2uSv/POJX0pd3hO14GCQVo2ak5ehvMU8Jqz6F kMQ/vdQSBcSJ9tHS/ocFZ4HnvM921gZO+G1U4NsWtsmVCBnuD67pyGUq+Dwh9w== Date: Tue, 11 Jul 2023 14:43:36 +0200 From: Lars-Dominik Braun Message-ID: References: <20230626204230.7b3b773a@spock.hosts.alm.website> <87mt07kej7.fsf@gnu.org> <20230708161658.25be509c@spock.hosts.alm.website> <87v8et8oug.fsf@jpoiret.xyz> <20230709162221.39fb0e66@spock.hosts.alm.website> <87pm508cir.fsf@jpoiret.xyz> <20230710154734.2b71b56b@spock.hosts.alm.website> <87jzv6979d.fsf@jpoiret.xyz> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="R+CcsZ76ztTp1UKo" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87jzv6979d.fsf@jpoiret.xyz> 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: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: AA25D483AD X-Migadu-Spam-Score: -5.30 X-Migadu-Scanner: mx0.migadu.com X-Spam-Score: -5.30 X-TUID: rzNr3SjDAOBB --R+CcsZ76ztTp1UKo Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, there’s a similar issue #63912 and a thread on the guix-devel mailinglist at https://lists.gnu.org/archive/html/guix-devel/2023-06/msg00066.html > So, looks like the default Python behavior is to load the usercustomize > after the sitecustomize [1], which leads to exactly the behavior you're > experiencing. I don't know what we should do here, maybe pass `-s` to > the shebang line of Python to disable loading the usercustomize? That > would probably be a world-rebuild though. CC'ing the Python team to see > what they think. I think the problem is bigger than usercustomize. Any custom PYTHONPATH also slips through and causes this issue, as well as any custom GUIX_PYTHONPATH, because the executable wrapper appends it (think nested `guix shell` invokations with different versions of a library for an example where this could go wrong). Guix-managed Python packages (libraries nor applications) should generally not pick up dependencies from random paths – only those from their package description, so we can keep Guix’ promise of being self-contained. I have experimented with customizing Python’s importing mechanism through a custom MetaPathFinder. It works by adding a __guix_pythonpath__ variable to every Python package’s __init__.py file and modifying the module loader’s search path accordingly if such a variable exists. It would provide exactly that guarantee, but it’s just a PoC at this point – see attached file. Apart from that I don’t see a good short-term solution right now. It’s just how Python works. Cheers, Lars --R+CcsZ76ztTp1UKo Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="mysitecustomize.py" Content-Transfer-Encoding: 8bit # Credits to # https://tenthousandmeters.com/blog/python-behind-the-scenes-11-how-the-python-import-system-works/ # for the very good explanation of how Python’s import statement works. import sys, os from importlib.abc import MetaPathFinder from importlib.machinery import SourceFileLoader, ModuleSpec, PathFinder class GuixPythonFinder (MetaPathFinder): def find_spec (self, fullname, path, target=None): # Short-circuit for non-top-level imports, which already have a path. if path: return None attrname = '__guix_pythonpath__' searchPath = None # Search for our caller. frame = sys._getframe () while frame: # If he has a search path, use it. This is mainly for executable # scripts with `__name__ == '__main__'`. searchPath = frame.f_globals.get (attrname, None) if not searchPath: # Otherwise check the top-level package for search paths # declared in __init__.py package = frame.f_globals.get ('__package__') if package: module = sys.modules.get (package) if module: searchPath = getattr (module, attrname, None) if searchPath is not None: break frame = frame.f_back # If we have a caller… if searchPath is not None: return PathFinder.find_spec (fullname, searchPath, target=target) else: # Otherwise we’re not responsible for this module. return None sys.meta_path.insert (0, GuixPythonFinder ()) --R+CcsZ76ztTp1UKo--