guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

01/03: guix: build: python-build-system: Don't process user site dir


From: guix-commits
Subject: 01/03: guix: build: python-build-system: Don't process user site dir
Date: Tue, 18 Jul 2023 05:38:49 -0400 (EDT)

rekado pushed a commit to branch python-team
in repository guix.

commit b242efa9c8b7b7a061a52a205b030a72fde120d8
Author: Wojtek Kosior <koszko@koszko.org>
AuthorDate: Tue Jul 11 20:14:38 2023 +0200

    guix: build: python-build-system: Don't process user site dir
    
    * guix/build/python-build-system.scm (wrap): Define PYTHONNOUSERSITE for
    programs so they don't incorrectly pick up local, pip-installed libraries.
---
 guix/build/python-build-system.scm | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/guix/build/python-build-system.scm 
b/guix/build/python-build-system.scm
index aa04664b25..93aafc4aa9 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -241,12 +241,16 @@ running checks after installing the package."
   (define %sh (delay (search-input-file inputs "bin/bash")))
   (define (sh) (force %sh))
 
-  (let* ((var `("GUIX_PYTHONPATH" prefix
-                ,(search-path-as-string->list
-                  (or (getenv "GUIX_PYTHONPATH") "")))))
+  (let* ((var-pythonpath `("GUIX_PYTHONPATH" prefix
+                           ,(search-path-as-string->list
+                             (or (getenv "GUIX_PYTHONPATH") ""))))
+         ;; Harden applications by preventing Python from automatically
+         ;; picking up libraries in user site directory.
+         (var-usersite '("PYTHONNOUSERSITE" = ("GUIX_WRAPPER"))))
     (for-each (lambda (dir)
                 (let ((files (list-of-files dir)))
-                  (for-each (cut wrap-program <> #:sh (sh) var)
+                  (for-each (cut wrap-program <> #:sh (sh)
+                                 var-pythonpath var-usersite)
                             files)))
               bindirs)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]