summary refs log tree commit diff
path: root/gnu/packages/python.scm
diff options
context:
space:
mode:
authorFederico Beffa <beffa@fbengineering.ch>2014-12-01 13:28:24 +0100
committerFederico Beffa <beffa@fbengineering.ch>2014-12-02 11:12:44 +0100
commit2ee8869a694803e582e203208d04a0725bfc8241 (patch)
treebc1eb42f4115a289aac01b4f825dff1599694262 /gnu/packages/python.scm
parent4cdec09a39580a920d1d20a0e1cf735124a327c2 (diff)
downloadguix-2ee8869a694803e582e203208d04a0725bfc8241.tar.gz
gnu: Add numpy.
* gnu/packages/python.scm (python-numpy, python2-numpy): New variables.
Diffstat (limited to 'gnu/packages/python.scm')
-rw-r--r--gnu/packages/python.scm71
1 files changed, 71 insertions, 0 deletions
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index dad68fdde5..88f892799f 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -46,6 +46,8 @@
   #:use-module (gnu packages image)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages which)
+  #:use-module (gnu packages perl)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -1939,6 +1941,75 @@ capabilities.")
 (define python2-numpy-bootstrap
   (package-with-python2 python-numpy-bootstrap))
 
+(define-public python-numpy
+  (package (inherit python-numpy-bootstrap)
+    (name "python-numpy")
+    (outputs '("out" "doc"))
+    (inputs 
+     `(("which" ,which)
+       ("python-setuptools" ,python-setuptools)
+       ("python-matplotlib" ,python-matplotlib)
+       ("python-sphinx" ,python-sphinx)
+       ("python-pyparsing" ,python-pyparsing)
+       ("python-numpydoc" ,python-numpydoc)
+       ,@(package-inputs python-numpy-bootstrap)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("texlive" ,texlive)
+       ("texinfo" ,texinfo)
+       ("perl" ,perl)
+       ,@(package-native-inputs python-numpy-bootstrap)))
+    (arguments
+     `(,@(substitute-keyword-arguments 
+             (package-arguments python-numpy-bootstrap)
+           ((#:phases phases)
+            `(alist-cons-after
+              'install 'install-doc
+              (lambda* (#:key outputs #:allow-other-keys)
+                (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
+                       (doc (string-append 
+                             data "/doc/" ,name "-" 
+                             ,(package-version python-numpy-bootstrap)))
+                       (info (string-append data "/info"))
+                       (html (string-append doc "/html"))
+                       (pyver ,(string-append "PYVER=")))
+                  (with-directory-excursion "doc"
+                    (mkdir-p html)
+                    (system* "make" "html" pyver)
+                    (system* "make" "latex" "PAPER=a4" pyver)
+                    (system* "make" "-C" "build/latex" 
+                             "all-pdf" "PAPER=a4" pyver)
+                    ;; FIXME: Generation of the info file fails.
+                    ;; (system* "make" "info" pyver)
+                    ;; (mkdir-p info)
+                    ;; (copy-file "build/texinfo/numpy.info"
+                    ;;            (string-append info "/numpy.info"))
+                    (for-each (lambda (file)
+                                (copy-file (string-append "build/latex" file)
+                                           (string-append doc file)))
+                              '("/numpy-ref.pdf" "/numpy-user.pdf"))
+                    (with-directory-excursion "build/html"
+                      (for-each (lambda (file)
+                                  (let* ((dir (dirname file))
+                                         (tgt-dir (string-append html "/" dir)))
+                                    (unless (equal? "." dir)
+                                      (mkdir-p tgt-dir))
+                                    (copy-file file (string-append html "/" file))))
+                                (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 python-pyparsing
   (package
     (name "python-pyparsing")