build-system/python: Install to the python output if present.
* gnu/build/python-build-system.scm (python-output): New procedure. (site-packages, install): Use python-output to find the output path. (wrap, rename-pth-file): Use site-packages where appropriate. * doc/guix.texi (Build Systems): Mention the new behavior.
This commit is contained in:
parent
386457b7bd
commit
849f6e0ff9
2 changed files with 18 additions and 13 deletions
|
@ -6685,6 +6685,13 @@ By default guix calls @code{setup.py} under control of
|
||||||
@code{setuptools}, much like @command{pip} does. Some packages are not
|
@code{setuptools}, much like @command{pip} does. Some packages are not
|
||||||
compatible with setuptools (and pip), thus you can disable this by
|
compatible with setuptools (and pip), thus you can disable this by
|
||||||
setting the @code{#:use-setuptools?} parameter to @code{#f}.
|
setting the @code{#:use-setuptools?} parameter to @code{#f}.
|
||||||
|
|
||||||
|
If a @code{"python"} output is available, the package is installed into it
|
||||||
|
instead of the default @code{"out"} output. This is useful for packages that
|
||||||
|
include a Python package as only a part of the software, and thus want to
|
||||||
|
combine the phases of @code{python-build-system} with another build system.
|
||||||
|
Python bindings are a common usecase.
|
||||||
|
|
||||||
@end defvr
|
@end defvr
|
||||||
|
|
||||||
@defvr {Scheme Variable} perl-build-system
|
@defvr {Scheme Variable} perl-build-system
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
|
;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||||
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
|
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
|
||||||
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
|
;;; Copyright © 2018 Arun Isaac <arunisaac@systemreboot.net>
|
||||||
|
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -154,9 +155,14 @@
|
||||||
(major+minor (take components 2)))
|
(major+minor (take components 2)))
|
||||||
(string-join major+minor ".")))
|
(string-join major+minor ".")))
|
||||||
|
|
||||||
|
(define (python-output outputs)
|
||||||
|
"Return the path of the python output, if there is one, or fall-back to out."
|
||||||
|
(or (assoc-ref outputs "python")
|
||||||
|
(assoc-ref outputs "out")))
|
||||||
|
|
||||||
(define (site-packages inputs outputs)
|
(define (site-packages inputs outputs)
|
||||||
"Return the path of the current output's Python site-package."
|
"Return the path of the current output's Python site-package."
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((out (python-output outputs))
|
||||||
(python (assoc-ref inputs "python")))
|
(python (assoc-ref inputs "python")))
|
||||||
(string-append out "/lib/python"
|
(string-append out "/lib/python"
|
||||||
(python-version python)
|
(python-version python)
|
||||||
|
@ -175,7 +181,7 @@ when running checks after installing the package."
|
||||||
(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."
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((out (python-output outputs))
|
||||||
(params (append (list (string-append "--prefix=" out))
|
(params (append (list (string-append "--prefix=" out))
|
||||||
(if use-setuptools?
|
(if use-setuptools?
|
||||||
;; distutils does not accept these flags
|
;; distutils does not accept these flags
|
||||||
|
@ -199,12 +205,8 @@ when running checks after installing the package."
|
||||||
(string-append dir "/sbin"))))
|
(string-append dir "/sbin"))))
|
||||||
outputs))
|
outputs))
|
||||||
|
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((var `("PYTHONPATH" prefix
|
||||||
(python (assoc-ref inputs "python"))
|
,(cons (site-packages inputs outputs)
|
||||||
(var `("PYTHONPATH" prefix
|
|
||||||
,(cons (string-append out "/lib/python"
|
|
||||||
(python-version python)
|
|
||||||
"/site-packages")
|
|
||||||
(search-path-as-string->list
|
(search-path-as-string->list
|
||||||
(or (getenv "PYTHONPATH") ""))))))
|
(or (getenv "PYTHONPATH") ""))))))
|
||||||
(for-each (lambda (dir)
|
(for-each (lambda (dir)
|
||||||
|
@ -220,11 +222,7 @@ installed with setuptools."
|
||||||
;; Even if the "easy-install.pth" is not longer created, we kept this phase.
|
;; Even if the "easy-install.pth" is not longer created, we kept this phase.
|
||||||
;; There still may be packages creating an "easy-install.pth" manually for
|
;; There still may be packages creating an "easy-install.pth" manually for
|
||||||
;; some good reason.
|
;; some good reason.
|
||||||
(let* ((out (assoc-ref outputs "out"))
|
(let* ((site-packages (site-packages inputs outputs))
|
||||||
(python (assoc-ref inputs "python"))
|
|
||||||
(site-packages (string-append out "/lib/python"
|
|
||||||
(python-version python)
|
|
||||||
"/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")))
|
||||||
(when (file-exists? easy-install-pth)
|
(when (file-exists? easy-install-pth)
|
||||||
|
|
Reference in a new issue