Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
d43547f1 | 2 | ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> |
0751fddd | 3 | ;;; Copyright © 2014 Federico Beffa <beffa@fbengineering.ch> |
d47e99e0 | 4 | ;;; Copyright © 2015, 2019 Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> |
0751fddd | 5 | ;;; Copyright © 2016, 2017 Efraim Flashner <efraim@flashner.co.il> |
838b232e | 6 | ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com> |
95dc93da | 7 | ;;; Copyright © 2017, 2019 Marius Bakke <mbakke@fastmail.com> |
667e6f1e | 8 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
4e933afd | 9 | ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
c44899a2 | 10 | ;;; |
233e7676 | 11 | ;;; This file is part of GNU Guix. |
c44899a2 | 12 | ;;; |
233e7676 | 13 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
14 | ;;; under the terms of the GNU General Public License as published by |
15 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
16 | ;;; your option) any later version. | |
17 | ;;; | |
233e7676 | 18 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
19 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
20 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;;; GNU General Public License for more details. | |
22 | ;;; | |
23 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 24 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 25 | |
1ffa7090 | 26 | (define-module (gnu packages libffi) |
1602fcea | 27 | #:use-module (gnu packages) |
4a44e743 | 28 | #:use-module (guix licenses) |
c44899a2 | 29 | #:use-module (guix packages) |
87f5d366 | 30 | #:use-module (guix download) |
ac257f12 | 31 | #:use-module (gnu packages check) |
0751fddd EF |
32 | #:use-module (gnu packages pkg-config) |
33 | #:use-module (gnu packages python) | |
44d10b1f | 34 | #:use-module (gnu packages python-xyz) |
838b232e | 35 | #:use-module (gnu packages ruby) |
9d0c291e | 36 | #:use-module (gnu packages sphinx) |
0751fddd | 37 | #:use-module (guix build-system gnu) |
838b232e EF |
38 | #:use-module (guix build-system python) |
39 | #:use-module (guix build-system ruby)) | |
c44899a2 LC |
40 | |
41 | (define-public libffi | |
667e6f1e | 42 | (package |
c44899a2 | 43 | (name "libffi") |
bfcb7bcb | 44 | (version "3.2.1") |
c44899a2 | 45 | (source (origin |
667e6f1e TGR |
46 | (method url-fetch) |
47 | (uri | |
48 | (string-append "ftp://sourceware.org/pub/libffi/" | |
49 | name "-" version ".tar.gz")) | |
50 | (sha256 | |
51 | (base32 | |
52 | "0dya49bnhianl0r65m65xndz6ls2jn1xngyn72gd28ls3n7bnvnh")) | |
53 | (patches (search-patches "libffi-3.2.1-complex-alpha.patch")))) | |
c44899a2 | 54 | (build-system gnu-build-system) |
667e6f1e | 55 | (arguments |
1935b8d5 MB |
56 | `(;; Prevent the build system from passing -march and -mtune to the |
57 | ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4". | |
58 | #:configure-flags '("--enable-portable-binary" "--without-gcc-arch") | |
59 | #:phases | |
667e6f1e TGR |
60 | (modify-phases %standard-phases |
61 | (add-after 'install 'post-install | |
62 | (lambda* (#:key outputs #:allow-other-keys) | |
63 | (define out (assoc-ref outputs "out")) | |
64 | (symlink (string-append out "/lib/libffi-3.2.1/include") | |
65 | (string-append out "/include")) | |
66 | #t))))) | |
9bf62d9b | 67 | (outputs '("out" "debug")) |
089b0634 | 68 | (synopsis "Foreign function call interface library") |
c44899a2 LC |
69 | (description |
70 | "The libffi library provides a portable, high level programming interface | |
71 | to various calling conventions. This allows a programmer to call any | |
72 | function specified by a call interface description at run-time. | |
73 | ||
74 | FFI stands for Foreign Function Interface. A foreign function interface is | |
75 | the popular name for the interface that allows code written in one language | |
76 | to call code written in another language. The libffi library really only | |
77 | provides the lowest, machine dependent layer of a fully featured foreign | |
78 | function interface. A layer must exist above libffi that handles type | |
79 | conversions for values passed between the two languages.") | |
80 | (home-page "http://sources.redhat.com/libffi/") | |
81 | ||
7bf837fd | 82 | ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>. |
667e6f1e | 83 | (license expat))) |
c44899a2 | 84 | |
0751fddd EF |
85 | (define-public python-cffi |
86 | (package | |
87 | (name "python-cffi") | |
22cf2f4a | 88 | (version "1.11.5") |
0751fddd EF |
89 | (source |
90 | (origin | |
91 | (method url-fetch) | |
92 | (uri (pypi-uri "cffi" version)) | |
93 | (sha256 | |
8c5749f1 MB |
94 | (base32 "1x3lrj928dcxx1k8k9gf3s4s3jwvzv8mc3kkyg1g7c3a1sc1f3z9")) |
95 | (patches (search-patches "python-cffi-x87-stack-clean.patch")))) | |
0751fddd | 96 | (build-system python-build-system) |
0751fddd EF |
97 | (inputs |
98 | `(("libffi" ,libffi))) | |
99 | (propagated-inputs ; required at run-time | |
100 | `(("python-pycparser" ,python-pycparser))) | |
101 | (native-inputs | |
102 | `(("pkg-config" ,pkg-config) | |
0751fddd EF |
103 | ("python-pytest" ,python-pytest))) |
104 | (arguments | |
105 | `(#:modules ((ice-9 ftw) | |
106 | (srfi srfi-26) | |
107 | (guix build utils) | |
108 | (guix build python-build-system)) | |
109 | #:phases | |
110 | (modify-phases %standard-phases | |
111 | (replace 'check | |
112 | (lambda _ | |
113 | (setenv "PYTHONPATH" | |
114 | (string-append | |
115 | (getenv "PYTHONPATH") | |
116 | ":" (getcwd) "/build/" | |
117 | (car (scandir "build" (cut string-prefix? "lib." <>))))) | |
118 | ||
119 | ;; XXX The "normal" approach of setting CC and friends does | |
120 | ;; not work here. Is this the correct way of doing things? | |
121 | (substitute* "testing/embedding/test_basic.py" | |
122 | (("c = distutils\\.ccompiler\\.new_compiler\\(\\)") | |
123 | (string-append "c = distutils.ccompiler.new_compiler();" | |
124 | "c.set_executables(compiler='gcc'," | |
125 | "compiler_so='gcc',linker_exe='gcc'," | |
126 | "linker_so='gcc -shared')"))) | |
127 | (substitute* "testing/cffi0/test_ownlib.py" | |
128 | (("'cc testownlib") "'gcc testownlib")) | |
fc38e317 TGR |
129 | (invoke "py.test" "-v" "c/" "testing/") |
130 | #t)) | |
4e933afd MC |
131 | (add-before 'check 'patch-paths-of-dynamically-loaded-libraries |
132 | (lambda* (#:key inputs #:allow-other-keys) | |
133 | ;; Shared libraries should be referred by their absolute path as | |
134 | ;; using find_library or the like with their name fail when the | |
135 | ;; resolved .so object is a linker script rather than an ELF | |
136 | ;; binary (this is a limitation of the ctype library of Python). | |
137 | (let* ((glibc (assoc-ref inputs "libc")) | |
138 | (libm (string-append glibc "/lib/libm.so.6")) | |
139 | (libc (string-append glibc "/lib/libc.so.6"))) | |
140 | (substitute* '("testing/cffi0/test_function.py" | |
141 | "testing/cffi0/test_parsing.py" | |
142 | "testing/cffi0/test_unicode_literals.py" | |
143 | "testing/cffi0/test_zdistutils.py" | |
144 | "testing/cffi1/test_recompiler.py") | |
145 | (("lib_m = ['\"]{1}m['\"]{1}") | |
146 | (format #f "lib_m = '~a'" libm))) | |
147 | (substitute* '("testing/cffi0/test_verify.py" | |
148 | "testing/cffi1/test_verify1.py") | |
149 | (("lib_m = \\[['\"]{1}m['\"]{1}\\]") | |
150 | (format #f "lib_m = ['~a']" libm))) | |
151 | (substitute* "c/test_c.py" | |
152 | (("find_and_load_library\\(['\"]{1}c['\"]{1}") | |
153 | (format #f "find_and_load_library('~a'" libc))) | |
154 | #t))) | |
0751fddd EF |
155 | (add-before 'check 'disable-failing-test |
156 | ;; This is assumed to be a libffi issue: | |
157 | ;; https://bitbucket.org/cffi/cffi/issues/312/tests-failed-with-armv8 | |
158 | (lambda _ | |
159 | (substitute* "testing/cffi0/test_ownlib.py" | |
160 | (("ret.left") "ownlib.left")) | |
95dc93da | 161 | #t))))) |
4e933afd | 162 | (home-page "https://cffi.readthedocs.io/") |
0751fddd | 163 | (synopsis "Foreign function interface for Python") |
4e933afd | 164 | (description "Foreign Function Interface for Python calling C code.") |
0751fddd EF |
165 | (license expat))) |
166 | ||
167 | (define-public python2-cffi | |
168 | (package-with-python2 python-cffi)) | |
838b232e | 169 | |
95dc93da MB |
170 | (define-public python-cffi-documentation |
171 | (package | |
172 | (name "python-cffi-documentation") | |
173 | (version (package-version python-cffi)) | |
174 | (source (package-source python-cffi)) | |
175 | (build-system gnu-build-system) | |
176 | (arguments | |
177 | `(#:tests? #f | |
178 | #:phases (modify-phases %standard-phases | |
179 | (add-after 'unpack 'chdir | |
180 | (lambda _ (chdir "doc") #t)) | |
181 | (delete 'configure) | |
182 | (replace 'build | |
183 | (lambda* (#:key (make-flags '()) #:allow-other-keys) | |
184 | (apply invoke "make" "html" make-flags))) | |
185 | (replace 'install | |
186 | (lambda* (#:key outputs #:allow-other-keys) | |
187 | (let ((out (assoc-ref outputs "out"))) | |
188 | (copy-recursively "build/html" (string-append out "/html")) | |
189 | #t)))))) | |
190 | (native-inputs | |
191 | `(("sphinx-build" ,python-sphinx))) | |
192 | (home-page (package-home-page python-cffi)) | |
193 | (synopsis "Documentation for the Python CFFI interface") | |
194 | (description | |
195 | "This package contains HTML documentation for the @code{python-cffi} | |
196 | project.") | |
197 | (license (package-license python-cffi)))) | |
198 | ||
838b232e EF |
199 | (define-public ruby-ffi |
200 | (package | |
201 | (name "ruby-ffi") | |
d47e99e0 | 202 | (version "1.10.0") |
838b232e EF |
203 | (source (origin |
204 | (method url-fetch) | |
205 | (uri (rubygems-uri "ffi" version)) | |
206 | (sha256 | |
207 | (base32 | |
d47e99e0 | 208 | "0j8pzj8raxbir5w5k6s7a042sb5k02pg0f8s4na1r5lan901j00p")))) |
838b232e EF |
209 | (build-system ruby-build-system) |
210 | ;; FIXME: Before running tests the build system attempts to build libffi | |
211 | ;; from sources. | |
212 | (arguments `(#:tests? #f)) | |
213 | (native-inputs | |
214 | `(("ruby-rake-compiler" ,ruby-rake-compiler) | |
215 | ("ruby-rspec" ,ruby-rspec) | |
216 | ("ruby-rubygems-tasks" ,ruby-rubygems-tasks))) | |
217 | (inputs | |
218 | `(("libffi" ,libffi))) | |
219 | (synopsis "Ruby foreign function interface library") | |
220 | (description "Ruby-FFI is a Ruby extension for programmatically loading | |
221 | dynamic libraries, binding functions within them, and calling those functions | |
222 | from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby | |
223 | and JRuby.") | |
224 | (home-page "http://wiki.github.com/ffi/ffi") | |
225 | (license bsd-3))) |