Commit | Line | Data |
---|---|---|
233e7676 | 1 | ;;; GNU Guix --- Functional package management for GNU |
b6e5eb4d | 2 | ;;; Copyright © 2012, 2013, 2014, 2020, 2021 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> |
9562d50d | 5 | ;;; Copyright © 2016, 2017, 2020, 2021 Efraim Flashner <efraim@flashner.co.il> |
838b232e | 6 | ;;; Copyright © 2016, 2017 Ben Woodcroft <donttrustben@gmail.com> |
a16ca6b3 | 7 | ;;; Copyright © 2017, 2019, 2020, 2022 Marius Bakke <marius@gnu.org> |
667e6f1e | 8 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
220a153c | 9 | ;;; Copyright © 2019, 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
7eaa2f24 | 10 | ;;; Copyright © 2020 John Doe <dftxbs3e@free.fr> |
c44899a2 | 11 | ;;; |
233e7676 | 12 | ;;; This file is part of GNU Guix. |
c44899a2 | 13 | ;;; |
233e7676 | 14 | ;;; GNU Guix is free software; you can redistribute it and/or modify it |
c44899a2 LC |
15 | ;;; under the terms of the GNU General Public License as published by |
16 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
17 | ;;; your option) any later version. | |
18 | ;;; | |
233e7676 | 19 | ;;; GNU Guix is distributed in the hope that it will be useful, but |
c44899a2 LC |
20 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
22 | ;;; GNU General Public License for more details. | |
23 | ;;; | |
24 | ;;; You should have received a copy of the GNU General Public License | |
233e7676 | 25 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. |
c44899a2 | 26 | |
1ffa7090 | 27 | (define-module (gnu packages libffi) |
1602fcea | 28 | #:use-module (gnu packages) |
4a44e743 | 29 | #:use-module (guix licenses) |
c44899a2 | 30 | #:use-module (guix packages) |
87f5d366 | 31 | #:use-module (guix download) |
075afce2 | 32 | #:use-module (guix git-download) |
ac257f12 | 33 | #:use-module (gnu packages check) |
0751fddd EF |
34 | #:use-module (gnu packages pkg-config) |
35 | #:use-module (gnu packages python) | |
44d10b1f | 36 | #:use-module (gnu packages python-xyz) |
838b232e | 37 | #:use-module (gnu packages ruby) |
9d0c291e | 38 | #:use-module (gnu packages sphinx) |
0751fddd | 39 | #:use-module (guix build-system gnu) |
838b232e EF |
40 | #:use-module (guix build-system python) |
41 | #:use-module (guix build-system ruby)) | |
c44899a2 LC |
42 | |
43 | (define-public libffi | |
667e6f1e | 44 | (package |
c44899a2 | 45 | (name "libffi") |
5f1000d5 | 46 | (version "3.3") |
c44899a2 | 47 | (source (origin |
667e6f1e TGR |
48 | (method url-fetch) |
49 | (uri | |
50 | (string-append "ftp://sourceware.org/pub/libffi/" | |
51 | name "-" version ".tar.gz")) | |
52 | (sha256 | |
53 | (base32 | |
4659e046 | 54 | "0mi0cpf8aa40ljjmzxb7im6dbj45bb0kllcd09xgmp834y9agyvj")) |
9562d50d EF |
55 | (patches (search-patches "libffi-3.3-powerpc-fixes.patch" |
56 | "libffi-float128-powerpc64le.patch")))) | |
c44899a2 | 57 | (build-system gnu-build-system) |
667e6f1e | 58 | (arguments |
1935b8d5 MB |
59 | `(;; Prevent the build system from passing -march and -mtune to the |
60 | ;; compiler. See "ax_cc_maxopt.m4" and "ax_gcc_archflag.m4". | |
9562d50d EF |
61 | #:configure-flags '("--enable-portable-binary" |
62 | "--without-gcc-arch"))) | |
9bf62d9b | 63 | (outputs '("out" "debug")) |
089b0634 | 64 | (synopsis "Foreign function call interface library") |
c44899a2 LC |
65 | (description |
66 | "The libffi library provides a portable, high level programming interface | |
67 | to various calling conventions. This allows a programmer to call any | |
68 | function specified by a call interface description at run-time. | |
69 | ||
70 | FFI stands for Foreign Function Interface. A foreign function interface is | |
71 | the popular name for the interface that allows code written in one language | |
72 | to call code written in another language. The libffi library really only | |
73 | provides the lowest, machine dependent layer of a fully featured foreign | |
74 | function interface. A layer must exist above libffi that handles type | |
75 | conversions for values passed between the two languages.") | |
b6e5eb4d LC |
76 | (home-page "http://www.sourceware.org/libffi/") |
77 | (properties `((release-monitoring-url . ,home-page))) | |
c44899a2 | 78 | |
7bf837fd | 79 | ;; See <https://github.com/atgreen/libffi/blob/master/LICENSE>. |
667e6f1e | 80 | (license expat))) |
c44899a2 | 81 | |
0751fddd EF |
82 | (define-public python-cffi |
83 | (package | |
84 | (name "python-cffi") | |
32b7e12e | 85 | (version "1.15.1") |
0751fddd EF |
86 | (source |
87 | (origin | |
88 | (method url-fetch) | |
89 | (uri (pypi-uri "cffi" version)) | |
90 | (sha256 | |
32b7e12e | 91 | (base32 "1y9lr651svbzf1m03s4lqbnbv2byx8f6f0ml7hjm24vvlfwvy06l")))) |
0751fddd | 92 | (build-system python-build-system) |
0751fddd | 93 | (inputs |
8394619b | 94 | (list libffi)) |
0751fddd | 95 | (propagated-inputs ; required at run-time |
8394619b | 96 | (list python-pycparser)) |
0751fddd | 97 | (native-inputs |
8394619b | 98 | (list pkg-config python-pytest)) |
0751fddd | 99 | (arguments |
220a153c | 100 | `(#:phases |
0751fddd EF |
101 | (modify-phases %standard-phases |
102 | (replace 'check | |
103 | (lambda _ | |
0751fddd EF |
104 | ;; XXX The "normal" approach of setting CC and friends does |
105 | ;; not work here. Is this the correct way of doing things? | |
106 | (substitute* "testing/embedding/test_basic.py" | |
107 | (("c = distutils\\.ccompiler\\.new_compiler\\(\\)") | |
108 | (string-append "c = distutils.ccompiler.new_compiler();" | |
109 | "c.set_executables(compiler='gcc'," | |
110 | "compiler_so='gcc',linker_exe='gcc'," | |
111 | "linker_so='gcc -shared')"))) | |
112 | (substitute* "testing/cffi0/test_ownlib.py" | |
41fdad9f | 113 | (("\"cc testownlib") "\"gcc testownlib")) |
220a153c | 114 | (invoke "py.test" "-v" "c/" "testing/"))) |
4e933afd MC |
115 | (add-before 'check 'patch-paths-of-dynamically-loaded-libraries |
116 | (lambda* (#:key inputs #:allow-other-keys) | |
117 | ;; Shared libraries should be referred by their absolute path as | |
118 | ;; using find_library or the like with their name fail when the | |
119 | ;; resolved .so object is a linker script rather than an ELF | |
120 | ;; binary (this is a limitation of the ctype library of Python). | |
97e29833 MB |
121 | (let ((libm (search-input-file inputs "lib/libm.so.6")) |
122 | (libc (search-input-file inputs "lib/libc.so.6"))) | |
4e933afd MC |
123 | (substitute* '("testing/cffi0/test_function.py" |
124 | "testing/cffi0/test_parsing.py" | |
125 | "testing/cffi0/test_unicode_literals.py" | |
126 | "testing/cffi0/test_zdistutils.py" | |
127 | "testing/cffi1/test_recompiler.py") | |
128 | (("lib_m = ['\"]{1}m['\"]{1}") | |
129 | (format #f "lib_m = '~a'" libm))) | |
130 | (substitute* '("testing/cffi0/test_verify.py" | |
131 | "testing/cffi1/test_verify1.py") | |
132 | (("lib_m = \\[['\"]{1}m['\"]{1}\\]") | |
133 | (format #f "lib_m = ['~a']" libm))) | |
134 | (substitute* "c/test_c.py" | |
135 | (("find_and_load_library\\(['\"]{1}c['\"]{1}") | |
220a153c | 136 | (format #f "find_and_load_library('~a'" libc))))))))) |
4e933afd | 137 | (home-page "https://cffi.readthedocs.io/") |
0751fddd | 138 | (synopsis "Foreign function interface for Python") |
4e933afd | 139 | (description "Foreign Function Interface for Python calling C code.") |
0751fddd EF |
140 | (license expat))) |
141 | ||
95dc93da MB |
142 | (define-public python-cffi-documentation |
143 | (package | |
144 | (name "python-cffi-documentation") | |
145 | (version (package-version python-cffi)) | |
146 | (source (package-source python-cffi)) | |
147 | (build-system gnu-build-system) | |
148 | (arguments | |
149 | `(#:tests? #f | |
150 | #:phases (modify-phases %standard-phases | |
151 | (add-after 'unpack 'chdir | |
152 | (lambda _ (chdir "doc") #t)) | |
153 | (delete 'configure) | |
154 | (replace 'build | |
155 | (lambda* (#:key (make-flags '()) #:allow-other-keys) | |
156 | (apply invoke "make" "html" make-flags))) | |
157 | (replace 'install | |
158 | (lambda* (#:key outputs #:allow-other-keys) | |
159 | (let ((out (assoc-ref outputs "out"))) | |
160 | (copy-recursively "build/html" (string-append out "/html")) | |
161 | #t)))))) | |
162 | (native-inputs | |
163 | `(("sphinx-build" ,python-sphinx))) | |
164 | (home-page (package-home-page python-cffi)) | |
165 | (synopsis "Documentation for the Python CFFI interface") | |
166 | (description | |
167 | "This package contains HTML documentation for the @code{python-cffi} | |
168 | project.") | |
169 | (license (package-license python-cffi)))) | |
170 | ||
838b232e EF |
171 | (define-public ruby-ffi |
172 | (package | |
173 | (name "ruby-ffi") | |
8df29c26 | 174 | (version "1.15.5") |
838b232e | 175 | (source (origin |
075afce2 MB |
176 | ;; Pull from git because the RubyGems release bundles LibFFI, |
177 | ;; and comes with a gemspec that makes it difficult to unbundle. | |
178 | (method git-fetch) | |
179 | (uri (git-reference | |
180 | (url "https://github.com/ffi/ffi") | |
8df29c26 | 181 | (commit (string-append "v" version)))) |
075afce2 | 182 | (file-name (git-file-name name version)) |
838b232e EF |
183 | (sha256 |
184 | (base32 | |
8df29c26 | 185 | "1qk55s1zwpdjykwkj9l37m71i5n228i7f8bg3ply3ks9py16m7s6")))) |
838b232e | 186 | (build-system ruby-build-system) |
075afce2 MB |
187 | (arguments |
188 | `(#:phases | |
189 | (modify-phases %standard-phases | |
075afce2 MB |
190 | (replace 'replace-git-ls-files |
191 | (lambda _ | |
192 | ;; Do not try to execute git, or include the (un)bundled LibFFI. | |
193 | (substitute* "ffi.gemspec" | |
194 | (("git ls-files -z") | |
195 | "find * -type f -print0 | sort -z") | |
196 | (("lfs \\+?= .*") | |
197 | "lfs = []\n")) | |
198 | (substitute* "Rakefile" | |
8df29c26 EF |
199 | (("git .*ls-files -z") |
200 | "find * -type f -print0 | sort -z") | |
075afce2 | 201 | (("LIBFFI_GIT_FILES = .*") |
8df29c26 | 202 | "LIBFFI_GIT_FILES = []\n")))) |
075afce2 MB |
203 | (replace 'build |
204 | (lambda _ | |
205 | ;; Tests depend on the native extensions, so we build it | |
206 | ;; beforehand without going through the gem machinery. | |
207 | (invoke "rake" "compile") | |
208 | ||
209 | ;; XXX: Ideally we'd use "rake native gem" here to prevent the | |
210 | ;; install phase from needlessly rebuilding everything, but that | |
211 | ;; requires the bundled LibFFI, and the install phase can not | |
212 | ;; deal with such gems anyway. | |
213 | (invoke "gem" "build" "ffi.gemspec"))) | |
214 | (replace 'check | |
215 | (lambda* (#:key tests? #:allow-other-keys) | |
216 | (if tests? | |
217 | (begin | |
218 | (setenv "MAKE" "make") | |
219 | (setenv "CC" "gcc") | |
220 | (invoke "rspec" "spec")) | |
8df29c26 | 221 | (format #t "test suite not run~%"))))))) |
838b232e | 222 | (native-inputs |
8394619b | 223 | (list ruby-rake-compiler ruby-rspec ruby-rubygems-tasks)) |
838b232e | 224 | (inputs |
8394619b | 225 | (list libffi)) |
838b232e EF |
226 | (synopsis "Ruby foreign function interface library") |
227 | (description "Ruby-FFI is a Ruby extension for programmatically loading | |
228 | dynamic libraries, binding functions within them, and calling those functions | |
229 | from Ruby code. Moreover, a Ruby-FFI extension works without changes on Ruby | |
230 | and JRuby.") | |
702a1012 | 231 | (home-page "https://wiki.github.com/ffi/ffi") |
838b232e | 232 | (license bsd-3))) |