gnu: python-html5lib: Add propagated input.
[jackhill/guix/guix.git] / gnu / packages / python.scm
index 81b6c95..bbff241 100644 (file)
@@ -1,9 +1,13 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
-;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2013, 2014, 2015 Andreas Enge <andreas@enge.fr>
+;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2014, 2015 Federico Beffa <beffa@fbengineering.ch>
+;;; Copyright © 2015 Omar Radwan <toxemicsquire4@gmail.com>
+;;; Copyright © 2015 Pierre-Antoine Rault <par@rigelk.eu>
+;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
 
 (define-module (gnu packages python)
   #:use-module ((guix licenses)
-                #:select (asl2.0 bsd-3 bsd-2 bsd-style cc0 expat x11 x11-style
-                          gpl2 gpl2+ gpl3+ lgpl2.0+ lgpl2.1+
-                          psfl public-domain))
-  #:use-module ((guix licenses) #:select (zlib)
-                                #:renamer (symbol-prefix-proc 'license:))
+                #:select (asl2.0 bsd-3 bsd-2 bsd-style cc0 x11 x11-style
+                          gpl2 gpl2+ gpl3+ lgpl2.0+ lgpl2.1 lgpl2.1+ lgpl3+
+                          psfl public-domain x11-style))
+  #:use-module ((guix licenses) #:select (expat zlib) #:prefix license:)
   #:use-module (gnu packages)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages databases)
+  #:use-module (gnu packages elf)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gdbm)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages ghostscript)
+  #:use-module (gnu packages glib)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages image)
+  #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages libffi)
-  #:use-module (gnu packages readline)
+  #:use-module (gnu packages maths)
+  #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages ncurses)
   #:use-module (gnu packages openssl)
-  #:use-module (gnu packages elf)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
-  #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages readline)
+  #:use-module (gnu packages texlive)
+  #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages which)
+  #:use-module (gnu packages xml)
+  #:use-module (gnu packages xorg)
   #:use-module (gnu packages zip)
-  #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
-  #:use-module (guix build-system trivial))
+  #:use-module (guix build-system trivial)
+  #:use-module (srfi srfi-1))
 
 (define-public python-2
   (package
@@ -55,7 +75,8 @@
       (method url-fetch)
       (uri (string-append "https://www.python.org/ftp/python/"
                           version "/Python-" version ".tar.xz"))
-      (patches (list (search-patch "python-libffi-mips-n32-fix.patch")))
+      (patches (list (search-patch "python-libffi-mips-n32-fix.patch")
+                     (search-patch "python2-sqlite-3.8.4-test-fix.patch")))
       (patch-flags '("-p0"))
       (sha256
        (base32
         (let ((bz2 (assoc-ref %build-inputs "bzip2"))
               (gdbm (assoc-ref %build-inputs "gdbm"))
               (libffi (assoc-ref %build-inputs "libffi"))
+              (sqlite (assoc-ref %build-inputs "sqlite"))
               (openssl (assoc-ref %build-inputs "openssl"))
               (readline (assoc-ref %build-inputs "readline"))
               (zlib (assoc-ref %build-inputs "zlib")))
                (string-append "CPPFLAGS="
                 "-I" bz2 "/include "
                 "-I" gdbm "/include "
+                "-I" sqlite "/include "
                 "-I" openssl "/include "
                 "-I" readline "/include "
                 "-I" zlib "/include")
                 "-L" bz2 "/lib "
                 "-L" gdbm "/lib "
                 "-L" libffi "/lib "
+                "-L" sqlite "/lib "
                 "-L" openssl "/lib "
                 "-L" readline "/lib "
                 "-L" zlib "/lib")))
      `(("bzip2" ,bzip2)
        ("gdbm" ,gdbm)
        ("libffi" ,libffi)                         ; for ctypes
+       ("sqlite" ,sqlite)                         ; for sqlite extension
        ("openssl" ,openssl)
        ("readline" ,readline)
        ("zlib" ,zlib)
     (native-search-paths
      (list (search-path-specification
             (variable "PYTHONPATH")
-            (directories '("lib/python2.7/site-packages")))))
+            (files '("lib/python2.7/site-packages")))))
     (home-page "http://python.org")
     (synopsis
-     "Python, a high-level dynamically-typed programming language")
+     "High-level, dynamically-typed programming language")
     (description
      "Python is a remarkably powerful dynamic programming language that
 is used in a wide variety of application domains.  Some of its key
@@ -198,6 +223,7 @@ data types.")
               (uri (string-append "https://www.python.org/ftp/python/"
                                   version "/Python-" version ".tar.xz"))
               (patches (list (search-patch "python-fix-tests.patch")
+                             (search-patch "python-sqlite-3.8.4-test-fix.patch")
                              (search-patch "python-libffi-mips-n32-fix.patch")))
               (patch-flags '("-p0"))
               (sha256
@@ -214,14 +240,14 @@ data types.")
     (native-search-paths
      (list (search-path-specification
             (variable "PYTHONPATH")
-            (directories '("lib/python3.3/site-packages")))))))
+            (files '("lib/python3.3/site-packages")))))))
 
 (define-public python-wrapper
   (package (inherit python)
     (name "python-wrapper")
     (source #f)
     (build-system trivial-build-system)
-    (inputs `(("python" ,python)))
+    (propagated-inputs `(("python" ,python)))
     (arguments
      `(#:modules ((guix build utils))
        #:builder
@@ -256,7 +282,7 @@ data types.")
     (build-system python-build-system)
     (arguments `(#:tests? #f)) ; no test target
     (home-page "https://launchpad.net/pytz")
-    (synopsis "The Python timezone library.")
+    (synopsis "Python timezone library")
     (description
      "This library allows accurate and cross platform timezone calculations
 using Python 2.4 or higher and provides access to the Olson timezone database.")
@@ -316,7 +342,7 @@ etc. ")
     (description
      "The lockfile package exports a LockFile class which provides a simple
 API for locking files.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-lockfile
   (package-with-python2 python-lockfile))
@@ -335,13 +361,13 @@ API for locking files.")
          "0kzlsbki6q0awf89rc287f3aj8x431lrajf160a70z0ikhnxsfdq"))))
     (build-system python-build-system)
     (arguments '(#:test-target "check"))
-    (home-page "http://code.google.com/m/mock/")
-    (synopsis "A Python Mocking and Patching Library for Testing")
+    (home-page "http://code.google.com/p/mock/")
+    (synopsis "Python mocking and patching library for testing")
     (description
      "Mock is a library for testing in Python.  It allows you to replace parts
 of your system under test with mock objects and make assertions about how they
 have been used.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-mock
   (package-with-python2 python-mock))
@@ -350,7 +376,7 @@ have been used.")
 (define-public python-setuptools
   (package
     (name "python-setuptools")
-    (version "1.1.4")
+    (version "12.1")
     (source
      (origin
       (method url-fetch)
@@ -358,14 +384,12 @@ have been used.")
                           version ".tar.gz"))
       (sha256
        (base32
-        "0hl9sa5xr9bi2ifq51wy1bawsjv5nzvpbac7m9z1ciz778874csf"))))
+        "04bfk7si1pwj3b5k2b1x9b1zkiclybmzpw6alrs5bciri56lg9zs"))))
     (build-system python-build-system)
+    ;; FIXME: Tests require pytest, which itself relies on setuptools.
+    ;; One could bootstrap with an internal untested setuptools.
     (arguments
      `(#:tests? #f))
-         ;;FIXME: test_sdist_with_utf8_encoded_filename fails in
-         ;; /tmp/nix-build-python2-setuptools-1.1.4.drv-0/setuptools-1.1.4/setuptools/tests/test_sdist.py"
-         ;; line 354
-         ;; The tests pass with Python 2.7.5.
     (home-page "https://pypi.python.org/pypi/setuptools")
     (synopsis
      "Library designed to facilitate packaging Python projects")
@@ -415,7 +439,7 @@ Python 3 support.")
     (description
      "Pycrypto is a collection of both secure hash functions (such as SHA256
 and RIPEMD160), and various encryption algorithms (AES, DES, RSA, ElGamal,
-etc.). The package is structured to make adding new modules easy.")
+etc.).  The package is structured to make adding new modules easy.")
     (license public-domain)))
 
 (define-public python-keyring
@@ -453,7 +477,7 @@ etc.). The package is structured to make adding new modules easy.")
     (synopsis "Store and access your passwords safely")
     (description
      "The Python keyring lib provides a easy way to access the system keyring
-service from python. It can be used in any application that needs safe
+service from python.  It can be used in any application that needs safe
 password storage.")
     ;; "MIT" and PSF dual license
     (license x11)))
@@ -476,13 +500,16 @@ password storage.")
     (home-page "http://pypi.python.org/pypi/six/")
     (synopsis "Python 2 and 3 compatibility utilities")
     (description
-     "Six is a Python 2 and 3 compatibility library. It provides utility
+     "Six is a Python 2 and 3 compatibility library.  It provides utility
 functions for smoothing over the differences between the Python versions with
 the goal of writing Python code that is compatible on both Python versions.
-Six supports every Python version since 2.5. It is contained in only one
+Six supports every Python version since 2.5.  It is contained in only one
 Python file, so it can be easily copied into your project.")
     (license x11)))
 
+(define-public python2-six
+  (package-with-python2 python-six))
+
 (define-public python-dateutil-2
   (package
     (name "python-dateutil")
@@ -587,7 +614,7 @@ datetime module, available in Python 2.3+.")
         %standard-phases)))
     (home-page "https://github.com/regebro/tzlocal")
     (synopsis
-     "tzinfo object for the local timezone")
+     "Local timezone information for Python")
     (description
      "Tzlocal returns a tzinfo object with the local timezone information.
 This module attempts to fix a glaring hole in pytz, that there is no way to
@@ -595,6 +622,43 @@ get the local timezone information, unless you know the zoneinfo name, and
 under several distributions that's hard or impossible to figure out.")
     (license cc0)))
 
