all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#64573] [PATCH 0/3] guix: build: python-build-system: Have applications by default ignore non-Guix libraries in user site dir
@ 2023-07-11 18:12 Wojtek Kosior via Guix-patches via
  2023-07-11 18:14 ` [bug#64573] [PATCH 1/3] guix: build: python-build-system: Don't process " Wojtek Kosior via Guix-patches via
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Wojtek Kosior via Guix-patches via @ 2023-07-11 18:12 UTC (permalink / raw)
  To: 64573; +Cc: Wojtek Kosior, Lars-Dominik Braun, jgart

Python applications used to prioritize loading their libraries from so-called
"user site dir" (usually in ~/.local/lib/python<VERSION>/site-packages). The
libraries would only be loaded from /gnu/store when not found in the user site
dir. This used to cause hard-to-diagnose bugs like [1] when a user happened to
have a similar but incompatible version of a library installed via pip.

These patches modify the python-build-system's procedure responsible for
wrapping executables. The modified proc defines a PYTHONNOUSERSITE variable
which makes Python applications disregard the user site dir when loading
libraries.

While this solution does harden most Python applications, it can also break a
few ones like pip that operate on the user site dir itself. To work around
that, the second patch introduces a change to pip to allow installing to the
user site directory even when PYTHONNOUSERSITE is set by the Guix-created
wrapper script.

The third patch adds a boolean argument called disable-user-site? to
python-build-system. Packagers can set this argument to #f on per-package
basis to disable the hardening behavior in case it breaks some
application. Note that in the long run, it might be beneficial (although more
time-consuming) to leave disable-user-site? as #t everywhere and instead
modify the problematic applications — as done here with python-pip. It might
even be practical to only merge the first 2 patches from this series.

Please note that virtualenvs and packages that operate on them are likely
unaffected by this change. The initial bug doesn't even occur with
virtualenvs.


I tested the changes with

    ./pre-inst-env guix shell -C --network --no-cwd python-xmldiff coreutils python-pip
    pip install xmldiff==2.4
    echo > ~/.local/lib/python3.10/site-packages/xmldiff/main.py
    xmldiff --help

Without any patches, the 4th line fails. With the patches applied, the 4th
line succeeds and prints xmldiff's usage info


[1] https://issues.guix.gnu.org/63912


Wojtek Kosior (3):
  guix: build: python-build-system: Don't process user site dir
  gnu: python-pip: Enable user site even with PYTHONNOUSERSITE
  guix: build: python-build-system: Honor disable-user-site? argument

 gnu/packages/python-build.scm      | 10 +++++++++-
 guix/build-system/python.scm       |  2 ++
 guix/build/python-build-system.scm | 27 ++++++++++++++++++---------
 3 files changed, 29 insertions(+), 10 deletions(-)


base-commit: 67e22584faaa558c2a5834a5013d77660ec45e85
-- 
2.40.1





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

end of thread, other threads:[~2023-07-26  9:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11 18:12 [bug#64573] [PATCH 0/3] guix: build: python-build-system: Have applications by default ignore non-Guix libraries in user site dir Wojtek Kosior via Guix-patches via
2023-07-11 18:14 ` [bug#64573] [PATCH 1/3] guix: build: python-build-system: Don't process " Wojtek Kosior via Guix-patches via
2023-07-11 18:14 ` [bug#64573] [PATCH 2/3] gnu: python-pip: Enable user site even with PYTHONNOUSERSITE Wojtek Kosior via Guix-patches via
2023-07-11 18:14 ` [bug#64573] [PATCH 3/3] guix: build: python-build-system: Honor disable-user-site? argument Wojtek Kosior via Guix-patches via
2023-07-16  8:55 ` [bug#64573] [PATCH 0/3] guix: build: python-build-system: Have applications by default ignore non-Guix libraries in user site dir Lars-Dominik Braun
2023-07-17 14:23   ` Wojtek Kosior via Guix-patches via
2023-07-18  9:41     ` Lars-Dominik Braun
2023-07-18 12:55       ` Wojtek Kosior via Guix-patches via
2023-07-22  0:30 ` 宋文武 via Guix-patches via
2023-07-26  9:14   ` bug#64573: " Wojtek Kosior via Guix-patches via

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.