build-system/python: Export 'python-version'.

* guix/build/python-build-system.scm (get-python-version): Rename to...
(python-version): ... this.  Update callers.  Make public.
* gnu/packages/gstreamer.scm (python-gst)[arguments]: Adjust accordingly.
* gnu/packages/machine-learning.scm (ghmm)[arguments]: Likewise.
* gnu/packages/openldap.scm (389-ds-base)[arguments]: Import (guix
build python-build-system).  Use 'python-version'.
* gnu/packages/package-management.scm (conda)[arguments]: Use
'python-version'.
This commit is contained in:
Ludovic Courtès 2019-06-21 18:11:25 +02:00
parent 1dcca83afb
commit 9c2563a80b
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
5 changed files with 14 additions and 20 deletions

View file

@ -447,9 +447,7 @@ (define-public python-gst
(guix build python-build-system)) (guix build python-build-system))
#:configure-flags #:configure-flags
(let* ((python (assoc-ref %build-inputs "python")) (let* ((python (assoc-ref %build-inputs "python"))
(python-version ((@@ (guix build python-build-system) (python-version (python-version python))
get-python-version)
python))
(python-sitedir (string-append (python-sitedir (string-append
"lib/python" python-version "/site-packages"))) "lib/python" python-version "/site-packages")))
(list (string-append (list (string-append

View file

@ -210,8 +210,7 @@ (define-public ghmm
(assoc-ref %standard-phases 'check)) (assoc-ref %standard-phases 'check))
(add-before 'check 'fix-PYTHONPATH (add-before 'check 'fix-PYTHONPATH
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let ((python-version ((@@ (guix build python-build-system) (let ((python-version (python-version
get-python-version)
(assoc-ref inputs "python")))) (assoc-ref inputs "python"))))
(setenv "PYTHONPATH" (setenv "PYTHONPATH"
(string-append (getenv "PYTHONPATH") (string-append (getenv "PYTHONPATH")

View file

@ -211,7 +211,11 @@ (define-public 389-ds-base
(arguments (arguments
`(#:modules ((srfi srfi-1) `(#:modules ((srfi srfi-1)
(guix build gnu-build-system) (guix build gnu-build-system)
((guix build python-build-system)
#:select (python-version))
(guix build utils)) (guix build utils))
#:imported-modules ((guix build python-build-system)
,@%gnu-build-system-modules)
#:configure-flags #:configure-flags
(list (string-append "--with-db=" (list (string-append "--with-db="
(assoc-ref %build-inputs "bdb")) (assoc-ref %build-inputs "bdb"))
@ -263,16 +267,9 @@ (define-public 389-ds-base
(add-after 'unpack 'fix-install-location-of-python-tools (add-after 'unpack 'fix-install-location-of-python-tools
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(get-python-version
;; FIXME: copied from python-build-system
(lambda (python)
(let* ((version (last (string-split python #\-)))
(components (string-split version #\.))
(major+minor (take components 2)))
(string-join major+minor "."))))
(pythondir (string-append (pythondir (string-append
out "/lib/python" out "/lib/python"
(get-python-version (assoc-ref inputs "python")) (python-version (assoc-ref inputs "python"))
"/site-packages/"))) "/site-packages/")))
;; Install directory must be on PYTHONPATH. ;; Install directory must be on PYTHONPATH.
(setenv "PYTHONPATH" (setenv "PYTHONPATH"

View file

@ -831,8 +831,7 @@ (define-public conda
(lambda* (#:key inputs outputs #:allow-other-keys) (lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(target (string-append out "/lib/python" (target (string-append out "/lib/python"
((@@ (guix build python-build-system) (python-version
get-python-version)
(assoc-ref inputs "python")) (assoc-ref inputs "python"))
"/site-packages/"))) "/site-packages/")))
;; The installer aborts if the target directory is not on ;; The installer aborts if the target directory is not on

View file

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2015, 2016, 2018 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013, 2015, 2016, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2015, 2018 Mark H Weaver <mhw@netris.org>
@ -32,6 +32,7 @@ (define-module (guix build python-build-system)
#:export (%standard-phases #:export (%standard-phases
add-installed-pythonpath add-installed-pythonpath
site-packages site-packages
python-version
python-build)) python-build))
;; Commentary: ;; Commentary:
@ -147,7 +148,7 @@ (define* (check #:key tests? test-target use-setuptools? #:allow-other-keys)
(format #t "test suite not run~%")) (format #t "test suite not run~%"))
#t) #t)
(define (get-python-version python) (define (python-version python)
(let* ((version (last (string-split python #\-))) (let* ((version (last (string-split python #\-)))
(components (string-split version #\.)) (components (string-split version #\.))
(major+minor (take components 2))) (major+minor (take components 2)))
@ -158,7 +159,7 @@ (define (site-packages inputs outputs)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(python (assoc-ref inputs "python"))) (python (assoc-ref inputs "python")))
(string-append out "/lib/python" (string-append out "/lib/python"
(get-python-version python) (python-version python)
"/site-packages/"))) "/site-packages/")))
(define (add-installed-pythonpath inputs outputs) (define (add-installed-pythonpath inputs outputs)
@ -202,7 +203,7 @@ (define bindirs
(python (assoc-ref inputs "python")) (python (assoc-ref inputs "python"))
(var `("PYTHONPATH" prefix (var `("PYTHONPATH" prefix
,(cons (string-append out "/lib/python" ,(cons (string-append out "/lib/python"
(get-python-version python) (python-version python)
"/site-packages") "/site-packages")
(search-path-as-string->list (search-path-as-string->list
(or (getenv "PYTHONPATH") "")))))) (or (getenv "PYTHONPATH") ""))))))
@ -222,7 +223,7 @@ (define* (rename-pth-file #:key name inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out")) (let* ((out (assoc-ref outputs "out"))
(python (assoc-ref inputs "python")) (python (assoc-ref inputs "python"))
(site-packages (string-append out "/lib/python" (site-packages (string-append out "/lib/python"
(get-python-version python) (python-version python)
"/site-packages")) "/site-packages"))
(easy-install-pth (string-append site-packages "/easy-install.pth")) (easy-install-pth (string-append site-packages "/easy-install.pth"))
(new-pth (string-append site-packages "/" name ".pth"))) (new-pth (string-append site-packages "/" name ".pth")))