From d95523fb8b437565226a1dc445bd883b434ca612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sun, 21 Dec 2014 12:28:10 +0100 Subject: [PATCH 1/5] packages: Sort Scheme file lists used by 'fold-packages'. * gnu/packages.scm (scheme-files): Call 'sort' on result. --- gnu/packages.scm | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/gnu/packages.scm b/gnu/packages.scm index c9efd0d691..6109d1f896 100644 --- a/gnu/packages.scm +++ b/gnu/packages.scm @@ -105,24 +105,29 @@ (define %package-module-path (append environment `((,%distro-root-directory . "gnu/packages")))))) (define* (scheme-files directory) - "Return the list of Scheme files found under DIRECTORY." - (file-system-fold (const #t) ; enter? - (lambda (path stat result) ; leaf - (if (string-suffix? ".scm" path) - (cons path result) - result)) - (lambda (path stat result) ; down - result) - (lambda (path stat result) ; up - result) - (const #f) ; skip - (lambda (path stat errno result) - (warning (_ "cannot access `~a': ~a~%") - path (strerror errno)) - result) - '() - directory - stat)) + "Return the list of Scheme files found under DIRECTORY, recursively. The +returned list is sorted in alphabetical order." + + ;; Sort entries so that 'fold-packages' works in a deterministic fashion + ;; regardless of details of the underlying file system. + (sort (file-system-fold (const #t) ; enter? + (lambda (path stat result) ; leaf + (if (string-suffix? ".scm" path) + (cons path result) + result)) + (lambda (path stat result) ; down + result) + (lambda (path stat result) ; up + result) + (const #f) ; skip + (lambda (path stat errno result) + (warning (_ "cannot access `~a': ~a~%") + path (strerror errno)) + result) + '() + directory + stat) + stringmodule-name (let ((not-slash (char-set-complement (char-set #\/)))) From a193b8248b235d1c29905c5be9431ba20c7bf412 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Sun, 21 Dec 2014 16:21:02 -0500 Subject: [PATCH 2/5] Optimize package-transitive-supported-systems. * guix/packages.scm (first-value): Remove. (define-memoized/v): New macro. (package-transitive-supported-systems): Rewrite. --- guix/packages.scm | 61 +++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 07f6d0ccbc..2a9a55e12f 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès +;;; Copyright © 2014 Mark H Weaver ;;; ;;; This file is part of GNU Guix. ;;; @@ -543,40 +544,38 @@ (define (package-transitive-propagated-inputs package) recursively." (transitive-inputs (package-propagated-inputs package))) -(define-syntax-rule (first-value exp) - "Truncate all but the first value returned by EXP." - (call-with-values (lambda () exp) - (lambda (result . _) - result))) +(define-syntax define-memoized/v + (lambda (form) + "Define a memoized single-valued unary procedure with docstring. +The procedure argument is compared to cached keys using `eqv?'." + (syntax-case form () + ((_ (proc arg) docstring body body* ...) + (string? (syntax->datum #'docstring)) + #'(define proc + (let ((cache (make-hash-table))) + (define (proc arg) + docstring + (match (hashv-get-handle cache arg) + ((_ . value) + value) + (_ + (let ((result (let () body body* ...))) + (hashv-set! cache arg result) + result)))) + proc)))))) -(define (package-transitive-supported-systems package) +(define-memoized/v (package-transitive-supported-systems package) "Return the intersection of the systems supported by PACKAGE and those supported by its dependencies." - (first-value - (let loop ((package package) - (systems (package-supported-systems package)) - (visited vlist-null)) - (match (vhash-assq package visited) - ((_ . result) - (values (lset-intersection string=? systems result) - visited)) - (#f - (call-with-values - (lambda () - (fold2 (lambda (input systems visited) - (match input - ((label (? package? package) . _) - (loop package systems visited)) - (_ - (values systems visited)))) - (lset-intersection string=? - systems - (package-supported-systems package)) - visited - (package-direct-inputs package))) - (lambda (systems visited) - (values systems - (vhash-consq package systems visited))))))))) + (fold (lambda (input systems) + (match input + ((label (? package? p) . _) + (lset-intersection + string=? systems (package-transitive-supported-systems p))) + (_ + systems))) + (package-supported-systems package) + (package-direct-inputs package))) (define (bag-transitive-inputs bag) "Same as 'package-transitive-inputs', but applied to a bag." From afc720d34c43a2fcf0b5871226c15ad6c5f73697 Mon Sep 17 00:00:00 2001 From: Federico Beffa Date: Tue, 23 Dec 2014 17:51:40 +0100 Subject: [PATCH 3/5] gnu: matplotlib: Comment out python2-matplotlib. * gnu/packages/python.scm (python2-matplotlib, python2-scipy, python2-numpy): Comment out python2-matplotlib and the packages making use of it as the generation of the derivation of these packages takes very long. --- gnu/packages/python.scm | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index f81ab695af..2ff258fb4b 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -2011,17 +2011,17 @@ (define-public python-numpy (find-files "." ".*")))))) ,phases))))))) -(define-public python2-numpy - (let ((numpy (package-with-python2 python-numpy))) - (package (inherit numpy) - ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is customized for - ;; Python 2. Since it is also an input to PYTHON2-MATPLOTLIB, we need to - ;; import the right version of 'matplotlib' as well. - (inputs `(("python2-numpydoc" ,python2-numpydoc) - ("python2-matplotlib" ,python2-matplotlib) - ,@(alist-delete "python-numpydoc" - (alist-delete "python-matplotlib" - (package-inputs numpy)))))))) +;; (define-public python2-numpy +;; (let ((numpy (package-with-python2 python-numpy))) +;; (package (inherit numpy) +;; ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is customized for +;; ;; Python 2. Since it is also an input to PYTHON2-MATPLOTLIB, we need to +;; ;; import the right version of 'matplotlib' as well. +;; (inputs `(("python2-numpydoc" ,python2-numpydoc) +;; ("python2-matplotlib" ,python2-matplotlib) +;; ,@(alist-delete "python-numpydoc" +;; (alist-delete "python-matplotlib" +;; (package-inputs numpy)))))))) (define-public python-pyparsing (package @@ -2227,22 +2227,22 @@ (define-public python-matplotlib toolkits.") (license psfl))) -(define-public python2-matplotlib - (let ((matplotlib (package-with-python2 python-matplotlib))) - (package (inherit matplotlib) - ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is - ;; customized for Python 2. - (propagated-inputs - `(("python2-py2cairo" ,python2-py2cairo) - ("python2-pygobject-2" ,python2-pygobject-2) - ,@(alist-delete "python-pycairo" - (alist-delete "python-pygobject" - (package-propagated-inputs - matplotlib))))) - (inputs - `(("python2-numpydoc" ,python2-numpydoc) - ,@(alist-delete "python-numpydoc" - (package-inputs matplotlib))))))) +;; (define-public python2-matplotlib +;; (let ((matplotlib (package-with-python2 python-matplotlib))) +;; (package (inherit matplotlib) +;; ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is +;; ;; customized for Python 2. +;; (propagated-inputs +;; `(("python2-py2cairo" ,python2-py2cairo) +;; ("python2-pygobject-2" ,python2-pygobject-2) +;; ,@(alist-delete "python-pycairo" +;; (alist-delete "python-pygobject" +;; (package-propagated-inputs +;; matplotlib))))) +;; (inputs +;; `(("python2-numpydoc" ,python2-numpydoc) +;; ,@(alist-delete "python-numpydoc" +;; (package-inputs matplotlib))))))) ;; Scipy 0.14.0 with Numpy 0.19.X fails several tests. This is known and ;; planned to be fixed in 0.14.1. It is claimed that the failures can safely @@ -2341,15 +2341,15 @@ (define-public python-scipy routines such as routines for numerical integration and optimization.") (license bsd-3))) -(define-public python2-scipy - (let ((scipy (package-with-python2 python-scipy))) - (package (inherit scipy) - ;; Use packages customized for python-2. - (inputs `(("python2-matplotlib" ,python2-matplotlib) - ("python2-numpy" ,python2-numpy) - ,@(alist-delete "python-matplotlib" - (alist-delete "python-numpy" - (package-inputs scipy)))))))) +;; (define-public python2-scipy +;; (let ((scipy (package-with-python2 python-scipy))) +;; (package (inherit scipy) +;; ;; Use packages customized for python-2. +;; (inputs `(("python2-matplotlib" ,python2-matplotlib) +;; ("python2-numpy" ,python2-numpy) +;; ,@(alist-delete "python-matplotlib" +;; (alist-delete "python-numpy" +;; (package-inputs scipy)))))))) (define-public python-sqlalchemy (package From 78a274537032bdd61a11845ac0cf48cb121e8458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 23 Dec 2014 19:11:03 +0100 Subject: [PATCH 4/5] build-system/python: Fix 'package-with-explicit-python'. Reported by Federico Beffa and Eric Bavier . * guix/build-system/python.scm (package-with-explicit-python): Do nothing when P's build system is not PYTHON-BUILD-SYSTEM. --- guix/build-system/python.scm | 42 ++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/guix/build-system/python.scm b/guix/build-system/python.scm index 4bba7167ca..e8af9f8146 100644 --- a/guix/build-system/python.scm +++ b/guix/build-system/python.scm @@ -55,8 +55,7 @@ (define (package-with-explicit-python p python old-prefix new-prefix) inputs are changed recursively accordingly. If the name of P starts with OLD-PREFIX, this is replaced by NEW-PREFIX; otherwise, NEW-PREFIX is prepended to the name." - (let* ((build-system (package-build-system p)) - (rewrite-if-package + (let* ((rewrite-if-package (lambda (content) ;; CONTENT may be a file name, in which case it is returned, or a ;; package, which is rewritten with the new PYTHON and NEW-PREFIX. @@ -68,28 +67,23 @@ (define (package-with-explicit-python p python old-prefix new-prefix) (match-lambda ((name content . rest) (append (list name (rewrite-if-package content)) rest))))) - (package (inherit p) - (name - (let ((name (package-name p))) - (if (eq? build-system python-build-system) - (string-append new-prefix - (if (string-prefix? old-prefix name) - (substring name (string-length old-prefix)) - name)) - name))) - (arguments - (let ((arguments (package-arguments p))) - (if (eq? build-system python-build-system) - (if (member #:python arguments) - (substitute-keyword-arguments arguments ((#:python p) python)) - (append arguments `(#:python ,python))) - arguments))) - (inputs - (map rewrite (package-inputs p))) - (propagated-inputs - (map rewrite (package-propagated-inputs p))) - (native-inputs - (map rewrite (package-native-inputs p)))))) + + (if (eq? (package-build-system p) python-build-system) + (package (inherit p) + (name (let ((name (package-name p))) + (string-append new-prefix + (if (string-prefix? old-prefix name) + (substring name (string-length old-prefix)) + name)))) + (arguments + (let ((arguments (package-arguments p))) + (if (member #:python arguments) + (substitute-keyword-arguments arguments ((#:python p) python)) + (append arguments `(#:python ,python))))) + (inputs (map rewrite (package-inputs p))) + (propagated-inputs (map rewrite (package-propagated-inputs p))) + (native-inputs (map rewrite (package-native-inputs p)))) + p))) (define package-with-python2 (cut package-with-explicit-python <> (default-python2) "python-" "python2-")) From 764c077b307f0a9cdc800494da552077d6d23895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 23 Dec 2014 19:17:17 +0100 Subject: [PATCH 5/5] Revert "gnu: matplotlib: Comment out python2-matplotlib." This reverts commit afc720d34c43a2fcf0b5871226c15ad6c5f73697. --- gnu/packages/python.scm | 72 ++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm index 2ff258fb4b..f81ab695af 100644 --- a/gnu/packages/python.scm +++ b/gnu/packages/python.scm @@ -2011,17 +2011,17 @@ (define-public python-numpy (find-files "." ".*")))))) ,phases))))))) -;; (define-public python2-numpy -;; (let ((numpy (package-with-python2 python-numpy))) -;; (package (inherit numpy) -;; ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is customized for -;; ;; Python 2. Since it is also an input to PYTHON2-MATPLOTLIB, we need to -;; ;; import the right version of 'matplotlib' as well. -;; (inputs `(("python2-numpydoc" ,python2-numpydoc) -;; ("python2-matplotlib" ,python2-matplotlib) -;; ,@(alist-delete "python-numpydoc" -;; (alist-delete "python-matplotlib" -;; (package-inputs numpy)))))))) +(define-public python2-numpy + (let ((numpy (package-with-python2 python-numpy))) + (package (inherit numpy) + ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is customized for + ;; Python 2. Since it is also an input to PYTHON2-MATPLOTLIB, we need to + ;; import the right version of 'matplotlib' as well. + (inputs `(("python2-numpydoc" ,python2-numpydoc) + ("python2-matplotlib" ,python2-matplotlib) + ,@(alist-delete "python-numpydoc" + (alist-delete "python-matplotlib" + (package-inputs numpy)))))))) (define-public python-pyparsing (package @@ -2227,22 +2227,22 @@ (define-public python-matplotlib toolkits.") (license psfl))) -;; (define-public python2-matplotlib -;; (let ((matplotlib (package-with-python2 python-matplotlib))) -;; (package (inherit matplotlib) -;; ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is -;; ;; customized for Python 2. -;; (propagated-inputs -;; `(("python2-py2cairo" ,python2-py2cairo) -;; ("python2-pygobject-2" ,python2-pygobject-2) -;; ,@(alist-delete "python-pycairo" -;; (alist-delete "python-pygobject" -;; (package-propagated-inputs -;; matplotlib))))) -;; (inputs -;; `(("python2-numpydoc" ,python2-numpydoc) -;; ,@(alist-delete "python-numpydoc" -;; (package-inputs matplotlib))))))) +(define-public python2-matplotlib + (let ((matplotlib (package-with-python2 python-matplotlib))) + (package (inherit matplotlib) + ;; Make sure we use exactly PYTHON2-NUMPYDOC, which is + ;; customized for Python 2. + (propagated-inputs + `(("python2-py2cairo" ,python2-py2cairo) + ("python2-pygobject-2" ,python2-pygobject-2) + ,@(alist-delete "python-pycairo" + (alist-delete "python-pygobject" + (package-propagated-inputs + matplotlib))))) + (inputs + `(("python2-numpydoc" ,python2-numpydoc) + ,@(alist-delete "python-numpydoc" + (package-inputs matplotlib))))))) ;; Scipy 0.14.0 with Numpy 0.19.X fails several tests. This is known and ;; planned to be fixed in 0.14.1. It is claimed that the failures can safely @@ -2341,15 +2341,15 @@ (define-public python-scipy routines such as routines for numerical integration and optimization.") (license bsd-3))) -;; (define-public python2-scipy -;; (let ((scipy (package-with-python2 python-scipy))) -;; (package (inherit scipy) -;; ;; Use packages customized for python-2. -;; (inputs `(("python2-matplotlib" ,python2-matplotlib) -;; ("python2-numpy" ,python2-numpy) -;; ,@(alist-delete "python-matplotlib" -;; (alist-delete "python-numpy" -;; (package-inputs scipy)))))))) +(define-public python2-scipy + (let ((scipy (package-with-python2 python-scipy))) + (package (inherit scipy) + ;; Use packages customized for python-2. + (inputs `(("python2-matplotlib" ,python2-matplotlib) + ("python2-numpy" ,python2-numpy) + ,@(alist-delete "python-matplotlib" + (alist-delete "python-numpy" + (package-inputs scipy)))))))) (define-public python-sqlalchemy (package