all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Wojtek Kosior <koszko@koszko.org>
Cc: 宋文武 <iyzsong@envs.net>,
	edk@beaver-labs.com, guix-devel <guix-devel@gnu.org>
Subject: Re: Guix's python has pip's user dir in its loadpath
Date: Sat, 01 Jul 2023 11:57:09 -0400	[thread overview]
Message-ID: <871qhr1v6y.fsf@gmail.com> (raw)
In-Reply-To: <20230701133257.6ada1e94.koszko@koszko.org> (Wojtek Kosior's message of "Sat, 1 Jul 2023 13:32:57 +0200")

Hi,

Wojtek Kosior <koszko@koszko.org> writes:

> The precedence of local, pip-installed Python libraries over Guix ones
> has already been a source of bugs. And these can be hard to diagnose.

> I imagine an optimal solution would be to configure this behavior on
> per-package basis. The vast majority of applications does not need to
> load local libraries. There are just a few exceptions like
> `python-virtualenv`.
>
> Once I did write a package definition that deliberately disabled user
> site dir package loading. I used code similar to what's below.
>
>> (modify-phases %standard-phases
>>   (add-after 'wrap 'prevent-local-package-interference
>>     (lambda* (#:key outputs #:allow-other-keys)
>>       (substitute* (string-append (assoc-ref outputs "out")
>>                                   "/bin/<program-name>")
>>         (("^#!/.*$" shabang)
>>          (string-append shabang
>>                         "export PYTHONNOUSERSITE=1\n"))))))

That is indeed a simple thing we could do to harden Python binaries from
picking up user pip-installed dependencies potentially causing
problems.  I would welcome such a patch.

> Of course, it makes no sense to add such snippet to all definitions.
> Instead, we could modify python-build-system to allow doing a similar
> thing based on a flag passed in package's `(arguments)`.

I think it need not be made configurable but just applied
indiscriminately to the wrap phase used in the python-build-system.

-- 
Thanks,
Maxim


  reply	other threads:[~2023-07-01 15:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14  6:42 Guix's python has pip's user dir in its loadpath edk
2023-06-29 10:22 ` 宋文武
2023-07-01  3:13   ` Maxim Cournoyer
2023-07-01 11:32     ` Wojtek Kosior via Development of GNU Guix and the GNU System distribution.
2023-07-01 15:57       ` Maxim Cournoyer [this message]
2023-07-05 20:29         ` John Kehayias
2023-07-06 15:35           ` Maxim Cournoyer
2023-07-06 21:28             ` Wojtek Kosior via Development of GNU Guix and the GNU System distribution.
2023-07-07 13:32               ` Maxim Cournoyer
2023-07-07 14:44                 ` Wojtek Kosior via Development of GNU Guix and the GNU System distribution.
2023-07-08  5:08                   ` Maxim Cournoyer
2023-07-11 18:21                     ` Wojtek Kosior via Development of GNU Guix and the GNU System distribution.

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=871qhr1v6y.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=edk@beaver-labs.com \
    --cc=guix-devel@gnu.org \
    --cc=iyzsong@envs.net \
    --cc=koszko@koszko.org \
    /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.