unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: Hartmut Goebel <h.goebel@crazy-compilers.com>
Cc: guix-devel@gnu.org
Subject: Re: Down with PYTHONPATH!
Date: Sat, 15 Jun 2019 16:50:30 +0200	[thread overview]
Message-ID: <87wohmq4w9.fsf@elephly.net> (raw)
In-Reply-To: <c4a496dd-7e4d-9173-a498-f8d3e3981a18@crazy-compilers.com>


Hi Hartmut,

>> here’s a half-baked idea that I think is worth considering: let’s 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’d like to fix this
large set of our Python problems soon.

GUIX_PYTHON2PATH / GUIX_PYTHON3PATH is as solution that’s really just a
variant of what we’ve been doing all along (with PYTHONPATH), and it has
precedent in GUIX_LOCPATH, GUIX_GTK2_IM_MODULE_FILE, and
GUIX_GTK3_IM_MODULE_FILE.  It’s a simple solution and removing it later
when a better solution comes along has virtually no costs.

> Rational for GUIX_PYTHONPATH being a cludge (IMHO)

Of course it isn’t pretty.  But introducing it will remove a very real
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

  reply	other threads:[~2019-06-15 14:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14  8:14 Down with PYTHONPATH! Ricardo Wurmus
2019-06-14 10:12 ` ng0
2019-06-14 21:29 ` Ludovic Courtès
2019-06-15  7:44   ` Ricardo Wurmus
2019-06-15  9:15 ` Konrad Hinsen
2019-06-17  9:03   ` Ludovic Courtès
2019-06-17 10:20     ` Konrad Hinsen
2019-06-17 15:48       ` Pjotr Prins
2019-06-18 15:46         ` Konrad Hinsen
2019-06-19 11:25           ` Hartmut Goebel
2019-06-17 12:17     ` Hartmut Goebel
2019-06-15 13:35 ` Hartmut Goebel
2019-06-15 14:50   ` Ricardo Wurmus [this message]
2019-06-17  9:11   ` Ludovic Courtès
2019-06-17 18:34     ` Ricardo Wurmus
2019-06-18  8:28       ` Hartmut Goebel
2019-07-06 10:45 ` Hartmut Goebel
2019-07-06 16:31   ` Pjotr Prins
2019-07-18  8:20   ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87wohmq4w9.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=guix-devel@gnu.org \
    --cc=h.goebel@crazy-compilers.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).