From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: Down with PYTHONPATH! Date: Sat, 15 Jun 2019 16:50:30 +0200 Message-ID: <87wohmq4w9.fsf@elephly.net> References: <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]:54496) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcA0v-0003FP-0H for guix-devel@gnu.org; Sat, 15 Jun 2019 10:50:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcA0t-0005yr-Ov for guix-devel@gnu.org; Sat, 15 Jun 2019 10:50:40 -0400 Received: from sender-of-o51.zoho.com ([135.84.80.216]:21277) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hcA0s-0005kc-9P for guix-devel@gnu.org; Sat, 15 Jun 2019 10:50:39 -0400 In-reply-to: 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: Hartmut Goebel Cc: guix-devel@gnu.org Hi Hartmut, >> 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. > > I have a *strong* opinion against this, as this would just replace one > cludge by another one. See below for rational. > > IMO the only sustainable solution it to patch the interpreter > (Modules/getpath.c) to determine the correct "installation path" > (profile). I did quite some work on this last year, but had no time to > finish it. I still have no time for finishing, but I should be able to > hand-over my results (including prepared patches for Python 3.7). This seems like a much bigger change that would require extensive testing as it aims to get rid of the wrappers as well. I welcome a solution that allows us to ditch the wrappers, but I=E2=80=99d like to fix = this large set of our Python problems soon. GUIX_PYTHON2PATH / GUIX_PYTHON3PATH is as solution that=E2=80=99s really ju= st a variant of what we=E2=80=99ve been doing all along (with PYTHONPATH), and i= t has precedent in GUIX_LOCPATH, GUIX_GTK2_IM_MODULE_FILE, and GUIX_GTK3_IM_MODULE_FILE. It=E2=80=99s a simple solution and removing it l= ater when a better solution comes along has virtually no costs. > Rational for GUIX_PYTHONPATH being a cludge (IMHO) Of course it isn=E2=80=99t pretty. But introducing it will remove a very r= eal problem we have. Installing a package via Guix should not affect other software that may be available on the system. Setting PYTHONPATH (to tell the Guix Python where to find modules the user has installed) unexpectedly violates this assumption. GUIX_PYTHONPATH (like GUIX_LOCPATH, GUIX_GTK2_IM_MODULE_FILE and GUIX_GTK3_IM_MODULE_FILE before it) has the potential to fix this with relatively little effort. > - Constraint: We must keep the expected behavior of PYTHONPATH as > documented for CPython. This esp. means, we must not simply substitute > in the source PYTHON_PATH by GUIX_PYTHONPATH, but need to *add* code. > > - When implementing GUIX_PYTHONPATH in site.py or site-cutomize.py, it > will fail if python is run using -S (disable the import of the module > site, and thus site-customize). I would not implement it there but do it in CPython, copying whatever code there is for PYTHONPATH and adapt it for GUIX_PYTHONPATH. > - When implementing GUIX_PYTHONPATH in getpath.c, we need to copy the > current code for PYTHONPATH, which means we will end up with a not so > short patch. And even then, this special care needs to be taken to not > leak GUIX_PYTHONPATH from one profile to the other. > > - We still need a wrapper (which caused a lot of problems, we already > solve. But maybe other problem will arise). This is a separate problem and it is not a new problem introduced by GUIX_PYTHONPATH. We have already simplified the use of wrappers for scripting languages on core-updates (using a polyglottal Guile wrapper). -- Ricardo