From: Ricardo Wurmus <rekado@elephly.net>
To: Pjotr Prins <pjotr.public12@thebird.nl>
Cc: guix-devel@gnu.org, Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Subject: Re: PYTHONPATH woes
Date: Tue, 20 Feb 2018 16:30:48 +0100 [thread overview]
Message-ID: <87tvubr847.fsf@elephly.net> (raw)
In-Reply-To: <20180220150135.GA20101@thebird.nl>
Hi Pjotr,
> On Tue, Feb 20, 2018 at 11:53:54AM +0100, Ricardo Wurmus wrote:
>> Would it be good to make the wrappers for Python scripts stricter and
>> not accept any user-set PYTHONPATH?
>
> I think that is a bad idea. You need to be able to opt out. Also
> people need to experiment with modules without understanding Guix per
> se. In my upcomping blog I would emphasize packaging at the point you
> become a serious user.
>
> That should come with a health warning ;). Similarly we should allow
> for LD_LIBRARY_PATH etc. It is what they exist for, even if it is
> dangerous.
While I agree that it must be *possible* to opt out, I think the
defaults are wrong here. We don’t ever set LD_LIBRARY_PATH when
building a profile, but we do set PYTHONPATH. Having PYTHONPATH set
(even without the knowledge of the user) leads to problems here when it
shouldn’t.
I’d argue that the number of users who need to be able to override
individual Python packages for a tool like Ribodiff is way lower than
the number of those who accidentally get into a situation where
PYTHONPATH is set purely because of the contents of their profile,
leading to breakage of unrelated packages that just happen to use Python
modules.
>> How do we approach the problem of having both Python 2 modules and
>> Python 3 modules in the same profile? PYTHONPATH will be set to refer
>> to the site-packages directories of both versions, which is never good.
>> Does Python offer us a way to do better? Can we make use of pth files
>> to get around this problem somehow?
>
> Python should have created PYTHONPATH2 to split them out. We could
> patch python2 to do just that.
I think there’s an alternative, but I don’t know it well. The official
way is to use “.pth” files instead of setting PYTHONPATH. Maybe there’s
a way that doesn’t involve setting PYTHONPATH. Instead we could nudge
Python towards reading the profile’s “.pth” file and read the package
locations from there.
This would require a new profile hook and possibly a patch to Python to
add a way to tell it to read the “.pth” file from a location provided by
a Guix environment variable.
> Even so, the real solution is separate profiles. I get that with
> versions of Ruby too.
Right, but it is not obvious what packages must be treated with extra
care. When I install the Ribodiff package I don’t know or care that
it’s written in Python. That shouldn’t matter at all. But now I
actually have to pay attention to this and install Ribodiff in a profile
that doesn’t contain Python 3 things.
That’s rather complicated and unfriendly for users. I don’t want the
users here to be anxious about installing software, just because a new
tool may be using Python and thus might break when installed to a
profile containing Python things. We made these wrappers precisely to
isolate the tools from the current environment. Allowing them to be
disturbed so easily is making wrappers much less useful.
--
Ricardo
GPG: BCA6 89B6 3655 3801 C3C6 2150 197A 5888 235F ACAC
https://elephly.net
next prev parent reply other threads:[~2018-02-20 15:31 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-20 10:53 PYTHONPATH woes Ricardo Wurmus
2018-02-20 15:01 ` Pjotr Prins
2018-02-20 15:18 ` Andy Wingo
2018-02-20 16:40 ` Pjotr Prins
2018-02-20 15:30 ` Ricardo Wurmus [this message]
2018-02-21 21:58 ` Hartmut Goebel
2018-02-22 15:30 ` Ricardo Wurmus
2018-02-22 18:35 ` Hartmut Goebel
2018-02-22 20:42 ` Hartmut Goebel
2018-02-23 8:45 ` Vincent Legoll
2018-02-23 12:36 ` Hartmut Goebel
2018-02-23 16:59 ` Pjotr Prins
2018-02-23 19:36 ` Ricardo Wurmus
2018-02-23 23:54 ` Pjotr Prins
2018-02-24 10:44 ` Hartmut Goebel
2018-02-24 10:49 ` Hartmut Goebel
2018-02-27 11:43 ` PYTHONPATH issue analysis - part 1 (was: PYTHONPATH woes) Hartmut Goebel
2018-03-13 21:54 ` PYTHONPATH issue analysis - part 1 Hartmut Goebel
2018-02-27 11:49 ` PYTHONPATH issue analysis - part 2 (was: PYTHONPATH woes) Hartmut Goebel
2018-03-11 21:47 ` PYTHONPATH issue analysis - part 3 " Hartmut Goebel
2018-03-13 21:23 ` PYTHONPATH issue analysis - part 3 Ludovic Courtès
2018-03-13 21:44 ` Pjotr Prins
2018-03-13 22:02 ` Hartmut Goebel
2018-03-14 7:49 ` Pjotr Prins
2018-03-14 9:04 ` Hartmut Goebel
2018-03-14 18:21 ` Pjotr Prins
2018-03-15 19:48 ` Hartmut Goebel
2018-03-13 21:47 ` Hartmut Goebel
2018-03-14 9:41 ` Ludovic Courtès
2018-03-13 21:51 ` Hartmut Goebel
2018-03-14 0:10 ` Ricardo Wurmus
2018-03-15 9:09 ` Ludovic Courtès
2018-03-15 19:30 ` PYTHONPATH issue explanation Hartmut Goebel
2018-03-17 1:41 ` 宋文武
2018-03-17 10:07 ` Ricardo Wurmus
2018-03-17 22:46 ` Hartmut Goebel
2018-03-17 22:53 ` Hartmut Goebel
2018-03-17 11:18 ` [PATCH] gnu: python: Honor 'GUIX_PYTHON_X_Y_SITE_PACKAGES' 宋文武
2018-03-17 21:53 ` Hartmut Goebel
2018-03-18 0:04 ` 宋文武
2018-03-18 0:07 ` 宋文武
2018-03-17 22:04 ` PYTHONPATH issue explanation Hartmut Goebel
2018-03-18 0:57 ` 宋文武
2018-03-18 10:05 ` 宋文武
2018-03-24 20:47 ` Chris Marusich
2018-04-16 14:21 ` PYTHONPATH - let's systematically tame the baest Hartmut Goebel
2018-04-17 1:47 ` 宋文武
2018-04-17 7:03 ` Hartmut Goebel
2018-04-18 8:34 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87tvubr847.fsf@elephly.net \
--to=rekado@elephly.net \
--cc=guix-devel@gnu.org \
--cc=pjotr.public12@thebird.nl \
--cc=ricardo.wurmus@mdc-berlin.de \
/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 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.