all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Down with PYTHONPATH!
@ 2019-06-14  8:14 Ricardo Wurmus
  2019-06-14 10:12 ` ng0
                   ` (4 more replies)
  0 siblings, 5 replies; 19+ messages in thread
From: Ricardo Wurmus @ 2019-06-14  8:14 UTC (permalink / raw)
  To: guix-devel

Hi Guix,

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.

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’s 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
<ad6b1473-2732-ca7b-d971-e548c39013f6@crazy-compilers.com>).
Unfortunately, we couldn’t 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’t distinguish between different versions of Python),
but at the very least it will separate Python applications that use Guix
from Python applications that don’t.  Right now this is not the case 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’re 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

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2019-07-18  8:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.