+(define-public python-pysam
+  (package
+    (name "python-pysam")
+    (version "0.8.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://pypi.python.org/packages/source/p/pysam/pysam-"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "1fb6i6hbpzxaxb62kyyp5alaidwhj40f7c6gwbhr6njzlqd5l459"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:tests? #f ; tests are excluded in the manifest
+       #:phases
+       (alist-cons-before
+        'build 'set-flags
+        (lambda _
+          (setenv "LDFLAGS" "-lncurses")
+          (setenv "CFLAGS" "-D_CURSES_LIB=1"))
+        %standard-phases)))
+    (inputs
+     `(("python-cython"     ,python-cython)
+       ("python-setuptools" ,python-setuptools)
+       ("ncurses"           ,ncurses)
+       ("zlib"              ,zlib)))
+    (home-page "https://github.com/pysam-developers/pysam")
+    (synopsis "Python bindings to the SAMtools C API")
+    (description
+     "Pysam is a Python module for reading and manipulating files in the
+SAM/BAM format.  Pysam is a lightweight wrapper of the SAMtools C API.  It
+also includes an interface for tabix.")
+    (license license:expat)))
+
+(define-public python2-pysam
+  (package-with-python2 python-pysam))
 
 (define-public python2-pysqlite
   (package
@@ -697,7 +761,7 @@ Python 3.3+.")
 (define-public python2-pyicu
   (package
     (name "python2-pyicu")
-    (version "1.5")
+    (version "1.8")
     (source
      (origin
       (method url-fetch)
@@ -705,7 +769,7 @@ Python 3.3+.")
                           version ".tar.gz"))
       (sha256
        (base32
-        "011vwflpir8wvh48mvi6d9a7vw0f43bkwv0w6bzxbzmvz20ax5vm"))))
+        "1y361x82lnh9k9srmdx3q92z5iag112z7r5fxm0n1sfwb349yjdw"))))
     (build-system python-build-system)
     (inputs
      `(("icu4c" ,icu4c)))
@@ -714,8 +778,7 @@ Python 3.3+.")
                           ; linking with libpython3.3m
        #:tests? #f)) ; no check target
     (home-page "http://pyicu.osafoundation.org/")
-    (synopsis
-     "Python extension wrapping the ICU C++ API.")
+    (synopsis "Python extension wrapping the ICU C++ API")
     (description
      "PyICU is a python extension wrapping the ICU C++ API.")
     (license x11)))
@@ -740,7 +803,7 @@ Python 3.3+.")
     (home-page "https://fedorahosted.org/dogtail/")
     (synopsis "GUI test tool and automation framework written in ​Python")
     (description
-     "dogtail is a GUI test tool and automation framework written in Python.
+     "Dogtail is a GUI test tool and automation framework written in Python.
 It uses Accessibility (a11y) technologies to communicate with desktop
 applications. dogtail scripts are written in Python and executed like any
 other Python program.")
@@ -962,7 +1025,7 @@ software.")
     (synopsis "Useful extensions to the Python standard library")
     (description
      "Extras is a set of extensions to the Python standard library.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-extras
   (package-with-python2 python-extras))
@@ -987,11 +1050,11 @@ software.")
      '(#:tests? #f)) ; no setup.py test command
     (home-page
      "https://github.com/dbtsai/python-mimeparse")
-    (synopsis "Python library for parsing MIME types.")
+    (synopsis "Python library for parsing MIME types")
     (description
      "Mimeparse provides basic functions for parsing MIME type names and
 matching them against a list of media-ranges.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-mimeparse
   (package-with-python2 python-mimeparse))
@@ -1086,7 +1149,7 @@ standard library.")
     (description
      "Py is a Python library for file name parsing, .ini file parsing, I/O,
 code introspection, and logging.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-py
   (package-with-python2 python-py))
@@ -1122,7 +1185,7 @@ code introspection, and logging.")
      "Pytest is a testing tool that provides auto-discovery of test modules
 and functions, detailed info on failing assert statements, modular fixtures,
 and many external plugins.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-pytest
   (package-with-python2 python-pytest))
@@ -1149,7 +1212,7 @@ and many external plugins.")
     (description "Scripttest is a Python helper library for testing
 interactive command-line applications.  With it you can run a script in a
 subprocess and see the output as well as any file modifications.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-scripttest
   (package-with-python2 python-scripttest))
