guix-commits
[Top][All Lists]
Advanced

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

06/104: guix: python-build-system: Add helpers for getting and setting P


From: Hartmut Goebel
Subject: 06/104: guix: python-build-system: Add helpers for getting and setting PYTHONPATH.
Date: Tue, 15 Nov 2016 21:36:58 +0000 (UTC)

htgoebel pushed a commit to branch python-build-system
in repository guix.

commit a2ff4f0240f0fac484836bb8ffb2f86917369666
Author: Hartmut Goebel <address@hidden>
Date:   Sat Oct 8 12:04:20 2016 +0200

    guix: python-build-system: Add helpers for getting and setting PYTHONPATH.
    
    * guix/build/python-build-system.scm (add-installed-pythonpath,
      site-packages): New exported procedures.
---
 guix/build/python-build-system.scm |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/guix/build/python-build-system.scm 
b/guix/build/python-build-system.scm
index 7ccc938..22c4f7d 100644
--- a/guix/build/python-build-system.scm
+++ b/guix/build/python-build-system.scm
@@ -28,6 +28,8 @@
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
   #:export (%standard-phases
+            add-installed-pythonpath
+            site-packages
             python-build))
 
 ;; Commentary:
@@ -76,6 +78,24 @@
          (major+minor (take components 2)))
     (string-join major+minor ".")))
 
+(define (site-packages inputs outputs)
+  "Return the path of the current output's Python site-package."
+  (let* ((out (assoc-ref outputs "out"))
+         (python (assoc-ref inputs "python")))
+    (string-append out "/lib/python"
+                   (get-python-version python)
+                   "/site-packages/")))
+
+(define (add-installed-pythonpath inputs outputs)
+  "Prepend the Python site-package of OUTPUT to PYTHONPATH.  This is useful
+when running checks after installing the package."
+  (let ((old-path (getenv "PYTHONPATH"))
+        (add-path (site-packages inputs outputs)))
+    (setenv "PYTHONPATH"
+            (string-append add-path
+                           (if old-path (string-append ":" old-path) "")))
+    #t))
+
 (define* (install #:key outputs (configure-flags '()) use-setuptools?
                   #:allow-other-keys)
   "Install a given Python package."



reply via email to

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