gnu: Add cl-ana.statistical-learning.
[jackhill/guix/guix.git] / gnu / packages / libffi.scm
index 3f7bb4f..b61dbc8 100644 (file)
@@ -1,11 +1,12 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch>
-;;; Copyright © 2015 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
+;;; Copyright © 2015, 2019 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
 ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com>
-;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2017, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -32,6 +33,7 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages ruby)
+  #:use-module (gnu packages sphinx)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
   #:use-module (guix build-system ruby))
@@ -92,14 +94,12 @@ conversions for values passed between the two languages.")
        (base32 "1x3lrj928dcxx1k8k9gf3s4s3jwvzv8mc3kkyg1g7c3a1sc1f3z9"))
       (patches (search-patches "python-cffi-x87-stack-clean.patch"))))
     (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-pytest" ,python-pytest)))
     (arguments
      `(#:modules ((ice-9 ftw)
@@ -128,42 +128,84 @@ conversions for values passed between the two languages.")
                (("'cc testownlib") "'gcc testownlib"))
              (invoke "py.test" "-v" "c/" "testing/")
              #t))
+         (add-before 'check 'patch-paths-of-dynamically-loaded-libraries
+           (lambda* (#:key inputs #:allow-other-keys)
+             ;; Shared libraries should be referred by their absolute path as
+             ;; using find_library or the like with their name fail when the
+             ;; resolved .so object is a linker script rather than an ELF
+             ;; binary (this is a limitation of the ctype library of Python).
+             (let* ((glibc (assoc-ref inputs "libc"))
+                    (libm (string-append glibc "/lib/libm.so.6"))
+                    (libc (string-append glibc "/lib/libc.so.6")))
+               (substitute* '("testing/cffi0/test_function.py"
+                              "testing/cffi0/test_parsing.py"
+                              "testing/cffi0/test_unicode_literals.py"
+                              "testing/cffi0/test_zdistutils.py"
+                              "testing/cffi1/test_recompiler.py")
+                 (("lib_m = ['\"]{1}m['\"]{1}")
+                  (format #f "lib_m = '~a'" libm)))
+               (substitute* '("testing/cffi0/test_verify.py"
+                              "testing/cffi1/test_verify1.py")
+                 (("lib_m = \\[['\"]{1}m['\"]{1}\\]")
+                  (format #f "lib_m = ['~a']" libm)))
+               (substitute* "c/test_c.py"
+                 (("find_and_load_library\\(['\"]{1}c['\"]{1}")
+                  (format #f "find_and_load_library('~a'" libc)))
+               #t)))
          (add-before 'check 'disable-failing-test
            ;; This is assumed to be a libffi issue:
            ;; https://bitbucket.org/cffi/cffi/issues/312/tests-failed-with-armv8
            (lambda _
              (substitute* "testing/cffi0/test_ownlib.py"
                (("ret.left") "ownlib.left"))
-             #t))
-         (add-after 'install 'install-doc
-           (lambda* (#:key outputs (make-flags '())  #:allow-other-keys)
-             (let* ((doc (string-append (assoc-ref outputs "doc")
-                                        "/share/doc/" ,name "-" ,version))
-                    (html (string-append doc "/html")))
-               (with-directory-excursion "doc"
-                 (apply invoke "make" "html" make-flags)
-                 (mkdir-p html)
-                 (copy-recursively "build/html" html))
-               #t))))))
-    (home-page "https://cffi.readthedocs.org")
+             #t)))))
+    (home-page "https://cffi.readthedocs.io/")
     (synopsis "Foreign function interface for Python")
-    (description
-     "Foreign Function Interface for Python calling C code.")
+    (description "Foreign Function Interface for Python calling C code.")
     (license expat)))
 
 (define-public python2-cffi
   (package-with-python2 python-cffi))
 
+(define-public python-cffi-documentation
+  (package
+    (name "python-cffi-documentation")
+    (version (package-version python-cffi))
+    (source (package-source python-cffi))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f
+       #:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'chdir
+                    (lambda _ (chdir "doc") #t))
+                  (delete 'configure)
+                  (replace 'build
+                    (lambda* (#:key (make-flags '()) #:allow-other-keys)
+                      (apply invoke "make" "html" make-flags)))
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let ((out (assoc-ref outputs "out")))
+                        (copy-recursively "build/html" (string-append out "/html"))
+                        #t))))))
+    (native-inputs
+     `(("sphinx-build" ,python-sphinx)))
+    (home-page (package-home-page python-cffi))
+    (synopsis "Documentation for the Python CFFI interface")
+    (description
+     "This package contains HTML documentation for the @code{python-cffi}
+project.")
+    (license (package-license python-cffi))))
+
 (define-public ruby-ffi
   (package
     (name "ruby-ffi")
-    (version "1.9.23")
+    (version "1.10.0")
     (source (origin
               (method url-fetch)
               (uri (rubygems-uri "ffi" version))
               (sha256
                (base32
-                "0zw6pbyvmj8wafdc7l5h7w20zkp1vbr2805ql5d941g2b20pk4zr"))))
+                "0j8pzj8raxbir5w5k6s7a042sb5k02pg0f8s4na1r5lan901j00p"))))
     (build-system ruby-build-system)
     ;; FIXME: Before running tests the build system attempts to build libffi
     ;; from sources.