@@ -1537,7 +1600,7 @@ than Python’s urllib2 library.")
     (synopsis "Implementation of JSON Schema for Python")
     (description
      "Jsonschema is an implementation of JSON Schema for Python.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-jsonschema
   (package-with-python2 python-jsonschema))
@@ -1593,7 +1656,7 @@ somewhat intelligeble.")
     (synopsis "JSON Web Token implementation in Python")
     (description
      "PyJWT is a JSON Web Token implementation written in Python.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-pyjwt
   (package-with-python2 python-pyjwt))
@@ -1629,17 +1692,6 @@ OAuth request-signing logic.")
   (let ((base (package-with-python2 python-oauthlib)))
     (package
       (inherit base)
-      (name "python2-oauthlib")
-      (version "0.6.3")
-      (source (origin
-                (method url-fetch)
-                (uri
-                 (string-append
-                  "https://pypi.python.org/packages/source/o/oauthlib/oauthlib-"
-                  version ".tar.gz"))
-                (sha256
-                 (base32
-                  "1yaj3j64la4arwsbhbfmpnickzh3jpg9nlpyg409v8pp24isn48a"))))
       (inputs
        (append (package-inputs base)
                `(("python2-unittest2" ,python2-unittest2)))))))
@@ -1692,7 +1744,7 @@ environments and back.")
     (synopsis "Virtual Python environment builder")
     (description
      "Virtualenv is a tool to create isolated Python environments.")
-    (license expat)))
+    (license license:expat)))
 
 (define-public python2-virtualenv
   (package-with-python2 python-virtualenv))
@@ -1834,3 +1886,1324 @@ sources.")
 
 (define-public python2-sphinx
   (package-with-python2 python-sphinx))
+
+(define-public python-sphinx-rtd-theme
+  (package
+    (name "python-sphinx-rtd-theme")
+    (version "0.1.6")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://pypi.python.org/packages/source/s/"
+                           "sphinx_rtd_theme/sphinx_rtd_theme-"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "19nw3rn7awplcdrz63kg1njqwkbymfg9lwn7l2grhdyhyr2gaa8g"))))
+    (build-system python-build-system)
+    (arguments
+     `(;; With standard flags, the install phase attempts to create a zip'd
+       ;; egg file, and fails with an error: 'ZIP does not support timestamps
+       ;; before 1980'
+       #:configure-flags '("--single-version-externally-managed"
+                           "--record=sphinx-rtd-theme.txt")))
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)))
+    (inputs
+     `(("python-docutils" ,python-docutils)
+       ("python-sphinx" ,python-sphinx)))
+    (home-page "https://github.com/snide/sphinx_rtd_theme/")
+    (synopsis "ReadTheDocs.org theme for Sphinx")
+    (description "A theme for Sphinx used by ReadTheDocs.org.")
+    (license license:expat)))
+
+(define-public python2-sphinx-rtd-theme
+  (package-with-python2 python-sphinx-rtd-theme))
+
+(define-public python-cython
+  (package
+    (name "python-cython")
+    (version "0.21.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "http://cython.org/release/Cython-"
+                           version ".tar.gz"))
+       (sha256
+        (base32
+         "0ddz2l2dvcy5hdkxx4xlfiwpccvwia7ixgcy4h0pdv46a4i4vxj3"))))
+    (build-system python-build-system)
+    ;; we need the full python package and not just the python-wrapper
+    ;; because we need libpython3.3m.so
+    (inputs
+     `(("python" ,python)))
+    (arguments
+     `(#:phases
+       (alist-cons-before
+        'check 'set-HOME
+        ;; some tests require access to "$HOME/.cython"
+        (lambda* _ (setenv "HOME" "/tmp"))
+        (alist-replace
+         'check
+         (lambda _ (zero? (system* "python" "runtests.py" "-vv")))
+         %standard-phases))))
+    (home-page "http://cython.org/")
+    (synopsis "C extensions for Python")
+    (description "Cython is an optimising static compiler for both the Python
+programming language and the extended Cython programming language.  It makes
+writing C extensions for Python as easy as Python itself.")
+    (license asl2.0)))
+
+(define-public python2-cython
+  (package (inherit (package-with-python2 python-cython))
+    (name "python2-cython")
+    (inputs
+     `(("python-2" ,python-2))))) ; this is not automatically changed
+
+;; This version of numpy is missing the documentation and is only used to
+;; build matplotlib which is required to build numpy's documentation.
+(define python-numpy-bootstrap
+  (package
+    (name "python-numpy-bootstrap")
+    (version "1.9.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/numpy"
+                           "/numpy-" version ".tar.gz"))
+       (sha256
+        (base32
+         "070ybfvpgfmiz2hs94x445hvkh9dh52nyi0m8jp5kdihgvhbnx80"))))
+    (build-system python-build-system)
+    (inputs
+     `(("python-nose" ,python-nose)
+       ("atlas" ,atlas)))
+    (native-inputs
+     `(("gfortran" ,gfortran-4.8)))
+    (arguments
+     `(#:phases
+       (alist-cons-before
+        'build 'set-environment-variables
+        (lambda* (#:key inputs #:allow-other-keys)
+          (let* ((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)))
+        ;; 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(verbose=2)"))))
+         (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 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")
+    (version "2.0.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/pyparsing"
+                           "/pyparsing-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0kw4py7gn45j93q8r7bzajfrjdc3xlsn2yzln41lf9zmrghjkrq6"))))
+    (build-system python-build-system)
+    (outputs '("out" "doc"))
+    (arguments
+     `(#:tests? #f ; no test target
+       #:modules ((guix build python-build-system)
+                  (guix build utils))
+       #:phases
+       (alist-cons-after
+        'install 'install-doc
+        (lambda* (#:key outputs #:allow-other-keys)
+          (let* ((doc (string-append (assoc-ref outputs "doc")
+                                     "/share/doc/" ,name "-" ,version))
+                 (html-doc (string-append doc "/html"))
+                 (examples (string-append doc "/examples")))
+            (mkdir-p html-doc)
+            (mkdir-p examples)
+            (for-each
+             (lambda (dir tgt)
+               (map (lambda (file)
+                      (copy-file file (string-append tgt "/" (basename file))))
+                    (find-files dir ".*")))
+             (list "docs" "htmldoc" "examples")
+             (list doc html-doc examples))))
+        %standard-phases)))
+    (home-page "http://pyparsing.wikispaces.com")
+    (synopsis "Python parsing class library")
+    (description
+     "The pyparsing module is an alternative approach to creating and
+executing simple grammars, vs. the traditional lex/yacc approach, or the use
+of regular expressions.  The pyparsing module provides a library of classes
+that client code uses to construct the grammar directly in Python code.")
+    (license license:expat)))
+
+(define-public python2-pyparsing
+  (package-with-python2 python-pyparsing))
+
+(define-public python-numpydoc
+  (package
+    (name "python-numpydoc")
+    (version "0.5")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://pypi.python.org/packages/source/n/numpydoc/numpydoc-"
+             version ".tar.gz"))
+       (sha256
+        (base32
+         "0d4dnifaxkll50jx6czj05y8cb4ny60njd2wz299sj2jxfy51w4k"))))
+    (build-system python-build-system)
+    (inputs
+     `(("python-setuptools" ,python-setuptools)
+       ("python-docutils" ,python-docutils)
+       ("python-sphinx" ,python-sphinx)
+       ("python-nose" ,python-nose)))
+    (home-page "https://pypi.python.org/pypi/numpydoc")
+    (synopsis
+     "Numpy's Sphinx extensions")
+    (description
+     "Sphinx extension to support docstrings in Numpy format.")
+    (license bsd-2)))
+
+(define-public python2-numpydoc
+  (package
+    (inherit (package-with-python2 python-numpydoc))
+    ;; With python-2 1 test (out of 30) fails because it doesn't find
+    ;; matplotlib.  With python-3 it seems to detect at run-time the absence
+    ;; of matplotlib.
+    (arguments `(#:tests? #f
+                 #:python ,python-2))))
+
+(define-public python-matplotlib
+  (package
+    (name "python-matplotlib")
+    (version "1.4.2")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/matplotlib"
+                           "/matplotlib-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0m6v9nwdldlwk22gcd339zg6mny5m301fxgks7z8sb8m9wawg8qp"))))
+    (build-system python-build-system)
+    (outputs '("out" "doc"))
+    (propagated-inputs ; the following packages are all needed at run time
+     `(("python-pyparsing" ,python-pyparsing)
+       ("python-pygobject" ,python-pygobject)
+       ("gobject-introspection" ,gobject-introspection)
+       ;; The 'gtk+' package (and 'gdk-pixbuf', 'atk' and 'pango' propagated
+       ;; from 'gtk+') provides the required 'typelib' files used by
+       ;; 'gobject-introspection'. The location of these files is set with the
+       ;; help of the environment variable GI_TYPELIB_PATH. At build time this
+       ;; is done automatically by a 'native-search-path' procedure. However,
+       ;; at run-time the user must set this variable as follows:
+       ;;
+       ;; export GI_TYPELIB_PATH=~/.guix-profile/lib/girepository-1.0
+       ("gtk+" ,gtk+)
+       ;; From version 1.4.0 'matplotlib' makes use of 'cairocffi' instead of
+       ;; 'pycairo'. However, 'pygobject' makes use of a 'pycairo' 'context'
+       ;; object. For this reason we need to import both libraries.
+       ;; https://pythonhosted.org/cairocffi/cffi_api.html#converting-pycairo
+       ("python-pycairo" ,python-pycairo)
+       ("python-cairocffi" ,python-cairocffi)))
+    (inputs
+     `(("python-setuptools" ,python-setuptools)
+       ("python-dateutil" ,python-dateutil-2)
+       ("python-six" ,python-six)
+       ("python-pytz" ,python-pytz)
+       ("python-numpy" ,python-numpy-bootstrap)
+       ("python-sphinx" ,python-sphinx)
+       ("python-numpydoc" ,python-numpydoc)
+       ("python-nose" ,python-nose)
+       ("python-mock" ,python-mock)
+       ("libpng" ,libpng)
+       ("imagemagick" ,imagemagick)
+       ("freetype" ,freetype)
+       ("cairo" ,cairo)
+       ("glib" ,glib)
+       ("python-pillow" ,python-pillow)
+       ;; FIXME: Add backends when available.
+       ;("python-wxpython" ,python-wxpython)
+       ;("python-pyqt" ,python-pyqt)
+       ))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("texlive" ,texlive)
+       ("texinfo" ,texinfo)))
+    (arguments
+     `(#:phases
+       (alist-cons-before
+        'build 'configure-environment
+        (lambda* (#:key outputs inputs #:allow-other-keys)
+          (let ((cairo (assoc-ref inputs "cairo"))
+                (gtk+ (assoc-ref inputs "gtk+")))
+            ;; Setting these directories in the 'basedirlist' of 'setup.cfg'
+            ;; has not effect.
+            (setenv "LD_LIBRARY_PATH"
+                    (string-append cairo "/lib:" gtk+ "/lib"))
+            (setenv "HOME" (getcwd))
+            (call-with-output-file "setup.cfg"
+              (lambda (port)
+                (format port "[rc_options]~%
+backend = GTK3Agg~%")))))
+        (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 "-" ,version))
+                  (info (string-append data "/info"))
+                  (html (string-append doc "/html")))
+             (with-directory-excursion "doc"
+               ;; Install and set UTF-8 locale to avoid an encoding error.
+               (setenv "LOCPATH" (getcwd))
+               (system* "localedef" "--no-archive"
+                        "--prefix" (getcwd) "-i" "en_US"
+                        "-f" "UTF-8" "./en_US.UTF-8")
+               (setenv "LANG" "en_US.UTF-8")
+               ;; Produce pdf in 'A4' format.
+               (substitute* (find-files "." "conf\\.py")
+                 (("latex_paper_size = 'letter'")
+                  "latex_paper_size = 'a4'"))
+               (mkdir-p html)
+               (mkdir-p info)
+               ;; The doc recommends to run the 'html' target twice.
+               (system* "python" "make.py" "html")
+               (system* "python" "make.py" "html")
+               (system* "python" "make.py" "latex")
+               (system* "python" "make.py" "texinfo")
+               (copy-file "build/texinfo/matplotlib.info"
+                          (string-append info "/matplotlib.info"))
+               (copy-file "build/latex/Matplotlib.pdf"
+                          (string-append doc "/Matplotlib.pdf"))
+               (copy-recursively "build/html" html))))
+        %standard-phases))))
+    (home-page "http://matplotlib.org")
+    (synopsis "2D plotting library for Python")
+    (description
+     "Matplotlib is a Python 2D plotting library which produces publication
+quality figures in a variety of hardcopy formats and interactive environments
+across platforms.  Matplotlib can be used in Python scripts, the python and
+ipython shell, web application servers, and six graphical user interface
+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 python-scipy
+  (package
+    (name "python-scipy")
+    (version "0.15.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/scipy"
+                           "/scipy-" version ".tar.xz"))
+       (sha256
+        (base32
+         "0fsqi05s035d7p6s8h3h2pvk1axias16chy17rw9l1bxvrfhmncf"))))
+    (build-system python-build-system)
+    (inputs
+     `(("python-numpy" ,python-numpy)
+       ("python-matplotlib" ,python-matplotlib)
+       ("python-pyparsing" ,python-pyparsing)
+       ("python-nose" ,python-nose)
+       ("python-sphinx" ,python-sphinx)
+       ("atlas" ,atlas)))
+    (native-inputs
+     `(("gfortran" ,gfortran-4.8)
+       ("texlive" ,texlive)
+       ("perl" ,perl)))
+    (outputs '("out" "doc"))
+    (arguments
+     `(#:phases
+       (alist-cons-before
+        'build 'set-environment-variables
+        (lambda* (#:key inputs #:allow-other-keys)
+          (let* ((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)))
+        (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 "-" ,version))
+                  (html (string-append doc "/html"))
+                  (pyver ,(string-append "PYVER=")))
+             (with-directory-excursion "doc"
+               ;; Install and set UTF-8 locale to avoid an encoding error.
+               (setenv "LOCPATH" (getcwd))
+               (system* "localedef" "--no-archive"
+                        "--prefix" (getcwd) "-i" "en_US"
+                        "-f" "UTF-8" "./en_US.UTF-8")
+               (setenv "LANG" "en_US.UTF-8")
+               ;; Fix generation of images for mathematical expressions.
+               (substitute* (find-files "source" "conf\\.py")
+                 (("pngmath_use_preview = True")
+                  "pngmath_use_preview = False"))
+               (mkdir-p html)
+               (system* "make" "html" pyver)
+               (system* "make" "latex" "PAPER=a4" pyver)
+               (system* "make" "-C" "build/latex" "all-pdf" "PAPER=a4" pyver)
+               (copy-file "build/latex/scipy-ref.pdf"
+                          (string-append doc "/scipy-ref.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 "." ".*"))))))
+         ;; 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 scipy; scipy.test()"))))
+          (alist-delete
+           'check
+           %standard-phases))))))
+    (home-page "http://www.scipy.org/")
+    (synopsis "The Scipy library provides efficient numerical routines")
+    (description "The SciPy library is one of the core packages that make up
+the SciPy stack.  It provides many user-friendly and efficient numerical
+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 python-sqlalchemy
+  (package
+    (name "python-sqlalchemy")
+    (version "0.9.7")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://pypi.python.org/packages/source/S/"
+                          "SQLAlchemy/SQLAlchemy-" version ".tar.gz"))
+      (sha256
+       (base32
+        "059ayifj5l08v6vv56anhyibyllscn10dlzr2fcw68gz1hfjdzsz"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("python-cython" ,python-cython) ;for c extensions
+       ("python-pytest" ,python-pytest)
+       ("python-mock"   ,python-mock))) ;for tests
+    (arguments
+     `(#:phases (alist-replace
+                 'check
+                 (lambda _ (zero? (system* "py.test")))
+                 %standard-phases)))
+    (home-page "http://www.sqlalchemy.org")
+    (synopsis "Database abstraction library")
+    (description
+     "SQLAlchemy is the Python SQL toolkit and Object Relational Mapper that
+gives application developers the full power and flexibility of SQL.  It
+provides a full suite of well known enterprise-level persistence patterns,
+designed for efficient and high-performing database access, adapted into a
+simple and Pythonic domain language.")
+    (license x11)))
+
+(define-public python2-sqlalchemy
+  (package-with-python2 python-sqlalchemy))
+
+(define-public python-distutils-extra
+  (package
+    (name "python-distutils-extra")
+    (version "2.38")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://launchpad.net/python-distutils-extra/trunk/"
+                          version "/+download/python-distutils-extra-"
+                          version ".tar.gz"))
+      (sha256
+       (base32
+        "0lx15kcbby9zisx33p2h5hgakgwh2bvh0ibag8z0px4j6ifhs41x"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)))
+    (home-page "https://launchpad.net/python-distutils-extra/")
+    (synopsis "Enhancements to Python's distutils")
+    (description
+     "The python-distutils-extra module enables you to easily integrate
+gettext support, themed icons, and scrollkeeper-based documentation into
+Python's distutils.")
+    (license gpl2)))
+
+(define-public python2-distutils-extra
+  (package-with-python2 python-distutils-extra))
+
+(define-public python2-elib.intl
+  (package
+    (name "python2-elib.intl")
+    (version "0.0.3")
+    (source
+     (origin
+       ;; This project doesn't tag releases or publish tarballs, so we take
+       ;; source from a (semi-arbitrary, i.e. latest as of now) git commit.
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/dieterv/elib.intl.git")
+             (commit "d09997cfef")))
+       (sha256
+        (base32
+         "0y7vzff9xgbnaay7m0va1arl6g68ncwrvbgwl7jqlclsahzzb09d"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("python2-setuptools" ,python2-setuptools)))
+    (arguments
+     ;; incompatible with Python 3 (exception syntax)
+     `(#:python ,python-2
+       #:tests? #f
+       ;; With standard flags, the install phase attempts to create a zip'd
+       ;; egg file, and fails with an error: 'ZIP does not support timestamps
+       ;; before 1980'
+       #:configure-flags '("--single-version-externally-managed"
+                           "--record=elib.txt")))
+    (home-page "https://github.com/dieterv/elib.intl")
+    (synopsis "Enhanced internationalization for Python")
+    (description
+     "The elib.intl module provides enhanced internationalization (I18N)
+services for your Python modules and applications.")
+    (license lgpl3+)))
+
+(define-public python-pillow
+  (package
+    (name "python-pillow")
+    (version "2.6.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://pypi.python.org/packages/source/P/"
+                           "Pillow/Pillow-" version ".tar.gz"))
+       (sha256
+        (base32
+         "0iw36c73wkhz88wa78v6l43llsb080ihw8yq7adhfqxdib7l4hzr"))))
+    (build-system python-build-system)
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)
+       ("python-nose"       ,python-nose)))
+    (inputs
+     `(("lcms"     ,lcms)
+       ("zlib"     ,zlib)
+       ("libjpeg"  ,libjpeg)
+       ("openjpeg" ,openjpeg)
+       ("libtiff"  ,libtiff)))
+    (propagated-inputs
+     `(;; Used at runtime for pkg_resources
+       ("python-setuptools" ,python-setuptools)))
+    (arguments
+     `(#:phases (alist-cons-after
+                 'install 'check-installed
+                 (lambda _
+                   (begin
+                     (setenv "HOME" (getcwd))
+                     (and (zero? (system* "python" "selftest.py" "--installed"))
+                          (zero? (system* "python" "test-installed.py")))))
+                 (alist-delete 'check %standard-phases))))
+    (home-page "https://pypi.python.org/pypi/Pillow")
+    (synopsis "Fork of the Python Imaging Library")
+    (description
+     "The Python Imaging Library adds image processing capabilities to your
+Python interpreter.  This library provides extensive file format support, an
+efficient internal representation, and fairly powerful image processing
+capabilities.  The core image library is designed for fast access to data
+stored in a few basic pixel formats.  It should provide a solid foundation for
+a general image processing tool.")
+    (license (x11-style
+              "http://www.pythonware.com/products/pil/license.htm"
+              "The PIL Software License"))))
+
+(define-public python2-pillow
+  (package-with-python2 python-pillow))
+
+(define-public python-pycparser
+  (package
+    (name "python-pycparser")
+    (version "2.10")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://pypi.python.org/packages/source/p/"
+                          "pycparser/pycparser-" version ".tar.gz"))
+      (sha256
+       (base32
+        "0v5qfq03yvd1pi0dwlgfai0p3dh9bq94pydn19c4pdn0c6v9hzcm"))))
+    (outputs '("out" "doc"))
+    (build-system python-build-system)
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("python-setuptools" ,python-setuptools)))
+    (arguments
+     `(#:phases
+       (alist-replace
+        'check
+        (lambda _
+          (with-directory-excursion "tests"
+            (zero? (system* "python" "all_tests.py"))))
+        (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 "-" ,version))
+                  (examples (string-append doc "/examples")))
+             (mkdir-p examples)
+             (for-each (lambda (file)
+                         (copy-file (string-append "." file)
+                                    (string-append doc file)))
+                       '("/README.rst" "/CHANGES" "/LICENSE"))
+             (copy-recursively "examples" examples)))
+         %standard-phases))))
+    (home-page "https://github.com/eliben/pycparser")
+    (synopsis "C parser in Python")
+    (description
+     "Pycparser is a complete parser of the C language, written in pure Python
+using the PLY parsing library.  It parses C code into an AST and can serve as
+a front-end for C compilers or analysis tools.")
+    (license bsd-3)))
+
+(define-public python2-pycparser
+  (package-with-python2 python-pycparser))
+
+(define-public python-cffi
+  (package
+    (name "python-cffi")
+    (version "0.8.6")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://pypi.python.org/packages/source/c/"
+                          "cffi/cffi-" version ".tar.gz"))
+      (sha256
+       (base32 "0406j3sgndmx88idv5zxkkrwfqxmjl18pj8gf47nsg4ymzixjci5"))))
+    (build-system python-build-system)
+    (outputs '("out" "doc"))
+    (inputs
+     `(("libffi" ,libffi)))
+    (propagated-inputs ; required at run-time
+     `(("python-pycparser" ,python-pycparser)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("python-sphinx" ,python-sphinx)
+       ("python-setuptools" ,python-setuptools)))
+    (arguments
+     `(#:tests? #f ; FIXME: requires pytest
+       #: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 "-" ,version))
+                 (html (string-append doc "/html")))
+            (with-directory-excursion "doc"
+              (system* "make" "html")
+              (mkdir-p html)
+              (copy-recursively "build/html" html))
+            (copy-file "LICENSE" (string-append doc "/LICENSE"))))
+        %standard-phases)))
+    (home-page "http://cffi.readthedocs.org")
+    (synopsis "Foreign function interface for Python")
+    (description
+     "Foreign Function Interface for Python calling C code.")
+    (license license:expat)))
+
+(define-public python2-cffi
+  (package-with-python2 python-cffi))
+
+(define-public python-xcffib
+  (package
+    (name "python-xcffib")
+    (version "0.1.9")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://pypi.python.org/packages/source/x/"
+                          "xcffib/xcffib-" version ".tar.gz"))
+      (sha256
+       (base32
+        "0655hzxv57h1a9ja9kwp0ichbkhf3djw32k33d66xp0q37dq2y81"))))
+    (build-system python-build-system)
+    (inputs
+     `(("libxcb" ,libxcb)
+       ("python-six" ,python-six)))
+    (native-inputs
+     `(("python-setuptools" ,python-setuptools)))
+    (propagated-inputs
+     `(("python-cffi" ,python-cffi))) ; used at run time
+    (arguments
+     `(#:phases
+       (alist-cons-after
+        'install 'install-doc
+        (lambda* (#:key outputs #:allow-other-keys)
+          (let ((doc (string-append (assoc-ref outputs "out") "/share"
+                                    "/doc/" ,name "-" ,version)))
+            (mkdir-p doc)
+            (copy-file "README.md"
+                       (string-append doc "/README.md"))))
+        %standard-phases)))
+    (home-page "https://github.com/tych0/xcffib")
+    (synopsis "XCB Python bindings")
+    (description
+     "Xcffib is a replacement for xpyb, an XCB Python bindings.  It adds
+support for Python 3 and PyPy.  It is based on cffi.")
+    (license license:expat)))
+
+(define-public python2-xcffib
+  (package-with-python2 python-xcffib))
+
+(define-public python-cairocffi
+  (package
+    (name "python-cairocffi")
+    (version "0.6")
+    (source
+     (origin
+      (method url-fetch)
+      ;; The archive on pypi is missing the 'utils' directory!
+      (uri (string-append "https://github.com/SimonSapin/cairocffi/archive/v"
+                          version ".tar.gz"))
+      (sha256
+       (base32
+        "03w5p62sp3nqiccx864sbq0jvh7946277jqx3rcc3dch5xwfvv51"))))
+    (build-system python-build-system)
+    (outputs '("out" "doc"))
+    (inputs
+     `(("gdk-pixbuf" ,gdk-pixbuf)
+       ("cairo" ,cairo)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("python-sphinx" ,python-sphinx)
+       ("python-docutils" ,python-docutils)
+       ("python-setuptools" ,python-setuptools)))
+    (propagated-inputs
+     `(("python-xcffib" ,python-xcffib))) ; used at run time
+    (arguments
+     `(#:phases
+       (alist-cons-after
+        'install 'install-doc
+        (lambda* (#:key inputs outputs #:allow-other-keys)
+          (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
+                 (doc (string-append data "/doc/" ,name "-" ,version))
+                 (html (string-append doc "/html")))
+            (setenv "LD_LIBRARY_PATH"
+                    (string-append (assoc-ref inputs "cairo") "/lib" ":"
+                                   (assoc-ref inputs "gdk-pixbuf") "/lib"))
+            (setenv "LANG" "en_US.UTF-8")
+            (mkdir-p html)
+            (for-each (lambda (file)
+                        (copy-file (string-append "." file)
+                                   (string-append doc file)))
+                      '("/README.rst" "/CHANGES" "/LICENSE"))
+            (system* "python" "setup.py" "build_sphinx")
+            (copy-recursively "docs/_build/html" html)))
+        %standard-phases)))
+    (home-page "https://github.com/SimonSapin/cairocffi")
+    (synopsis "Python bindings and object-oriented API for Cairo")
+    (description
+     "Cairocffi is a CFFI-based drop-in replacement for Pycairo, a set of
+Python bindings and object-oriented API for cairo.  Cairo is a 2D vector
+graphics library with support for multiple backends including image buffers,
+PNG, PostScript, PDF, and SVG file output.")
+    (license bsd-3)))
+
+(define-public python2-cairocffi
+  (package-with-python2 python-cairocffi))
+
+(define-public python-ipython
+  (package
+    (name "python-ipython")
+    (version "2.3.1")
+    (source
+     (origin
+      (method url-fetch)
+      (uri (string-append "https://pypi.python.org/packages/source/i/"
+                          "ipython/ipython-" version ".tar.gz"))
+      (sha256
+       (base32 "1764gi5m3ff481rjk336cw6i2h4zlc0nxam9rc5m8m7yl9m4d61y"))))
+    (build-system python-build-system)
+    (outputs '("out" "doc"))
+    ;; FIXME: add optional dependencies when available: pyzmq, tornado, ...
+    (inputs
+     `(("readline" ,readline)
+       ("python-matplotlib" ,python-matplotlib)
+       ("python-numpy" ,python-numpy-bootstrap)
+       ("python-numpydoc" ,python-numpydoc)
+       ("python-nose" ,python-nose)))
+    (native-inputs
+     `(("pkg-config" ,pkg-config)
+       ("python-sphinx" ,python-sphinx)
+       ("texlive" ,texlive)
+       ("texinfo" ,texinfo)
+       ("python-setuptools" ,python-setuptools)))
+    (arguments
+     `(#:phases
+       (alist-cons-after
+        'install 'install-doc
+        (lambda* (#:key inputs outputs #:allow-other-keys)
+          (let* ((data (string-append (assoc-ref outputs "doc") "/share"))
+                 (doc (string-append data "/doc/" ,name "-" ,version))
+                 (html (string-append doc "/html"))
+                 (man1 (string-append data "/man/man1"))
+                 (info (string-append data "/info"))
+                 (examples (string-append doc "/examples")))
+            (setenv "LANG" "en_US.UTF-8")
+            (with-directory-excursion "docs"
+              ;; FIXME: html and pdf fail to build without optional pyzmq
+              ;(system* "make" "html")
+              ;(system* "make" "pdf" "PAPER=a4")
+              (system* "make" "info"))
+            (copy-recursively "docs/man" man1)
+            (copy-recursively "examples" examples)
+            ;; (copy-recursively "docs/build/html" html)
+            ;; (copy-file "docs/build/latex/ipython.pdf"
+            ;;            (string-append doc "/ipython.pdf"))
+            (mkdir-p info)
+            (copy-file "docs/build/texinfo/ipython.info"
+                       (string-append info "/ipython.info"))
+            (copy-file "COPYING.rst" (string-append doc "/COPYING.rst"))))
+        ;; Tests can only be run after the library has been installed and not
+        ;; within the source directory.
+        (alist-cons-after
+         'install 'check
+         (lambda* (#:key outputs #:allow-other-keys)
+           ;; The test procedure appears to miss the fact that some optional
+           ;; dependencies are missing.
+           ;; (with-directory-excursion "/tmp"
+           ;;   (zero? (system* (string-append (assoc-ref outputs "out")
+           ;;                                  "/bin/iptest"))))
+           #t)
+         (alist-delete
+          'check
+          %standard-phases)))))
+    (home-page "http://ipython.org")
+    (synopsis "IPython is a tool for interactive computing in Python")
+    (description
+     "IPython provides a rich architecture for interactive computing with:
+Powerful interactive shells, a browser-based notebook, support for interactive
+data visualization, embeddable interpreters and tools for parallel
+computing.")
+    (license bsd-3)))
+
+(define-public python2-ipython
+  (let ((ipython (package-with-python2 python-ipython)))
+    (package (inherit ipython)
+      ;; Make sure we use custom python2-NAME packages.
+      (inputs
+       `(("python2-numpydoc" ,python2-numpydoc)
+         ("python2-matplotlib" ,python2-matplotlib)
+         ,@(alist-delete "python-numpydoc"
+                         (alist-delete "python-matplotlib"
+                                       (package-inputs ipython))))))))
+
+(define-public python-isodate
+  (package
+    (name "python-isodate")
+    (version "0.5.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/i/isodate/isodate-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "1yqjn0is0p64cmk9xhq4hc6q06jk86d60kg2jws58d78q0qysami"))))
+    (build-system python-build-system)
+    (inputs
+      `(("python-setuptools" ,python-setuptools)))
+    (home-page
+      "http://cheeseshop.python.org/pypi/isodate")
+    (synopsis
+      "Python date parser and formatter")
+    (description
+      "Python-isodate is a python module for parsing and formatting
+ISO 8601 dates, time and duration.")
+    (license bsd-3)))
+
+(define-public python2-isodate
+  (package-with-python2 python-isodate))
+
+(define-public python-html5lib
+  (package
+    (name "python-html5lib")
+    (version "1.0b3")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/h/html5lib/html5lib-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "1l5i6xzckzx4hnh9qzv9q3kyhkgjx2hsi2k9srgci3qizjmvp6ln"))))
+    (build-system python-build-system)
+    (propagated-inputs
+      `(("python-six" ,python-six))) ; required to "import html5lib"
+    (inputs
+      `(("python-setuptools" ,python-setuptools)))
+    (arguments
+     `(#:test-target "check"))
+    (home-page
+      "https://github.com/html5lib/html5lib-python")
+    (synopsis
+      "Python HTML parser based on the WHATWG HTML specifcation")
+    (description
+      "Html5lib is an HTML parser based on the WHATWG HTML specifcation
+and written in Python.")
+    (license license:expat)))
+
+(define-public python2-html5lib
+  (package-with-python2 python-html5lib))
+
+(define-public python-urwid
+  (package
+    (name "python-urwid")
+    (version "1.3.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://pypi.python.org/packages/source/u/urwid/urwid-"
+             version ".tar.gz"))
+       (sha256
+        (base32
+         "18mb0yy94sjc434rd61m2sfnw27sa0nyrszpj5a9r9zh7fnlzw19"))))
+    (build-system python-build-system)
+    (native-inputs `(("python-setuptools" ,python-setuptools)))
+    (home-page "http://urwid.org")
+    (synopsis "Console user interface library for Python")
+    (description
+     "Urwid is a curses-based UI/widget library for Python.  It includes many
+features useful for text console applications.")
+    (license lgpl2.1+)))
+
+(define-public python2-urwid
+  (package-with-python2 python-urwid))
+
+(define-public python-dbus
+  (package
+    (name "python-dbus")
+    (version "1.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "http://dbus.freedesktop.org/releases/dbus-python/dbus-python-"
+             version ".tar.gz"))
+       (sha256
+        (base32 "1py62qir966lvdkngg0v8k1khsqxwk5m4s8nflpk1agk5f5nqb71"))))
+    (build-system gnu-build-system)
+    (native-inputs
+     `(("pkg-config" ,pkg-config)))
+    (inputs
+     `(("python" ,python)
+       ("dbus" ,dbus)
+       ("dbus-glib" ,dbus-glib)
+       ("glib" ,glib)))
+    (synopsis "Python bindings for D-bus")
+    (description "python-dbus provides bindings for libdbus, the reference
+implementation of D-Bus.")
+    (home-page "http://www.freedesktop.org/wiki/Software/DBusBindings/")
+    (license license:expat)))
+
+(define-public python2-dbus
+  (package (inherit python-dbus)
+    (name "python2-dbus")
+    (inputs `(("python" ,python-2)
+              ,@(alist-delete "python"
+                              (package-inputs python-dbus)
+                              equal?)))
+    ;; FIXME: on Python 2, the test_utf8 fails with:
+    ;; "ValueError: unichr() arg not in range(0x10000) (narrow Python build)"
+    (arguments `(#:tests? #f))))
+
+(define-public python-apsw
+  (package
+    (name "python-apsw")
+    (version "3.8.7.3-r1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/a/apsw/apsw-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "1rgxdypg7hym0qny15rx5khrghx9fkppfgsfa2s8lg917924mv7l"))))
+    (build-system python-build-system)
+    (inputs
+      `(("python-setuptools" ,python-setuptools)
+        ("sqlite" ,sqlite)))
+    (arguments
+     `(#:phases
+        ;; swap check and install phases
+        (alist-cons-after
+         'install 'check
+         (assoc-ref %standard-phases 'check)
+         (alist-delete
+          'check
+          %standard-phases))))
+    (home-page "https://github.com/rogerbinns/apsw/")
+    (synopsis "Another Python SQLite Wrapper")
+    (description "APSW is a Python wrapper for the SQLite
+embedded relational database engine.  In contrast to other wrappers such as
+pysqlite it focuses on being a minimal layer over SQLite attempting just to
+translate the complete SQLite API into Python.")
+    (license license:zlib)))
+
+(define-public python2-apsw
+  (package-with-python2 python-apsw))
+
+(define-public python-lxml
+  (package
+    (name "python-lxml")
+    (version "3.4.2")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/l/lxml/lxml-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "0pd23qz8vms1mgm41p96h4vac5y91igs4wr9640gnvxgk019kmf7"))))
+    (build-system python-build-system)
+    (inputs
+      `(("libxml2" ,libxml2)
+        ("libxslt" ,libxslt)
+        ("python-setuptools" ,python-setuptools)))
+    (home-page "http://lxml.de/")
+    (synopsis
+      "Python XML processing library")
+    (description
+      "The lxml XML toolkit is a Pythonic binding for the C libraries
+libxml2 and libxslt.")
+    (license bsd-3))) ; and a few more, see LICENSES.txt
+
+(define-public python2-lxml
+  (package-with-python2 python-lxml))
+
+(define-public python-pillow
+  (package
+    (name "python-pillow")
+    (version "2.7.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/P/Pillow/Pillow-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "1y0rysgd7vqpl5lh0lsra7j2k30azwxqlh5jnqk1i0pmfc735s96"))))
+    (build-system python-build-system)
+    (inputs
+      `(("freetype" ,freetype)
+        ("lcms" ,lcms)
+        ("libjpeg" ,libjpeg)
+        ("libtiff" ,libtiff)
+        ("openjpeg" ,openjpeg)
+        ("python-setuptools" ,python-setuptools)
+        ("zlib" ,zlib)))
+    (arguments
+     `(#:tests? #f)) ; no check target
+    (home-page "http://python-pillow.github.io/")
+    (synopsis "Pillow fork of Python Imaging Library")
+    (description "Pillow is a fork of the Python Imaging Library (PIL).")
+    ;; PIL license, see
+    ;; http://www.pythonware.com/products/pil/license.htm
+    (license (x11-style
+               "file://PKG-INFO"
+               "See http://www.pythonware.com/products/pil/license.htm"))))
+
+(define-public python2-pillow
+  (package-with-python2 python-pillow))
+
+(define-public python2-pil
+  (package
+    (name "python2-pil")
+    (version "1.1.7")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "http://effbot.org/downloads/Imaging-"
+              version ".tar.gz"))
+        (sha256
+          (base32
+            "04aj80jhfbmxqzvmq40zfi4z3cw6vi01m3wkk6diz3lc971cfnw9"))))
+    (build-system python-build-system)
+    (inputs
+      `(("freetype" ,freetype)
+        ("libjpeg" ,libjpeg)
+        ("libtiff" ,libtiff)
+        ("python-setuptools" ,python-setuptools)
+        ("zlib" ,zlib)))
+    (arguments
+     ;; Only the fork python-pillow works with Python 3.
+     `(#:python ,python-2
+       #:tests? #f ; no check target
+       #:phases
+         (alist-cons-before
+          'build 'configure
+          ;; According to README and setup.py, manual configuration is
+          ;; the preferred way of "searching" for inputs.
+          ;; lcms is not found, TCL_ROOT refers to the unavailable tkinter.
+          (lambda* (#:key inputs #:allow-other-keys)
+            (let ((jpeg (assoc-ref inputs "libjpeg"))
+                  (zlib (assoc-ref inputs "zlib"))
+                  (tiff (assoc-ref inputs "libtiff"))
+                  (freetype (assoc-ref inputs "freetype")))
+              (substitute* "setup.py"
+                (("JPEG_ROOT = None")
+                 (string-append "JPEG_ROOT = libinclude(\"" jpeg "\")"))
+                (("ZLIB_ROOT = None")
+                 (string-append "ZLIB_ROOT = libinclude(\"" zlib "\")"))
+                (("TIFF_ROOT = None")
+                 (string-append "TIFF_ROOT = libinclude(\"" tiff "\")"))
+                (("FREETYPE_ROOT = None")
+                 (string-append "FREETYPE_ROOT = libinclude(\""
+                                freetype "\")")))))
+          %standard-phases)))
+    (home-page "http://www.pythonware.com/products/pil/")
+    (synopsis "Python Imaging Library")
+    (description "The Python Imaging Library (PIL) adds image processing
+capabilities to the Python interpreter.")
+    (license (x11-style
+               "file://README"
+               "See 'README' in the distribution."))))
+
+(define-public python2-cssutils
+  (package
+    (name "python2-cssutils")
+    (version "1.0")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/c/cssutils/cssutils-"
+              version
+              ".zip"))
+        (sha256
+          (base32
+            "1bwim1353r4hqiir73sn4sc43y7ymh09qx0kly7vj048blppc125"))))
+    (build-system python-build-system)
+    (native-inputs
+      `(("python2-mock" ,python2-mock) ; for the tests
+        ("unzip" ,unzip))) ; for unpacking the source
+    (inputs
+      `(("python2-setuptools" ,python2-setuptools)))
+    (arguments
+     `(#:python ,python-2 ; Otherwise tests fail with a syntax error.
+       #:tests? #f ; The tests apparently download an external URL.
+       #:phases
+       (alist-replace
+        'unpack
+        (lambda* (#:key source #:allow-other-keys)
+          (and (zero? (system* "unzip" source))
+               (chdir "cssutils-1.0")))
+        %standard-phases)))
+    (home-page "http://cthedot.de/cssutils/")
+    (synopsis
+      "CSS Cascading Style Sheets library for Python")
+    (description
+      "Cssutils is a Python package for parsing and building CSS
+Cascading Style Sheets.  Currently it provides a DOM only and no rendering
+options.")
+    (license lgpl3+)))
+
+(define-public python-cssselect
+  (package
+    (name "python-cssselect")
+    (version "0.9.1")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/c/cssselect/cssselect-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "10h623qnp6dp1191jri7lvgmnd4yfkl36k9smqklp1qlf3iafd85"))))
+    (build-system python-build-system)
+    (inputs
+      `(("python-setuptools" ,python-setuptools)))
+    (arguments
+     ;; tests fail with message
+     ;; AttributeError: 'module' object has no attribute 'tests'
+     `(#:tests? #f))
+    (home-page
+      "https://pythonhosted.org/cssselect/")
+    (synopsis
+      "CSS3 selector parser and translator to XPath 1.0")
+    (description
+      "Cssselect ia a Python module that parses CSS3 Selectors and translates
+them to XPath 1.0 expressions.  Such expressions can be used in lxml or
+another XPath engine to find the matching elements in an XML or HTML document.")
+    (license bsd-3)))
+
+(define-public python2-cssselect
+  (package-with-python2 python-cssselect))
+
+(define-public python-netifaces
+  (package
+    (name "python-netifaces")
+    (version "0.10.4")
+    (source
+      (origin
+        (method url-fetch)
+        (uri (string-append
+              "https://pypi.python.org/packages/source/n/netifaces/netifaces-"
+              version
+              ".tar.gz"))
+        (sha256
+          (base32
+            "1plw237a4zib4z8s62g0mrs8gm3kjfrp5sxh6bbk9nl3rdls2mln"))))
+    (build-system python-build-system)
+    (inputs
+      `(("python-setuptools" ,python-setuptools)))
+    (home-page
+      "https://bitbucket.org/al45tair/netifaces")
+    (synopsis
+      "Python module for portable network interface information")
+    (description
+      "Netifaces is a Python module providing information on network
+interfaces in an easy and portable manner.")
+    (license license:expat)))
+
+(define-public python2-netifaces
+  (package-with-python2 python-netifaces))