From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pjotr Prins Subject: Re: Down with PYTHONPATH! Date: Mon, 17 Jun 2019 10:48:52 -0500 Message-ID: <20190617154852.wjq42ywbsjyiobio@thebird.nl> References: <87muikr3bq.fsf@mdc-berlin.de> <87ef3s37nq.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:43032) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hcu1k-00024p-Gf for guix-devel@gnu.org; Mon, 17 Jun 2019 11:58:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hcu1h-0003Dx-Nx for guix-devel@gnu.org; Mon, 17 Jun 2019 11:58:35 -0400 Content-Disposition: inline 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: Konrad Hinsen Cc: guix-devel@gnu.org, Ricardo Wurmus On Mon, Jun 17, 2019 at 12:20:12PM +0200, Konrad Hinsen wrote: > Hi Ludo, > > > How does virtualenv work, if not by setting PYTHONPATH? > > It creates a new filetree corresponding to a complete new Python > installation, and the uses soft links to share most of the actual files > with the parent installation. Exactly, Python is 'aware' of certain default paths. Virtualenv uses that. > > Setting up an environment all about augmenting the search path, so I > > naively thought that virtualenv sets PYTHONPATH or the corresponding > > Python variable. > > PYTHONPATH only adds directories to the search path. The standard > library and packages installed via pip are already on the search path > before PYTHONPATH is looked at. So virtualenv could not work by > modifying PYTHONPATH. PYTHONPATH's main use is to override the search path for modules. Guix using this is a recipe for trouble because users will always want to set it for their own purposes (I do the same for the genenetwork stack) and you get the question of precedence and versioning - I solve it by creating a module library that makes use of a Guix hash so it is tied to one interpreter. We should always allow people to override PYTHONPATH. For Guix it would actually make sense to make the interpreter Guix aware. Since we don't abide by the default paths I think it takes very much approach similar to overriding RPATH to solve this satisfactory. That does imply patching the interpreter. All interpreters, including Ruby and Perl. A special environment variable may work too. It would be interesting to see how others solve this problem. Including Nix and Conda. Pj.