From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Down with PYTHONPATH! Date: Fri, 14 Jun 2019 10:14:33 +0200 Message-ID: <87muikr3bq.fsf@mdc-berlin.de> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51416) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbhMW-0002gc-CF for guix-devel@gnu.org; Fri, 14 Jun 2019 04:15:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbhMU-0007zo-9Q for guix-devel@gnu.org; Fri, 14 Jun 2019 04:15:04 -0400 Received: from a2062.mx.srv.dfn.de ([194.95.232.172]:33499) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbhMQ-0007fh-7w for guix-devel@gnu.org; Fri, 14 Jun 2019 04:15:00 -0400 Received: from localhost (localhost [127.0.0.1]) by a2062.mx.srv.dfn.de (Postfix) with ESMTP id 2CBB0A003C for ; Fri, 14 Jun 2019 10:14:36 +0200 (CEST) Received: from a2062.mx.srv.dfn.de ([127.0.0.1]) by localhost (mgw4-han.srv.dfn.de [127.0.0.1]) (amavisd-new, port 20134) with ESMTP id GaGULz92SQW6 for ; Fri, 14 Jun 2019 10:14:35 +0200 (CEST) Received: from SW-IT-P-CAS3.mdc-berlin.net (mgw10-3.mdc-berlin.de [141.80.113.58]) by a2062.mx.srv.dfn.de (Postfix) with ESMTPS for ; Fri, 14 Jun 2019 10:14:35 +0200 (CEST) List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org Hi Guix, here=E2=80=99s a half-baked idea that I think is worth considering: let=E2= =80=99s patch our Python package to respect GUIX_PYTHONPATH and use GUIX_PYTHONPATH in our wrappers. PYTHONPATH is dangerously inadequate for use in a wrapper. Consider the case where a user has Numpy installed with Guix but also uses some unrelated application that happens to have been installed to ~/.local/bin via pip. Since numpy is part of the manifest Guix will helpfully record a value for PYTHONPATH in etc/profile. It=E2=80=99s very likely that users rely on etc/profile magic to set all needed environment variables, so PYTHONPATH will likely be set to a location that makes sense for Python applications in Guix. The user now runs ~/.local/bin/myapp and the thing crashes because the system Python will to load up Numpy from Guix, which is incompatible. The system Python may even be Python 2.7. PYTHONPATH is the wrong mechanism for Guix to use. We have previously discussed this and Hartmut Goebel analyzed the situation for us in the past (see the thread containing the message with ID ). Unfortunately, we couldn=E2=80=99t decide on a good way forward. So I propose to avoid using PYTHONPATH, which is similarly dangerous as LD_LIBRARY_PATH in that it causes incompatible libraries to be loaded. Switching to GUIX_PYTHONPATH is not going to be a complete solution (because it doesn=E2=80=99t distinguish between different versions of Pytho= n), but at the very least it will separate Python applications that use Guix from Python applications that don=E2=80=99t. Right now this is not the cas= e and people who use Guix for some things but not for others have a really bad time and learn to avoid Guix because it sets PYTHONPATH, which breaks their other applications. If we=E2=80=99re feeling lucky we could even introduce GUIX_PYTHON2_PATH and GUIX_PYTHON3_PATH to solve the other half of the problem, namely that Python 2 applications will load Python 3 libraries (and vice versa). What do you think? -- Ricardo