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> |
075afce2 | 7 | ;;; Copyright © 2017, 2019, 2020 Marius Bakke <marius@gnu.org> |
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) |
075afce2 | 31 | #:use-module (guix git-download) |
ac257f12 | 32 | #:use-module (gnu packages check) |
0751fddd EF |
33 | #:use-module (gnu packages pkg-config) |
34 | #:use-module (gnu packages python) | |
44d10b1f | 35 | #:use-module (gnu packages python-xyz) |
838b232e | 36 | #:use-module (gnu packages ruby) |
9d0c291e | 37 | #:use-module (gnu packages sphinx) |
0751fddd | 38 | #:use-module (guix build-system gnu) |
838b232e EF |
39 | #:use-module (guix build-system python) |
40 | #:use-module (guix build-system ruby)) | |
c44899a2 LC |
41 | |
42 | (define-public libffi | |
667e6f1e | 43 | (package |
c44899a2 | 44 | (name "libffi") |
5f1000d5 | 45 | (version "3.3") |
c44899a2 | 46 | (source (origin |
667e6f1e TGR |
47 | (method url-fetch) |
48 | (uri | |
49 | (string-append "ftp://sourceware.org/pub/libffi/" | |
50 | name "-" version ".tar.gz")) | |
51 | (sha256 | |
52 | (base32 | |
5f1000d5 | 53 | "0mi0cpf8aa40ljjmzxb7im6dbj45bb0kllcd09xgmp834y9agyvj")))) |
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". | |
5f1000d5 | 58 | #:configure-flags '("--enable-portable-binary" "--without-gcc-arch"))) |
9bf62d9b | 59 | (outputs '("out" "debug")) |
089b0634 | 60 | (synopsis "Foreign function call interface library") |
c44899a2 LC |
61 | (description |
62 | "The libffi library provides a portable, high level programming interface | |
63 | to various calling conventions. This allows a programmer to call any | |
64 | function specified by a call interface description at run-time. | |
65 | ||
66 | FFI stands for Foreign Function Interface. A foreign function interface is | |
67 | the popular name for the interface that allows code written in one language | |
68 | to call code written in another language. The libffi library really only | |
69 | provides the lowest, machine dependent layer of a fully featured foreign | |
70 | function interface. A layer must exist above libffi that handles type | |
71 | conversions for values passed between the two languages.") | |
72 | (home-page "http://sources.redhat.com/libffi/") | |
73 | ||
7bf837fd | 74 | ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>. |
667e6f1e | 75 | (license expat))) |
c44899a2 | 76 | |
0751fddd EF |
77 | (define-public python-cffi |
78 | (package | |
79 | (name "python-cffi") | |
d708be82 | 80 | (version "1.14.0") |
0751fddd EF |
81 | (source |
82 | (origin | |
83 | (method url-fetch) | |
84 | (uri (pypi-uri "cffi" version)) | |
85 | (sha256 | |
d708be82 | 86 | (base32 "1dn279gw5ql8i5n3s5v4rnv96rhhjjfn7xq729qbl5bs2954yf1d")))) |
0751fddd | 87 | (build-system python-build-system) |
0751fddd EF |
88 | (inputs |
89 | `(("libffi" ,libffi))) | |
90 | (propagated-inputs ; required at run-time | |
91 | `(("python-pycparser" ,python-pycparser))) | |
92 | (native-inputs | |
93 | `(("pkg-config" ,pkg-config) | |
0751fddd EF |
94 | ("python-pytest" ,python-pytest))) |
95 | (arguments | |
96 | `(#:modules ((ice-9 ftw) | |
97 | (srfi srfi-26) | |
98 | (guix build utils) | |
99 | (guix build python-build-system)) | |
100 | #:phases | |
101 | (modify-phases %standard-phases | |
102 | (replace 'check | |
103 | (lambda _ | |
104 | (setenv "PYTHONPATH" | |
105 | (string-append | |
106 | (getenv "PYTHONPATH") | |
107 | ":" (getcwd) "/build/" | |
108 | (car (scandir "build" (cut string-prefix? "lib." <>))))) | |
109 | ||
110 | ;; XXX The "normal" approach of setting CC and friends does | |
111 | ;; not work here. Is this the correct way of doing things? | |
112 | (substitute* "testing/embedding/test_basic.py" | |
113 | (("c = distutils\\.ccompiler\\.new_compiler\\(\\)") | |
114 | (string-append "c = distutils.ccompiler.new_compiler();" | |
115 | "c.set_executables(compiler='gcc'," | |
116 | "compiler_so='gcc',linker_exe='gcc'," | |
117 | "linker_so='gcc -shared')"))) | |
118 | (substitute* "testing/cffi0/test_ownlib.py" | |
41fdad9f | 119 | (("\"cc testownlib") "\"gcc testownlib")) |
fc38e317 TGR |
120 | (invoke "py.test" "-v" "c/" "testing/") |
121 | #t)) | |
4e933afd MC |
122 | (add-before 'check 'patch-paths-of-dynamically-loaded-libraries |
123 | (lambda* (#:key inputs #:allow-other-keys) | |
124 | ;; Shared libraries should be referred by their absolute path as | |
125 | ;; using find_library or the like with their name fail when the | |
126 | ;; resolved .so object is a linker script rather than an ELF | |
127 | ;; binary (this is a limitation of the ctype library of Python). | |
128 | (let* ((glibc (assoc-ref inputs "libc")) | |
129 | (libm (string-append glibc "/lib/libm.so.6")) | |
130 | (libc (string-append glibc "/lib/libc.so.6"))) | |
131 | (substitute* '("testing/cffi0/test_function.py" | |
132 | "testing/cffi0/test_parsing.py" | |
133 | "testing/cffi0/test_unicode_literals.py" | |
134 | "testing/cffi0/test_zdistutils.py" | |
135 | "testing/cffi1/test_recompiler.py") | |
136 | (("lib_m = ['\"]{1}m['\"]{1}") | |
137 | (format #f "lib_m = '~a'" libm))) | |
138 | (substitute* '("testing/cffi0/test_verify.py" | |
139 | "testing/cffi1/test_verify1.py") | |
140 | (("lib_m = \\[['\"]{1}m['\"]{1}\\]") | |
141 | (format #f "lib_m = ['~a']" libm))) | |
142 | (substitute* "c/test_c.py" | |
143 | (("find_and_load_library\\(['\"]{1}c['\"]{1}") | |
144 | (format #f "find_and_load_library('~a'" libc))) | |
41fdad9f | 145 | #t)))))) |
4e933afd | 146 | (home-page "https://cffi.readthedocs.io/") |
0751fddd | 147 | (synopsis "Foreign function interface for Python") |
4e933afd | 148 | (description "Foreign Function Interface for Python calling C code.") |
0751fddd EF |
149 | (license expat))) |
150 | ||
151 | (define-public python2-cffi | |
152 | (package-with-python2 python-cffi)) | |
838b232e | 153 | |
95dc93da MB |
154 | (define-public python-cffi-documentation |
155 | (package | |
156 | (name "python-cffi-documentation") | |
157 | (version (package-version python-cffi)) | |
158 | (source (package-source python-cffi)) | |
159 | (build-system gnu-build-system) | |
160 | (arguments | |
161 | `(#:tests? #f | |
162 | #:phases (modify-phases %standard-phases | |
163 | (add-after 'unpack 'chdir | |
164 | (lambda _ (chdir "doc") #t)) | |
165 | (delete 'configure) | |
166 | (replace 'build | |
167 | (lambda* (#:key (make-flags '()) #:allow-other-keys) | |
168 | (apply invoke "make" "html" make-flags))) | |
169 | (replace 'install | |
170 | (lambda* (#:key outputs #:allow-other-keys) | |
171 | (let ((out (assoc-ref outputs "out"))) | |
172 | (copy-recursively "build/html" (string-append out "/html")) | |
173 | #t)))))) | |
174 | (native-inputs | |
175 | `(("sphinx-build" ,python-sphinx))) | |
176 | (home-page (package-home-page python-cffi)) | |
177 | (synopsis "Documentation for the Python CFFI interface") | |
178 | (description | |
179 | "This package contains HTML documentation for the @code{python-cffi} | |
180 | project.") | |
181 | (license (package-license python-cffi)))) | |
182 | ||
838b232e EF |
183 | (define-public ruby-ffi |
184 | (package | |
185 | (name "ruby-ffi") | |
77209ddd | 186 | (version "1.12.2") |
838b232e | 187 | (source (origin |
075afce2 MB |
188 | ;; Pull from git because the RubyGems release bundles LibFFI, |
189 | ;; and comes with a gemspec that makes it difficult to unbundle. | |
190 | (method git-fetch) | |
191 | (uri (git-reference | |
192 | (url "https://github.com/ffi/ffi") | |
193 | (commit version))) | |
194 | (file-name (git-file-name name version)) | |
838b232e EF |
195 | (sha256 |
196 | (base32 | |
075afce2 | 197 | "1cvqsbjr2gfjgqggq9kdx90qhhzr7qkyr9wmxdsfsik6cnxnnpmd")))) |
838b232e | 198 | (build-system ruby-build-system) |
075afce2 MB |
199 | (arguments |
200 | `(#:phases | |
201 | (modify-phases %standard-phases | |
202 | (add-after 'unpack 'do-not-depend-on-ccache | |
203 | (lambda _ | |
204 | (substitute* "spec/ffi/fixtures/GNUmakefile" | |
205 | (("^CCACHE := .*") | |
206 | "")) | |
207 | #t)) | |
208 | (replace 'replace-git-ls-files | |
209 | (lambda _ | |
210 | ;; Do not try to execute git, or include the (un)bundled LibFFI. | |
211 | (substitute* "ffi.gemspec" | |
212 | (("git ls-files -z") | |
213 | "find * -type f -print0 | sort -z") | |
214 | (("lfs \\+?= .*") | |
215 | "lfs = []\n")) | |
216 | (substitute* "Rakefile" | |
217 | (("LIBFFI_GIT_FILES = .*") | |
218 | "LIBFFI_GIT_FILES = []\n")) | |
219 | #t)) | |
220 | (replace 'build | |
221 | (lambda _ | |
222 | ;; Tests depend on the native extensions, so we build it | |
223 | ;; beforehand without going through the gem machinery. | |
224 | (invoke "rake" "compile") | |
225 | ||
226 | ;; XXX: Ideally we'd use "rake native gem" here to prevent the | |
227 | ;; install phase from needlessly rebuilding everything, but that | |
228 | ;; requires the bundled LibFFI, and the install phase can not | |
229 | ;; deal with such gems anyway. | |
230 | (invoke "gem" "build" "ffi.gemspec"))) | |
231 | (replace 'check | |
232 | (lambda* (#:key tests? #:allow-other-keys) | |
233 | (if tests? | |
234 | (begin | |
235 | (setenv "MAKE" "make") | |
236 | (setenv "CC" "gcc") | |
237 | (invoke "rspec" "spec")) | |
238 | (format #t "test suite not run~%")) | |
239 | #t))))) | |
838b232e EF |
240 | (native-inputs |
241 | `(("ruby-rake-compiler" ,ruby-rake-compiler) | |
242 | ("ruby-rspec" ,ruby-rspec) | |
243 | ("ruby-rubygems-tasks" ,ruby-rubygems-tasks))) | |
244 | (inputs | |
245 | `(("libffi" ,libffi))) | |
246 | (synopsis "Ruby foreign function interface library") | |
247 | (description "Ruby-FFI is a Ruby extension for programmatically loading | |
248 | dynamic libraries, binding functions within them, and calling those functions | |
249 | from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby | |
250 | and JRuby.") | |
702a1012 | 251 | (home-page "https://wiki.github.com/ffi/ffi") |
838b232e | 252 | (license bsd-3))) |