build-system/python: Honor the 'python2-variant' property of packages.
Fixes <http://bugs.gnu.org/22437>. Reported by Leo Famulari <leo@famulari.name> and others. * guix/build-system/python.scm (package-with-explicit-python): Add #:variant-property and honor it. (strip-python2-variant): New procedure.
This commit is contained in:
parent
5540929500
commit
1be83341f6
|
@ -27,9 +27,11 @@
|
||||||
#:use-module (guix build-system)
|
#:use-module (guix build-system)
|
||||||
#:use-module (guix build-system gnu)
|
#:use-module (guix build-system gnu)
|
||||||
#:use-module (ice-9 match)
|
#:use-module (ice-9 match)
|
||||||
|
#:use-module (srfi srfi-1)
|
||||||
#:use-module (srfi srfi-26)
|
#:use-module (srfi srfi-26)
|
||||||
#:export (%python-build-system-modules
|
#:export (%python-build-system-modules
|
||||||
package-with-python2
|
package-with-python2
|
||||||
|
strip-python2-variant
|
||||||
python-build
|
python-build
|
||||||
python-build-system
|
python-build-system
|
||||||
pypi-uri))
|
pypi-uri))
|
||||||
|
@ -65,12 +67,19 @@ extension, such as '.tar.gz'."
|
||||||
(let ((python (resolve-interface '(gnu packages python))))
|
(let ((python (resolve-interface '(gnu packages python))))
|
||||||
(module-ref python 'python-2)))
|
(module-ref python 'python-2)))
|
||||||
|
|
||||||
(define (package-with-explicit-python python old-prefix new-prefix)
|
(define* (package-with-explicit-python python old-prefix new-prefix
|
||||||
|
#:key variant-property)
|
||||||
"Return a procedure of one argument, P. The procedure creates a package with
|
"Return a procedure of one argument, P. The procedure creates a package with
|
||||||
the same fields as P, which is assumed to use PYTHON-BUILD-SYSTEM, such that
|
the same fields as P, which is assumed to use PYTHON-BUILD-SYSTEM, such that
|
||||||
it is compiled with PYTHON instead. The inputs are changed recursively
|
it is compiled with PYTHON instead. The inputs are changed recursively
|
||||||
accordingly. If the name of P starts with OLD-PREFIX, this is replaced by
|
accordingly. If the name of P starts with OLD-PREFIX, this is replaced by
|
||||||
NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name."
|
NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name.
|
||||||
|
|
||||||
|
When VARIANT-PROPERTY is present, it is used as a key to search for
|
||||||
|
pre-defined variants of this transformation recorded in the 'properties' field
|
||||||
|
of packages. The property value must be the promise of a package. This is a
|
||||||
|
convenient way for package writers to force the transformation to use
|
||||||
|
pre-defined variants."
|
||||||
(define transform
|
(define transform
|
||||||
;; Memoize the transformations. Failing to do that, we would build a huge
|
;; Memoize the transformations. Failing to do that, we would build a huge
|
||||||
;; object graph with lots of duplicates, which in turns prevents us from
|
;; object graph with lots of duplicates, which in turns prevents us from
|
||||||
|
@ -90,26 +99,34 @@ NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name."
|
||||||
((name content . rest)
|
((name content . rest)
|
||||||
(append (list name (rewrite-if-package content)) rest)))))
|
(append (list name (rewrite-if-package content)) rest)))))
|
||||||
|
|
||||||
(if (eq? (package-build-system p) python-build-system)
|
(cond
|
||||||
(package
|
;; If VARIANT-PROPERTY is present, use that.
|
||||||
(inherit p)
|
((and variant-property
|
||||||
(location (package-location p))
|
(assoc-ref (package-properties p) variant-property))
|
||||||
(name (let ((name (package-name p)))
|
=> force)
|
||||||
(string-append new-prefix
|
|
||||||
(if (string-prefix? old-prefix name)
|
;; Otherwise build the new package object graph.
|
||||||
(substring name
|
((eq? (package-build-system p) python-build-system)
|
||||||
(string-length old-prefix))
|
(package
|
||||||
name))))
|
(inherit p)
|
||||||
(arguments
|
(location (package-location p))
|
||||||
(let ((python (if (promise? python)
|
(name (let ((name (package-name p)))
|
||||||
(force python)
|
(string-append new-prefix
|
||||||
python)))
|
(if (string-prefix? old-prefix name)
|
||||||
(ensure-keyword-arguments (package-arguments p)
|
(substring name
|
||||||
`(#:python ,python))))
|
(string-length old-prefix))
|
||||||
(inputs (map rewrite (package-inputs p)))
|
name))))
|
||||||
(propagated-inputs (map rewrite (package-propagated-inputs p)))
|
(arguments
|
||||||
(native-inputs (map rewrite (package-native-inputs p))))
|
(let ((python (if (promise? python)
|
||||||
p)))))
|
(force python)
|
||||||
|
python)))
|
||||||
|
(ensure-keyword-arguments (package-arguments p)
|
||||||
|
`(#:python ,python))))
|
||||||
|
(inputs (map rewrite (package-inputs p)))
|
||||||
|
(propagated-inputs (map rewrite (package-propagated-inputs p)))
|
||||||
|
(native-inputs (map rewrite (package-native-inputs p)))))
|
||||||
|
(else
|
||||||
|
p))))))
|
||||||
|
|
||||||
transform)
|
transform)
|
||||||
|
|
||||||
|
@ -118,7 +135,14 @@ NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name."
|
||||||
;; of packages is accessed to avoid a circular dependency when evaluating
|
;; of packages is accessed to avoid a circular dependency when evaluating
|
||||||
;; the top-level of (gnu packages python).
|
;; the top-level of (gnu packages python).
|
||||||
(package-with-explicit-python (delay (default-python2))
|
(package-with-explicit-python (delay (default-python2))
|
||||||
"python-" "python2-"))
|
"python-" "python2-"
|
||||||
|
#:variant-property 'python2-variant))
|
||||||
|
|
||||||
|
(define (strip-python2-variant p)
|
||||||
|
"Remove the 'python2-variant' property from P."
|
||||||
|
(package
|
||||||
|
(inherit p)
|
||||||
|
(properties (alist-delete 'python2-variant (package-properties p)))))
|
||||||
|
|
||||||
(define* (lower name
|
(define* (lower name
|
||||||
#:key source inputs native-inputs outputs system target
|
#:key source inputs native-inputs outputs system target
|
||||||
|
|
Loading…
Reference in New Issue