unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 1/2] gnu: Add numpy
@ 2014-10-26 13:09 Federico Beffa
  2014-10-26 18:56 ` Ludovic Courtès
  0 siblings, 1 reply; 41+ messages in thread
From: Federico Beffa @ 2014-10-26 13:09 UTC (permalink / raw)
  To: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 59 bytes --]

Here the first packages depending on ATLAS.

Regards,
Fede

[-- Attachment #2: 0001-gnu-Add-numpy.patch --]
[-- Type: text/x-patch, Size: 5578 bytes --]

From 063b33562c4fee2ea4e3fd1b53a27770047e9201 Mon Sep 17 00:00:00 2001
From: Federico Beffa <beffa@fbengineering.ch>
Date: Sun, 26 Oct 2014 15:03:17 +0100
Subject: [PATCH 1/2] gnu: Add numpy

* gnu/packages/python.scm(python-numpy, python2-numpy): New variables.
---
 gnu/packages/python.scm | 112 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index c995c1b..b39957a 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -37,6 +37,8 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages zip)
+  #:use-module (gnu packages maths)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -1832,3 +1834,113 @@ sources.")
 
 (define-public python2-sphinx
   (package-with-python2 python-sphinx))
+
+(define python-numpy-reference
+  (origin
+    (method url-fetch)
+    (uri (string-append "mirror://sourceforge/numpy/reference.pdf"))
+    (sha256 
+     (base32
+      "0izsmzazhd042ra6p7as2jhwx8713sc5gpn9s5nifwm68biwn0lp"))))
+
+(define python-numpy-userguide
+  (origin
+    (method url-fetch)
+    (uri (string-append "mirror://sourceforge/numpy/userguide.pdf"))
+    (sha256 
+     (base32
+      "1z2xjlxldv01ad2775k9birg1hkqay5wbi5vmgz3rlr6dczvk77k"))))
+
+(define-public python-numpy
+  (package
+    (name "python-numpy")
+    (version "1.9.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/numpy"
+                           "/numpy-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1xbzsb84wg32zx5ilgvkdp0lwfqrycwhh5a2q9nx5iwyjpgcxrpp"))))
+    (build-system python-build-system)
+    (inputs
+     `(("python" ,python) ; otherwise ld does not find libpython3.3m
+       ("python-numpy-userguide" ,python-numpy-userguide)
+       ("python-numpy-reference" ,python-numpy-reference)
+       ("atlas" ,atlas)))
+    (native-inputs
+     `(("python-nose" ,python-nose)  ; used by tests
+       ("gfortran" ,gfortran-4.8)))
+    (outputs '("out" "doc"))         ; doc is ca. 9MB
+    (arguments
+     `(#:phases
+       (alist-replace
+        'build
+        (lambda* (#:key outputs inputs 
+                  #:allow-other-keys #:rest args)
+          (let* ((build (assoc-ref %standard-phases 'build))
+                 (atlas-threaded
+                  (string-append (assoc-ref inputs "atlas") 
+                                 "/lib/libtatlas.so"))
+                 ;; On single core CPUs only the serial library is created.
+                 (atlas-lib
+                  (if (file-exists? atlas-threaded)
+                      atlas-threaded
+                      (string-append (assoc-ref inputs "atlas") 
+                                     "/lib/libsatlas.so"))))
+            (setenv "ATLAS" atlas-lib)
+            (apply build args)))
+        (alist-cons-after
+         'install 'install-doc
+         (lambda* (#:key outputs inputs #:allow-other-keys)
+           ;; procedure from gnu-build-system.scm
+           (define (package-name)
+             (let* ((out  (assoc-ref outputs "out"))
+                    (base (basename out))
+                    (dash (string-rindex base #\-)))
+               (string-drop (if dash
+                                (substring base 0 dash)
+                                base)
+                            (+ 1 (string-index base #\-)))))
+
+           (let ((doc (string-append (assoc-ref outputs "doc") 
+                                     "/share/doc/" (package-name))))
+             (mkdir-p doc)
+             (and (zero? 
+                   (system* "cp" 
+                            (assoc-ref inputs "python-numpy-reference") 
+                            (string-append doc "/reference.pdf")))
+                  (zero? 
+                   (system* "cp" 
+                            (assoc-ref inputs "python-numpy-userguide")
+                            (string-append doc "/userguide.pdf"))))))
+         ;; Tests can only be run after the library has been installed and not
+         ;; within the source directory.
+         (alist-cons-after
+          'install 'check
+          (lambda _ 
+            (with-directory-excursion "/tmp"
+              (zero? (system* "python" "-c" "import numpy; numpy.test()"))))
+          (alist-delete 
+           'check 
+           %standard-phases))))))
+    (home-page "http://www.numpy.org/")
+    (synopsis "Fundamental package for scientific computing with Python")
+    (description "NumPy is the fundamental package for scientific computing
+with Python. It contains among other things: a powerful N-dimensional array
+object, sophisticated (broadcasting) functions, tools for integrating C/C++
+and Fortran code, useful linear algebra, Fourier transform, and random number
+capabilities.")
+    (license bsd-3)))
+
+(define-public python2-numpy
+  (package (inherit (package-with-python2 python-numpy))
+           ;; If we don't redefine the inputs here, then python (version 3) is
+           ;; also imported and its libraries come first in PYTHONPATH.  This
+           ;; causes the 'check phase to fail.
+           (inputs
+            `(("python-2" ,python-2) ; otherwise ld does not find libpython2.7
+              ("python-numpy-userguide" ,python-numpy-userguide)
+              ("python-numpy-reference" ,python-numpy-reference)
+              ("atlas" ,atlas)))))
-- 
1.8.4


^ permalink raw reply related	[flat|nested] 41+ messages in thread
* Re: [PATCH 1/2] gnu: Add numpy
@ 2014-10-29 19:17 Federico Beffa
  2014-10-29 19:55 ` Federico Beffa
  2014-10-29 21:26 ` Ludovic Courtès
  0 siblings, 2 replies; 41+ messages in thread
From: Federico Beffa @ 2014-10-29 19:17 UTC (permalink / raw)
  To: Guix-devel, Ludovic Courtès

> Personally my main use of ATLAS is through numpy/scipy. Therefore I
> would like to be able to use a good performing ATLAS with those
> packages.  If that needs a manual installation step, that's fine with
> me.
>
> In principle we could make a second package and add a suffix to the
> version number such that the general binary version takes precedence.
> To get a locally built library one would then have to give an explicit
> ATLAS version to guix.  Or, do you have other approaches in mind?

Actually this is not a good idea because then, every time you update
your system, you get the slow version.

In my opinion the fact that guix makes it easy to build a package on
the user machine is really a key advantage over other package
managers/distributions, for a few, somewhat special packages, ATLAS
being one.  It would really be a pity to give up such nice a feature
to spare some build time (ca. 10 min. on my system from 2007).

Regards,
Fede

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2014-11-24 21:24 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-26 13:09 [PATCH 1/2] gnu: Add numpy Federico Beffa
2014-10-26 18:56 ` Ludovic Courtès
2014-10-27 20:26   ` Federico Beffa
2014-10-28  9:34     ` Ludovic Courtès
2014-10-28 17:49       ` Federico Beffa
2014-10-29 21:28         ` Ludovic Courtès
2014-10-28 23:34       ` Ludovic Courtès
2014-10-29 22:23       ` Andreas Enge
2014-10-30 13:12         ` Changing python-wrapper to handle lib/ etc Ludovic Courtès
2014-11-02 17:44           ` Andreas Enge
2014-11-02 21:32             ` Andreas Enge
2014-11-03 10:11               ` Federico Beffa
2014-11-03 10:13                 ` Andreas Enge
2014-11-03 20:19                   ` Andreas Enge
2014-11-03 20:49                     ` Andreas Enge
2014-11-03 22:06                       ` Andreas Enge
2014-11-04  9:44                         ` Ludovic Courtès
2014-11-04 13:07                           ` Andreas Enge
2014-11-04 16:48                             ` Ludovic Courtès
2014-11-04 17:08                               ` Andreas Enge
2014-11-04 18:26                                 ` Andreas Enge
2014-11-04 21:40                                 ` Ludovic Courtès
2014-11-04 22:29                                   ` Andreas Enge
2014-11-03  9:04             ` Ludovic Courtès
2014-10-29 22:20     ` [PATCH 1/2] gnu: Add numpy Andreas Enge
2014-10-30 16:56       ` Federico Beffa
2014-10-30 17:03         ` Andreas Enge
2014-10-30 17:05           ` Federico Beffa
2014-11-02 18:21   ` Ludovic Courtès
  -- strict thread matches above, loose matches on Subject: below --
2014-10-29 19:17 Federico Beffa
2014-10-29 19:55 ` Federico Beffa
2014-10-29 22:11   ` Ludovic Courtès
2014-10-30 17:03     ` Federico Beffa
2014-11-19  9:04       ` Ludovic Courtès
2014-11-22 15:31         ` Federico Beffa
2014-11-22 17:21           ` Ludovic Courtès
2014-11-24 19:56             ` Federico Beffa
2014-11-24 21:06               ` Ludovic Courtès
2014-11-24 21:24                 ` Federico Beffa
2014-10-29 22:30   ` Andreas Enge
2014-10-29 21:26 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).