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.
This commit is contained in:
Hartmut Goebel 2016-10-08 12:04:20 +02:00
parent 5f7565d190
commit a2ff4f0240
No known key found for this signature in database
GPG Key ID: 634A8DFFD3F631DF
1 changed files with 20 additions and 0 deletions

View File

@ -28,6 +28,8 @@
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26) #:use-module (srfi srfi-26)
#:export (%standard-phases #:export (%standard-phases
add-installed-pythonpath
site-packages
python-build)) python-build))
;; Commentary: ;; Commentary:
@ -76,6 +78,24 @@
(major+minor (take components 2))) (major+minor (take components 2)))
(string-join major+minor "."))) (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? (define* (install #:key outputs (configure-flags '()) use-setuptools?
#:allow-other-keys) #:allow-other-keys)
"Install a given Python package." "Install a given Python package."