Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
7d4cab74 | 2 | ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net> |
25e0037a | 3 | ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> |
be6eb2f1 RW |
4 | ;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com> |
5 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> | |
d1308c5e | 6 | ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr> |
3a354e10 | 7 | ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net> |
a9b34762 MM |
8 | ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org> |
9 | ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com> | |
2dab4188 | 10 | ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com> |
564cf93f | 11 | ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu> |
df4c8434 | 12 | ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de> |
741115b6 RW |
13 | ;;; |
14 | ;;; This file is part of GNU Guix. | |
15 | ;;; | |
16 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
17 | ;;; under the terms of the GNU General Public License as published by | |
18 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
19 | ;;; your option) any later version. | |
20 | ;;; | |
21 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
22 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | ;;; GNU General Public License for more details. | |
25 | ;;; | |
26 | ;;; You should have received a copy of the GNU General Public License | |
27 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
28 | ||
29 | (define-module (gnu packages machine-learning) | |
30 | #:use-module ((guix licenses) #:prefix license:) | |
31 | #:use-module (guix packages) | |
32 | #:use-module (guix utils) | |
33 | #:use-module (guix download) | |
23aab4ab | 34 | #:use-module (guix svn-download) |
c1670a81 | 35 | #:use-module (guix build-system cmake) |
741115b6 | 36 | #:use-module (guix build-system gnu) |
0a3063d6 | 37 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 38 | #:use-module (guix build-system python) |
8406138b | 39 | #:use-module (guix build-system r) |
a9b34762 | 40 | #:use-module (guix git-download) |
71f80f54 | 41 | #:use-module (gnu packages) |
0dfeb285 | 42 | #:use-module (gnu packages adns) |
5a14e81e | 43 | #:use-module (gnu packages algebra) |
b9445d0b | 44 | #:use-module (gnu packages audio) |
23aab4ab | 45 | #:use-module (gnu packages autotools) |
b9445d0b | 46 | #:use-module (gnu packages base) |
99260014 | 47 | #:use-module (gnu packages bash) |
0931c609 | 48 | #:use-module (gnu packages boost) |
be6eb2f1 | 49 | #:use-module (gnu packages check) |
0931c609 | 50 | #:use-module (gnu packages compression) |
9e37e537 | 51 | #:use-module (gnu packages cran) |
23aab4ab | 52 | #:use-module (gnu packages dejagnu) |
0931c609 | 53 | #:use-module (gnu packages gcc) |
b9445d0b RW |
54 | #:use-module (gnu packages glib) |
55 | #:use-module (gnu packages gstreamer) | |
5f0ff6a9 | 56 | #:use-module (gnu packages image) |
b9445d0b | 57 | #:use-module (gnu packages linux) |
0931c609 | 58 | #:use-module (gnu packages maths) |
112c2c01 | 59 | #:use-module (gnu packages mpi) |
0a3063d6 | 60 | #:use-module (gnu packages ocaml) |
3929f46c | 61 | #:use-module (gnu packages onc-rpc) |
791c11d6 | 62 | #:use-module (gnu packages perl) |
c1670a81 | 63 | #:use-module (gnu packages pkg-config) |
0dfeb285 | 64 | #:use-module (gnu packages protobuf) |
0931c609 | 65 | #:use-module (gnu packages python) |
10451f6b | 66 | #:use-module (gnu packages python-web) |
44d10b1f | 67 | #:use-module (gnu packages python-xyz) |
c1670a81 RW |
68 | #:use-module (gnu packages statistics) |
69 | #:use-module (gnu packages swig) | |
0dfeb285 | 70 | #:use-module (gnu packages tls) |
99260014 | 71 | #:use-module (gnu packages web) |
5f0ff6a9 MB |
72 | #:use-module (gnu packages xml) |
73 | #:use-module (gnu packages xorg)) | |
741115b6 | 74 | |
a9b34762 MM |
75 | (define-public fann |
76 | ;; The last release is >100 commits behind, so we package from git. | |
77 | (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7")) | |
78 | (package | |
79 | (name "fann") | |
80 | (version (string-append "2.2.0-1." (string-take commit 8))) | |
81 | (source (origin | |
82 | (method git-fetch) | |
83 | (uri (git-reference | |
84 | (url "https://github.com/libfann/fann.git") | |
85 | (commit commit))) | |
86 | (file-name (string-append name "-" version "-checkout")) | |
87 | (sha256 | |
88 | (base32 | |
89 | "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x")))) | |
90 | (build-system cmake-build-system) | |
91 | (arguments | |
92 | `(#:phases | |
93 | (modify-phases %standard-phases | |
94 | (replace 'check | |
95 | (lambda* (#:key outputs #:allow-other-keys) | |
96 | (let* ((out (assoc-ref outputs "out"))) | |
97 | (with-directory-excursion (string-append (getcwd) "/tests") | |
98 | (invoke "./fann_tests")))))))) | |
99 | (home-page "http://leenissen.dk/fann/wp/") | |
100 | (synopsis "Fast Artificial Neural Network") | |
101 | (description | |
102 | "FANN is a free open source neural network library, which implements | |
103 | multilayer artificial neural networks in C with support for both fully | |
104 | connected and sparsely connected networks.") | |
105 | (license license:lgpl2.1)))) | |
106 | ||
741115b6 RW |
107 | (define-public libsvm |
108 | (package | |
109 | (name "libsvm") | |
d1308c5e | 110 | (version "3.22") |
741115b6 RW |
111 | (source |
112 | (origin | |
113 | (method url-fetch) | |
d1308c5e TGR |
114 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
115 | name "-" version ".tar.gz")) | |
741115b6 RW |
116 | (sha256 |
117 | (base32 | |
d1308c5e | 118 | "0zd7s19y5vb7agczl6456bn45cj1y64739sslaskw1qk7dywd0bd")))) |
741115b6 RW |
119 | (build-system gnu-build-system) |
120 | (arguments | |
121 | `(#:tests? #f ;no "check" target | |
122 | #:phases (modify-phases %standard-phases | |
123 | (delete 'configure) | |
124 | (replace | |
d1308c5e | 125 | 'install ; no ‘install’ target |
741115b6 RW |
126 | (lambda* (#:key outputs #:allow-other-keys) |
127 | (let* ((out (assoc-ref outputs "out")) | |
128 | (bin (string-append out "/bin/"))) | |
129 | (mkdir-p bin) | |
130 | (for-each (lambda (file) | |
131 | (copy-file file (string-append bin file))) | |
132 | '("svm-train" | |
133 | "svm-predict" | |
134 | "svm-scale"))) | |
135 | #t))))) | |
136 | (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/") | |
137 | (synopsis "Library for Support Vector Machines") | |
138 | (description | |
139 | "LIBSVM is a machine learning library for support vector | |
140 | classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and | |
141 | distribution estimation (one-class SVM). It supports multi-class | |
142 | classification.") | |
143 | (license license:bsd-3))) | |
71f80f54 RW |
144 | |
145 | (define-public python-libsvm | |
146 | (package (inherit libsvm) | |
147 | (name "python-libsvm") | |
148 | (build-system gnu-build-system) | |
149 | (arguments | |
150 | `(#:tests? #f ;no "check" target | |
151 | #:make-flags '("-C" "python") | |
152 | #:phases | |
153 | (modify-phases %standard-phases | |
154 | (delete 'configure) | |
155 | (replace | |
d1308c5e | 156 | 'install ; no ‘install’ target |
71f80f54 RW |
157 | (lambda* (#:key inputs outputs #:allow-other-keys) |
158 | (let ((site (string-append (assoc-ref outputs "out") | |
159 | "/lib/python" | |
160 | (string-take | |
161 | (string-take-right | |
162 | (assoc-ref inputs "python") 5) 3) | |
163 | "/site-packages/"))) | |
164 | (substitute* "python/svm.py" | |
165 | (("../libsvm.so.2") "libsvm.so.2")) | |
166 | (mkdir-p site) | |
167 | (for-each (lambda (file) | |
168 | (copy-file file (string-append site (basename file)))) | |
169 | (find-files "python" "\\.py")) | |
170 | (copy-file "libsvm.so.2" | |
171 | (string-append site "libsvm.so.2"))) | |
172 | #t))))) | |
173 | (inputs | |
174 | `(("python" ,python))) | |
175 | (synopsis "Python bindings of libSVM"))) | |
0931c609 | 176 | |
23aab4ab RW |
177 | (define-public ghmm |
178 | ;; The latest release candidate is several years and a couple of fixes have | |
179 | ;; been published since. This is why we download the sources from the SVN | |
180 | ;; repository. | |
181 | (let ((svn-revision 2341)) | |
182 | (package | |
183 | (name "ghmm") | |
184 | (version (string-append "0.9-rc3-0." (number->string svn-revision))) | |
185 | (source (origin | |
186 | (method svn-fetch) | |
187 | (uri (svn-reference | |
188 | (url "http://svn.code.sf.net/p/ghmm/code/trunk") | |
189 | (revision svn-revision))) | |
190 | (file-name (string-append name "-" version)) | |
191 | (sha256 | |
192 | (base32 | |
193 | "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq")))) | |
194 | (build-system gnu-build-system) | |
195 | (arguments | |
ced12a7b RW |
196 | `(#:imported-modules (,@%gnu-build-system-modules |
197 | (guix build python-build-system)) | |
198 | #:phases | |
23aab4ab RW |
199 | (modify-phases %standard-phases |
200 | (add-after 'unpack 'enter-dir | |
201 | (lambda _ (chdir "ghmm") #t)) | |
ced12a7b RW |
202 | (delete 'check) |
203 | (add-after 'install 'check | |
204 | (assoc-ref %standard-phases 'check)) | |
205 | (add-before 'check 'fix-PYTHONPATH | |
206 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
207 | (let ((python-version ((@@ (guix build python-build-system) | |
208 | get-python-version) | |
209 | (assoc-ref inputs "python")))) | |
210 | (setenv "PYTHONPATH" | |
211 | (string-append (getenv "PYTHONPATH") | |
212 | ":" (assoc-ref outputs "out") | |
213 | "/lib/python" python-version | |
214 | "/site-packages"))) | |
23aab4ab RW |
215 | #t)) |
216 | (add-after 'enter-dir 'fix-runpath | |
217 | (lambda* (#:key outputs #:allow-other-keys) | |
218 | (substitute* "ghmmwrapper/setup.py" | |
219 | (("^(.*)extra_compile_args = \\[" line indent) | |
220 | (string-append indent | |
221 | "extra_link_args = [\"-Wl,-rpath=" | |
222 | (assoc-ref outputs "out") "/lib\"],\n" | |
223 | line | |
224 | "\"-Wl,-rpath=" | |
225 | (assoc-ref outputs "out") | |
226 | "/lib\", "))) | |
227 | #t)) | |
228 | (add-after 'enter-dir 'disable-broken-tests | |
229 | (lambda _ | |
230 | (substitute* "tests/Makefile.am" | |
231 | ;; GHMM_SILENT_TESTS is assumed to be a command. | |
232 | (("TESTS_ENVIRONMENT.*") "") | |
233 | ;; Do not build broken tests. | |
234 | (("chmm .*") "") | |
235 | (("read_fa .*") "") | |
236 | (("mcmc .*") "") | |
237 | (("label_higher_order_test.*$") | |
238 | "label_higher_order_test\n")) | |
239 | ||
240 | ;; These Python unittests are broken as there is no gato. | |
241 | ;; See https://sourceforge.net/p/ghmm/support-requests/3/ | |
242 | (substitute* "ghmmwrapper/ghmmunittests.py" | |
243 | (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)" | |
244 | line indent) | |
245 | (string-append indent | |
246 | "@unittest.skip(\"Disabled by Guix\")\n" | |
247 | line))) | |
248 | #t)) | |
d10092b8 | 249 | (add-after 'disable-broken-tests 'autogen |
23aab4ab | 250 | (lambda _ |
3107259f | 251 | (invoke "bash" "autogen.sh")))))) |
23aab4ab RW |
252 | (inputs |
253 | `(("python" ,python-2) ; only Python 2 is supported | |
254 | ("libxml2" ,libxml2))) | |
255 | (native-inputs | |
256 | `(("pkg-config" ,pkg-config) | |
257 | ("dejagnu" ,dejagnu) | |
258 | ("swig" ,swig) | |
259 | ("autoconf" ,autoconf) | |
260 | ("automake" ,automake) | |
261 | ("libtool" ,libtool))) | |
262 | (home-page "http://ghmm.org") | |
263 | (synopsis "Hidden Markov Model library") | |
264 | (description | |
265 | "The General Hidden Markov Model library (GHMM) is a C library with | |
266 | additional Python bindings implementing a wide range of types of @dfn{Hidden | |
d1e4ad1b | 267 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
268 | training, HMM clustering, HMM mixtures.") |
269 | (license license:lgpl2.0+)))) | |
270 | ||
791c11d6 BW |
271 | (define-public mcl |
272 | (package | |
273 | (name "mcl") | |
274 | (version "14.137") | |
275 | (source (origin | |
276 | (method url-fetch) | |
277 | (uri (string-append | |
278 | "http://micans.org/mcl/src/mcl-" | |
279 | (string-replace-substring version "." "-") | |
280 | ".tar.gz")) | |
281 | (sha256 | |
282 | (base32 | |
283 | "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m")))) | |
284 | (build-system gnu-build-system) | |
285 | (arguments | |
286 | `(#:configure-flags (list "--enable-blast"))) | |
287 | (inputs | |
288 | `(("perl" ,perl))) | |
289 | (home-page "http://micans.org/mcl/") | |
290 | (synopsis "Clustering algorithm for graphs") | |
291 | (description | |
292 | "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a | |
293 | fast and scalable unsupervised cluster algorithm for graphs (also known as | |
294 | networks) based on simulation of (stochastic) flow in graphs.") | |
295 | ;; In the LICENCE file and web page it says "The software is licensed | |
296 | ;; under the GNU General Public License, version 3.", but in several of | |
297 | ;; the source code files it suggests GPL3 or later. | |
298 | ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html | |
299 | (license license:gpl3))) | |
300 | ||
0a3063d6 BW |
301 | (define-public ocaml-mcl |
302 | (package | |
303 | (name "ocaml-mcl") | |
304 | (version "12-068oasis4") | |
305 | (source | |
306 | (origin | |
307 | (method url-fetch) | |
308 | (uri (string-append | |
309 | "https://github.com/fhcrc/mcl/archive/" | |
310 | version ".tar.gz")) | |
311 | (file-name (string-append name "-" version ".tar.gz")) | |
312 | (sha256 | |
313 | (base32 | |
314 | "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110")))) | |
315 | (build-system ocaml-build-system) | |
316 | (arguments | |
564cf93f JL |
317 | `(#:ocaml ,ocaml-4.02 |
318 | #:findlib ,ocaml4.02-findlib | |
319 | #:phases | |
0a3063d6 BW |
320 | (modify-phases %standard-phases |
321 | (add-before 'configure 'patch-paths | |
322 | (lambda _ | |
323 | (substitute* "configure" | |
324 | (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh")))) | |
325 | (substitute* "setup.ml" | |
326 | (("LDFLAGS=-fPIC") | |
327 | (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh")))) | |
328 | #t))))) | |
329 | (home-page "https://github.com/fhcrc/mcl") | |
330 | (synopsis "OCaml wrappers around MCL") | |
331 | (description | |
332 | "This package provides OCaml bindings for the MCL graph clustering | |
333 | algorithm.") | |
334 | (license license:gpl3))) | |
335 | ||
0931c609 RW |
336 | (define-public randomjungle |
337 | (package | |
338 | (name "randomjungle") | |
339 | (version "2.1.0") | |
340 | (source | |
341 | (origin | |
342 | (method url-fetch) | |
343 | (uri (string-append | |
df4c8434 BH |
344 | "https://www.imbs.uni-luebeck.de/fileadmin/files/Software" |
345 | "/randomjungle/randomjungle-" version ".tar_.gz")) | |
1e92d311 | 346 | (patches (search-patches "randomjungle-disable-static-build.patch")) |
0931c609 RW |
347 | (sha256 |
348 | (base32 | |
349 | "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w")))) | |
350 | (build-system gnu-build-system) | |
351 | (arguments | |
352 | `(#:configure-flags | |
1e92d311 MB |
353 | (list "--disable-static" |
354 | (string-append "--with-boost=" | |
0931c609 RW |
355 | (assoc-ref %build-inputs "boost"))) |
356 | #:phases | |
357 | (modify-phases %standard-phases | |
358 | (add-before | |
359 | 'configure 'set-CXXFLAGS | |
360 | (lambda _ | |
361 | (setenv "CXXFLAGS" "-fpermissive ") | |
362 | #t))))) | |
363 | (inputs | |
364 | `(("boost" ,boost) | |
365 | ("gsl" ,gsl) | |
366 | ("libxml2" ,libxml2) | |
367 | ("zlib" ,zlib))) | |
368 | (native-inputs | |
25e0037a EF |
369 | `(("gfortran" ,gfortran) |
370 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
371 | ;; Non-portable assembly instructions are used so building fails on |
372 | ;; platforms other than x86_64 or i686. | |
373 | (supported-systems '("x86_64-linux" "i686-linux")) | |
df4c8434 | 374 | (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224") |
0931c609 RW |
375 | (synopsis "Implementation of the Random Forests machine learning method") |
376 | (description | |
377 | "Random Jungle is an implementation of Random Forests. It is supposed to | |
378 | analyse high dimensional data. In genetics, it can be used for analysing big | |
379 | Genome Wide Association (GWA) data. Random Forests is a powerful machine | |
380 | learning method. Most interesting features are variable selection, missing | |
381 | value imputation, classifier creation, generalization error estimation and | |
382 | sample proximities between pairs of cases.") | |
383 | (license license:gpl3+))) | |
c1670a81 | 384 | |
7d4cab74 RW |
385 | (define-public openfst |
386 | (package | |
387 | (name "openfst") | |
388 | (version "1.7.1") | |
389 | (source (origin | |
390 | (method url-fetch) | |
391 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
392 | "FstDownload/openfst-" version ".tar.gz")) | |
393 | (sha256 | |
394 | (base32 | |
395 | "0x9wfcqd8hq4h349s7j77sr60h8xjdfshqw1m3a2n6z5bdr9qkm1")))) | |
396 | (build-system gnu-build-system) | |
397 | (home-page "http://www.openfst.org") | |
398 | (synopsis "Library for weighted finite-state transducers") | |
399 | (description "OpenFst is a library for constructing, combining, | |
400 | optimizing, and searching weighted finite-state transducers (FSTs).") | |
401 | (license license:asl2.0))) | |
402 | ||
c1670a81 RW |
403 | (define-public shogun |
404 | (package | |
405 | (name "shogun") | |
5a14e81e | 406 | (version "6.1.3") |
c1670a81 RW |
407 | (source |
408 | (origin | |
409 | (method url-fetch) | |
410 | (uri (string-append | |
411 | "ftp://shogun-toolbox.org/shogun/releases/" | |
412 | (version-major+minor version) | |
413 | "/sources/shogun-" version ".tar.bz2")) | |
414 | (sha256 | |
415 | (base32 | |
5a14e81e | 416 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
417 | (modules '((guix build utils) |
418 | (ice-9 rdelim))) | |
419 | (snippet | |
420 | '(begin | |
421 | ;; Remove non-free sources and files referencing them | |
422 | (for-each delete-file | |
423 | (find-files "src/shogun/classifier/svm/" | |
424 | "SVMLight\\.(cpp|h)")) | |
425 | (for-each delete-file | |
426 | (find-files "examples/undocumented/libshogun/" | |
427 | (string-append | |
428 | "(classifier_.*svmlight.*|" | |
429 | "evaluation_cross_validation_locked_comparison).cpp"))) | |
430 | ;; Remove non-free functions. | |
431 | (define (delete-ifdefs file) | |
432 | (with-atomic-file-replacement file | |
433 | (lambda (in out) | |
434 | (let loop ((line (read-line in 'concat)) | |
435 | (skipping? #f)) | |
436 | (if (eof-object? line) | |
437 | #t | |
438 | (let ((skip-next? | |
439 | (or (and skipping? | |
440 | (not (string-prefix? | |
441 | "#endif //USE_SVMLIGHT" line))) | |
442 | (string-prefix? | |
443 | "#ifdef USE_SVMLIGHT" line)))) | |
444 | (when (or (not skipping?) | |
445 | (and skipping? (not skip-next?))) | |
446 | (display line out)) | |
447 | (loop (read-line in 'concat) skip-next?))))))) | |
5a14e81e KK |
448 | (for-each delete-ifdefs |
449 | (append | |
450 | (find-files "src/shogun/classifier/mkl" | |
451 | "^MKLClassification\\.cpp") | |
452 | (find-files "src/shogun/classifier/svm" | |
453 | "^SVMLightOneClass\\.(cpp|h)") | |
454 | (find-files "src/shogun/multiclass" | |
455 | "^ScatterSVM\\.(cpp|h)") | |
456 | (find-files "src/shogun/kernel/" | |
457 | "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)") | |
458 | (find-files "src/shogun/regression/svr" | |
459 | "^(MKLRegression|SVRLight)\\.(cpp|h)") | |
460 | (find-files "src/shogun/transfer/domain_adaptation" | |
c0d7c124 | 461 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 462 | #t)))) |
c1670a81 RW |
463 | (build-system cmake-build-system) |
464 | (arguments | |
465 | '(#:tests? #f ;no check target | |
466 | #:phases | |
dc1d3cde KK |
467 | (modify-phases %standard-phases |
468 | (add-after 'unpack 'delete-broken-symlinks | |
469 | (lambda _ | |
470 | (for-each delete-file '("applications/arts/data" | |
471 | "applications/asp/data" | |
472 | "applications/easysvm/data" | |
473 | "applications/msplicer/data" | |
474 | "applications/ocr/data" | |
5a14e81e KK |
475 | "examples/meta/data" |
476 | "examples/undocumented/data")) | |
dc1d3cde KK |
477 | #t)) |
478 | (add-after 'unpack 'change-R-target-path | |
479 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
480 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
481 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
482 | (("\\$\\{R_COMPONENT_LIB_PATH\\}") |
483 | (string-append (assoc-ref outputs "out") | |
484 | "/lib/R/library/"))) | |
485 | #t)) | |
486 | (add-after 'unpack 'fix-octave-modules | |
487 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e | 488 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 489 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
490 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
491 | ;; change target directory | |
dc1d3cde KK |
492 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
493 | (string-append (assoc-ref outputs "out") | |
494 | "/share/octave/packages"))) | |
5a14e81e KK |
495 | (substitute* '("src/interfaces/octave/swig_typemaps.i" |
496 | "src/interfaces/octave/sg_print_functions.cpp") | |
497 | ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave. | |
498 | (("octave/config\\.h") "octave/octave-config.h") | |
499 | (("octave/oct-obj.h") "octave/ovl.h")) | |
dc1d3cde | 500 | #t)) |
5a14e81e KK |
501 | (add-after 'unpack 'move-rxcpp |
502 | (lambda* (#:key inputs #:allow-other-keys) | |
503 | (let ((rxcpp-dir "shogun/third-party/rxcpp")) | |
504 | (mkdir-p rxcpp-dir) | |
505 | (install-file (assoc-ref inputs "rxcpp") rxcpp-dir) | |
506 | #t))) | |
dc1d3cde | 507 | (add-before 'build 'set-HOME |
c1670a81 | 508 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 509 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
510 | #:configure-flags |
511 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
512 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
513 | "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags |
514 | ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas | |
515 | ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray | |
516 | ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist | |
517 | ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file | |
518 | "-DINTERFACE_OCTAVE=ON" | |
519 | "-DINTERFACE_PYTHON=ON" | |
520 | "-DINTERFACE_R=ON"))) | |
c1670a81 RW |
521 | (inputs |
522 | `(("python" ,python) | |
523 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 524 | ("r-minimal" ,r-minimal) |
5537603f | 525 | ("octave" ,octave-cli) |
c1670a81 | 526 | ("swig" ,swig) |
5a14e81e | 527 | ("eigen" ,eigen) |
c1670a81 RW |
528 | ("hdf5" ,hdf5) |
529 | ("atlas" ,atlas) | |
530 | ("arpack" ,arpack-ng) | |
531 | ("lapack" ,lapack) | |
532 | ("glpk" ,glpk) | |
533 | ("libxml2" ,libxml2) | |
534 | ("lzo" ,lzo) | |
535 | ("zlib" ,zlib))) | |
536 | (native-inputs | |
5a14e81e KK |
537 | `(("pkg-config" ,pkg-config) |
538 | ("rxcpp" ,rxcpp))) | |
6b5b656f RW |
539 | ;; Non-portable SSE instructions are used so building fails on platforms |
540 | ;; other than x86_64. | |
541 | (supported-systems '("x86_64-linux")) | |
c1670a81 RW |
542 | (home-page "http://shogun-toolbox.org/") |
543 | (synopsis "Machine learning toolbox") | |
544 | (description | |
545 | "The Shogun Machine learning toolbox provides a wide range of unified and | |
546 | efficient Machine Learning (ML) methods. The toolbox seamlessly allows to | |
547 | combine multiple data representations, algorithm classes, and general purpose | |
548 | tools. This enables both rapid prototyping of data pipelines and extensibility | |
549 | in terms of new algorithms.") | |
550 | (license license:gpl3+))) | |
8406138b | 551 | |
3a354e10 KK |
552 | (define-public rxcpp |
553 | (package | |
554 | (name "rxcpp") | |
555 | (version "4.0.0") | |
556 | (source | |
557 | (origin | |
558 | (method url-fetch) | |
559 | (uri (string-append "https://github.com/ReactiveX/RxCpp/archive/v" | |
560 | version ".tar.gz")) | |
561 | (sha256 | |
562 | (base32 | |
563 | "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh")) | |
564 | (file-name (string-append name "-" version ".tar.gz")))) | |
565 | (build-system cmake-build-system) | |
566 | (arguments | |
567 | `(#:phases | |
568 | (modify-phases %standard-phases | |
569 | (add-after 'unpack 'remove-werror | |
570 | (lambda _ | |
571 | (substitute* (find-files ".") | |
572 | (("-Werror") "")) | |
573 | #t)) | |
574 | (replace 'check | |
575 | (lambda _ | |
576 | (invoke "ctest")))))) | |
577 | (native-inputs | |
578 | `(("catch" ,catch-framework))) | |
579 | (home-page "http://reactivex.io/") | |
580 | (synopsis "Reactive Extensions for C++") | |
581 | (description | |
582 | "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for | |
583 | values-distributed-in-time. ReactiveX is a library for composing asynchronous | |
584 | and event-based programs by using observable sequences. | |
585 | ||
586 | It extends the observer pattern to support sequences of data and/or events and | |
587 | adds operators that allow you to compose sequences together declaratively while | |
588 | abstracting away concerns about things like low-level threading, | |
589 | synchronization, thread-safety, concurrent data structures, and non-blocking | |
590 | I/O.") | |
591 | (license license:asl2.0))) | |
592 | ||
8406138b RW |
593 | (define-public r-adaptivesparsity |
594 | (package | |
595 | (name "r-adaptivesparsity") | |
c0608f81 | 596 | (version "1.6") |
8406138b RW |
597 | (source (origin |
598 | (method url-fetch) | |
599 | (uri (cran-uri "AdaptiveSparsity" version)) | |
600 | (sha256 | |
601 | (base32 | |
c0608f81 | 602 | "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91")))) |
8406138b RW |
603 | (properties |
604 | `((upstream-name . "AdaptiveSparsity"))) | |
605 | (build-system r-build-system) | |
606 | (arguments | |
607 | `(#:phases | |
608 | (modify-phases %standard-phases | |
609 | (add-after 'unpack 'link-against-armadillo | |
610 | (lambda _ | |
611 | (substitute* "src/Makevars" | |
612 | (("PKG_LIBS=" prefix) | |
613 | (string-append prefix "-larmadillo")))))))) | |
614 | (propagated-inputs | |
c0608f81 RW |
615 | `(("r-mass" ,r-mass) |
616 | ("r-matrix" ,r-matrix) | |
617 | ("r-rcpp" ,r-rcpp) | |
8406138b | 618 | ("r-rcpparmadillo" ,r-rcpparmadillo))) |
60e36bff LC |
619 | (inputs |
620 | `(("armadillo" ,armadillo))) | |
e9960d8c | 621 | (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity") |
8406138b RW |
622 | (synopsis "Adaptive sparsity models") |
623 | (description | |
624 | "This package implements the Figueiredo machine learning algorithm for | |
625 | adaptive sparsity and the Wong algorithm for adaptively sparse gaussian | |
626 | geometric models.") | |
627 | (license license:lgpl3+))) | |
e4785eb8 | 628 | |
5f0ff6a9 MB |
629 | (define-public dlib |
630 | (package | |
631 | (name "dlib") | |
abe97a58 | 632 | (version "19.7") |
5f0ff6a9 MB |
633 | (source (origin |
634 | (method url-fetch) | |
635 | (uri (string-append | |
636 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
637 | (sha256 | |
638 | (base32 | |
abe97a58 | 639 | "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2")) |
5f0ff6a9 MB |
640 | (modules '((guix build utils))) |
641 | (snippet | |
642 | '(begin | |
643 | ;; Delete ~13MB of bundled dependencies. | |
644 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
645 | (delete-file-recursively "docs/dlib/external") |
646 | #t)))) | |
5f0ff6a9 MB |
647 | (build-system cmake-build-system) |
648 | (arguments | |
677bc34d | 649 | `(#:phases |
5f0ff6a9 MB |
650 | (modify-phases %standard-phases |
651 | (add-after 'unpack 'disable-asserts | |
652 | (lambda _ | |
653 | ;; config.h recommends explicitly enabling or disabling asserts | |
654 | ;; when building as a shared library. By default neither is set. | |
655 | (substitute* "dlib/config.h" | |
656 | (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS")) | |
657 | #t)) | |
4fba38db MB |
658 | (add-after 'disable-asserts 'disable-failing-tests |
659 | (lambda _ | |
660 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 661 | ;; Others are flaky on some platforms. |
4fba38db MB |
662 | (let* ((system ,(or (%current-target-system) |
663 | (%current-system))) | |
664 | (disabled-tests (cond | |
665 | ((string-prefix? "mips64" system) | |
666 | '("object_detector" ; timeout | |
667 | "data_io")) | |
668 | ((string-prefix? "armhf" system) | |
a343c461 | 669 | '("learning_to_track")) |
4fba38db | 670 | ((string-prefix? "i686" system) |
0ef7ea66 | 671 | '("optimization")) |
4fba38db | 672 | (else '())))) |
4fba38db MB |
673 | (for-each |
674 | (lambda (test) | |
675 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
676 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
677 | disabled-tests) | |
678 | #t))) | |
5f0ff6a9 MB |
679 | (replace 'check |
680 | (lambda _ | |
681 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 682 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 683 | (with-directory-excursion test-dir |
8448e6bf TGR |
684 | (invoke "make" "-j" (number->string (parallel-job-count))) |
685 | (invoke "./dtest" "--runall")) | |
686 | #t))) | |
5f0ff6a9 MB |
687 | (add-after 'install 'delete-static-library |
688 | (lambda* (#:key outputs #:allow-other-keys) | |
0ef7ea66 MB |
689 | (delete-file (string-append (assoc-ref outputs "out") |
690 | "/lib/libdlib.a")) | |
691 | #t))))) | |
5f0ff6a9 | 692 | (native-inputs |
3929f46c TGR |
693 | `(("pkg-config" ,pkg-config) |
694 | ;; For tests. | |
695 | ("libnsl" ,libnsl))) | |
5f0ff6a9 | 696 | (inputs |
f40841e9 | 697 | `(("giflib" ,giflib) |
4fba38db | 698 | ("lapack" ,lapack) |
5f0ff6a9 MB |
699 | ("libjpeg" ,libjpeg) |
700 | ("libpng" ,libpng) | |
701 | ("libx11" ,libx11) | |
702 | ("openblas" ,openblas) | |
703 | ("zlib" ,zlib))) | |
704 | (synopsis | |
705 | "Toolkit for making machine learning and data analysis applications in C++") | |
706 | (description | |
707 | "Dlib is a modern C++ toolkit containing machine learning algorithms and | |
708 | tools. It is used in both industry and academia in a wide range of domains | |
709 | including robotics, embedded devices, mobile phones, and large high performance | |
710 | computing environments.") | |
711 | (home-page "http://dlib.net") | |
712 | (license license:boost1.0))) | |
be6eb2f1 RW |
713 | |
714 | (define-public python-scikit-learn | |
715 | (package | |
716 | (name "python-scikit-learn") | |
7ff3f3d2 | 717 | (version "0.20.1") |
be6eb2f1 RW |
718 | (source |
719 | (origin | |
4a89bdd1 RW |
720 | (method git-fetch) |
721 | (uri (git-reference | |
722 | (url "https://github.com/scikit-learn/scikit-learn.git") | |
723 | (commit version))) | |
724 | (file-name (git-file-name name version)) | |
be6eb2f1 RW |
725 | (sha256 |
726 | (base32 | |
650bc942 | 727 | "0fkhwg3xn1s7ln9q1szq6kwc4jhwvjh8w4kmv9wcrqy7cq3lbv0d")))) |
be6eb2f1 RW |
728 | (build-system python-build-system) |
729 | (arguments | |
730 | `(#:phases | |
731 | (modify-phases %standard-phases | |
4a89bdd1 RW |
732 | (add-after 'build 'build-ext |
733 | (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t)) | |
734 | (replace 'check | |
735 | (lambda _ | |
736 | ;; Restrict OpenBLAS threads to prevent segfaults while testing! | |
737 | (setenv "OPENBLAS_NUM_THREADS" "1") | |
7ff3f3d2 MB |
738 | |
739 | ;; Some tests require write access to $HOME. | |
740 | (setenv "HOME" "/tmp") | |
741 | ||
742 | (invoke "pytest" "sklearn" "-m" "not network"))) | |
4a89bdd1 RW |
743 | ;; FIXME: This fails with permission denied |
744 | (delete 'reset-gzip-timestamps)))) | |
be6eb2f1 RW |
745 | (inputs |
746 | `(("openblas" ,openblas))) | |
747 | (native-inputs | |
4a89bdd1 RW |
748 | `(("python-pytest" ,python-pytest) |
749 | ("python-pandas" ,python-pandas) ;for tests | |
be6eb2f1 RW |
750 | ("python-cython" ,python-cython))) |
751 | (propagated-inputs | |
752 | `(("python-numpy" ,python-numpy) | |
753 | ("python-scipy" ,python-scipy))) | |
754 | (home-page "http://scikit-learn.org/") | |
755 | (synopsis "Machine Learning in Python") | |
756 | (description | |
4a89bdd1 RW |
757 | "Scikit-learn provides simple and efficient tools for data mining and |
758 | data analysis.") | |
be6eb2f1 RW |
759 | (license license:bsd-3))) |
760 | ||
761 | (define-public python2-scikit-learn | |
7ff3f3d2 | 762 | (package-with-python2 python-scikit-learn)) |
2dab4188 FT |
763 | |
764 | (define-public python-autograd | |
765 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
766 | (revision "0") | |
767 | (version (git-version "0.0.0" revision commit))) | |
768 | (package | |
769 | (name "python-autograd") | |
770 | (home-page "https://github.com/HIPS/autograd") | |
771 | (source (origin | |
772 | (method git-fetch) | |
773 | (uri (git-reference | |
774 | (url home-page) | |
775 | (commit commit))) | |
776 | (sha256 | |
777 | (base32 | |
778 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
779 | (file-name (git-file-name name version)))) | |
780 | (version version) | |
781 | (build-system python-build-system) | |
782 | (native-inputs | |
783 | `(("python-nose" ,python-nose) | |
784 | ("python-pytest" ,python-pytest))) | |
785 | (propagated-inputs | |
786 | `(("python-future" ,python-future) | |
787 | ("python-numpy" ,python-numpy))) | |
788 | (arguments | |
789 | `(#:phases (modify-phases %standard-phases | |
790 | (replace 'check | |
791 | (lambda _ | |
792 | (invoke "py.test" "-v")))))) | |
793 | (synopsis "Efficiently computes derivatives of NumPy code") | |
794 | (description "Autograd can automatically differentiate native Python and | |
795 | NumPy code. It can handle a large subset of Python's features, including loops, | |
796 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
797 | of derivatives. It supports reverse-mode differentiation | |
798 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
799 | scalar-valued functions with respect to array-valued arguments, as well as | |
800 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
801 | main intended application of Autograd is gradient-based optimization.") | |
802 | (license license:expat)))) | |
803 | ||
804 | (define-public python2-autograd | |
805 | (package-with-python2 python-autograd)) | |
112c2c01 FT |
806 | |
807 | (define-public lightgbm | |
808 | (package | |
809 | (name "lightgbm") | |
810 | (version "2.0.12") | |
811 | (source (origin | |
812 | (method url-fetch) | |
813 | (uri (string-append | |
814 | "https://github.com/Microsoft/LightGBM/archive/v" | |
815 | version ".tar.gz")) | |
816 | (sha256 | |
817 | (base32 | |
818 | "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1")) | |
819 | (file-name (string-append name "-" version ".tar.gz")))) | |
820 | (native-inputs | |
821 | `(("python-pytest" ,python-pytest) | |
822 | ("python-nose" ,python-nose))) | |
823 | (inputs | |
824 | `(("openmpi" ,openmpi))) | |
825 | (propagated-inputs | |
826 | `(("python-numpy" ,python-numpy) | |
827 | ("python-scipy" ,python-scipy))) | |
828 | (arguments | |
829 | `(#:configure-flags | |
830 | '("-DUSE_MPI=ON") | |
831 | #:phases | |
832 | (modify-phases %standard-phases | |
833 | (replace 'check | |
834 | (lambda* (#:key outputs #:allow-other-keys) | |
835 | (with-directory-excursion ,(string-append "../LightGBM-" version) | |
836 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) | |
837 | (build-system cmake-build-system) | |
838 | (home-page "https://github.com/Microsoft/LightGBM") | |
839 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
840 | (description "LightGBM is a gradient boosting framework that uses tree | |
841 | based learning algorithms. It is designed to be distributed and efficient with | |
842 | the following advantages: | |
843 | ||
844 | @itemize | |
845 | @item Faster training speed and higher efficiency | |
846 | @item Lower memory usage | |
847 | @item Better accuracy | |
848 | @item Parallel and GPU learning supported (not enabled in this package) | |
849 | @item Capable of handling large-scale data | |
850 | @end itemize\n") | |
851 | (license license:expat))) | |
a8fb82a8 FT |
852 | |
853 | (define-public vowpal-wabbit | |
854 | ;; Language bindings not included. | |
855 | (package | |
856 | (name "vowpal-wabbit") | |
857 | (version "8.5.0") | |
858 | (source (origin | |
859 | (method url-fetch) | |
860 | (uri (string-append | |
861 | "https://github.com/JohnLangford/vowpal_wabbit/archive/" | |
862 | version ".tar.gz")) | |
863 | (sha256 | |
864 | (base32 | |
865 | "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr")) | |
866 | (file-name (string-append name "-" version ".tar.gz")))) | |
867 | (inputs | |
868 | `(("boost" ,boost) | |
869 | ("zlib" ,zlib))) | |
870 | (arguments | |
871 | `(#:configure-flags | |
872 | (list (string-append "--with-boost=" | |
873 | (assoc-ref %build-inputs "boost"))))) | |
874 | (build-system gnu-build-system) | |
875 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
876 | (synopsis "Fast machine learning library for online learning") | |
877 | (description "Vowpal Wabbit is a machine learning system with techniques | |
878 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
879 | interactive learning.") | |
880 | (license license:bsd-3))) | |
915c6bf6 LC |
881 | |
882 | (define-public python2-fastlmm | |
883 | (package | |
884 | (name "python2-fastlmm") | |
885 | (version "0.2.21") | |
886 | (source | |
887 | (origin | |
888 | (method url-fetch) | |
889 | (uri (pypi-uri "fastlmm" version ".zip")) | |
890 | (sha256 | |
891 | (base32 | |
892 | "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m")))) | |
893 | (build-system python-build-system) | |
894 | (arguments | |
237ee6f2 RW |
895 | `(#:tests? #f ; some test files are missing |
896 | #:python ,python-2)) ; only Python 2.7 is supported | |
915c6bf6 LC |
897 | (propagated-inputs |
898 | `(("python2-numpy" ,python2-numpy) | |
899 | ("python2-scipy" ,python2-scipy) | |
900 | ("python2-matplotlib" ,python2-matplotlib) | |
901 | ("python2-pandas" ,python2-pandas) | |
902 | ("python2-scikit-learn" ,python2-scikit-learn) | |
903 | ("python2-pysnptools" ,python2-pysnptools))) | |
904 | (native-inputs | |
905 | `(("unzip" ,unzip) | |
906 | ("python2-cython" ,python2-cython) | |
907 | ("python2-mock" ,python2-mock) | |
908 | ("python2-nose" ,python2-nose))) | |
909 | (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/") | |
910 | (synopsis "Perform genome-wide association studies on large data sets") | |
911 | (description | |
912 | "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed | |
913 | Models, is a program for performing both single-SNP and SNP-set genome-wide | |
914 | association studies (GWAS) on extremely large data sets.") | |
915 | (license license:asl2.0))) | |
b9445d0b RW |
916 | |
917 | ;; There have been no proper releases yet. | |
918 | (define-public kaldi | |
919 | (let ((commit "2f95609f0bb085bd3a1dc5eb0a39f3edea59e606") | |
920 | (revision "1")) | |
921 | (package | |
922 | (name "kaldi") | |
923 | (version (git-version "0" revision commit)) | |
924 | (source (origin | |
925 | (method git-fetch) | |
926 | (uri (git-reference | |
927 | (url "https://github.com/kaldi-asr/kaldi.git") | |
928 | (commit commit))) | |
929 | (file-name (git-file-name name version)) | |
930 | (sha256 | |
931 | (base32 | |
932 | "082qh3pfi7hvncylp4xsmkfahbd7gb0whdfa4rwrx7fxk9rdh3kz")))) | |
933 | (build-system gnu-build-system) | |
934 | (arguments | |
935 | `(#:test-target "test" | |
936 | #:phases | |
937 | (modify-phases %standard-phases | |
938 | (add-after 'unpack 'chdir | |
939 | (lambda _ (chdir "src") #t)) | |
940 | (replace 'configure | |
941 | (lambda* (#:key build system inputs outputs #:allow-other-keys) | |
942 | (when (not (or (string-prefix? "x86_64" system) | |
943 | (string-prefix? "i686" system))) | |
944 | (substitute* "makefiles/linux_openblas.mk" | |
945 | (("-msse -msse2") ""))) | |
946 | (substitute* "makefiles/default_rules.mk" | |
947 | (("/bin/bash") (which "bash"))) | |
948 | (substitute* "Makefile" | |
949 | (("ext_depend: check_portaudio") | |
950 | "ext_depend:")) | |
951 | (substitute* '("online/Makefile" | |
952 | "onlinebin/Makefile" | |
953 | "gst-plugin/Makefile") | |
954 | (("../../tools/portaudio/install") | |
955 | (assoc-ref inputs "portaudio"))) | |
956 | ||
957 | ;; This `configure' script doesn't support variables passed as | |
958 | ;; arguments, nor does it support "prefix". | |
959 | (let ((out (assoc-ref outputs "out")) | |
960 | (openblas (assoc-ref inputs "openblas")) | |
961 | (openfst (assoc-ref inputs "openfst"))) | |
962 | (substitute* "configure" | |
963 | (("check_for_slow_expf;") "") | |
964 | ;; This affects the RPATH and also serves as the installation | |
965 | ;; directory. | |
966 | (("KALDILIBDIR=`pwd`/lib") | |
967 | (string-append "KALDILIBDIR=" out "/lib"))) | |
968 | (mkdir-p out) ; must exist | |
969 | (setenv "CONFIG_SHELL" (which "bash")) | |
970 | (setenv "OPENFST_VER" ,(package-version openfst)) | |
971 | (invoke "./configure" | |
972 | "--use-cuda=no" | |
973 | "--shared" | |
974 | (string-append "--openblas-root=" openblas) | |
975 | (string-append "--fst-root=" openfst))))) | |
976 | (add-after 'build 'build-ext-and-gstreamer-plugin | |
977 | (lambda _ | |
978 | (invoke "make" "-C" "online" "depend") | |
979 | (invoke "make" "-C" "online") | |
980 | (invoke "make" "-C" "onlinebin" "depend") | |
981 | (invoke "make" "-C" "onlinebin") | |
982 | (invoke "make" "-C" "gst-plugin" "depend") | |
983 | (invoke "make" "-C" "gst-plugin") | |
984 | #t)) | |
985 | ;; TODO: also install the executables. | |
986 | (replace 'install | |
987 | (lambda* (#:key outputs #:allow-other-keys) | |
988 | (let* ((out (assoc-ref outputs "out")) | |
1fdd20c7 | 989 | (inc (string-append out "/include")) |
b9445d0b RW |
990 | (lib (string-append out "/lib"))) |
991 | (mkdir-p lib) | |
1fdd20c7 RW |
992 | ;; The build phase installed symlinks to the actual |
993 | ;; libraries. Install the actual targets. | |
994 | (for-each (lambda (file) | |
995 | (let ((target (readlink file))) | |
996 | (delete-file file) | |
997 | (install-file target lib))) | |
998 | (find-files lib "\\.so")) | |
999 | ;; Install headers | |
1000 | (for-each (lambda (file) | |
1001 | (let ((target-dir (string-append inc "/" (dirname file)))) | |
1002 | (install-file file target-dir))) | |
1003 | (find-files "." "\\.h")) | |
1004 | (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" | |
1005 | (string-append lib "/gstreamer-1.0")) | |
b9445d0b RW |
1006 | #t)))))) |
1007 | (inputs | |
1008 | `(("alsa-lib" ,alsa-lib) | |
1009 | ("gfortran" ,gfortran "lib") | |
1010 | ("glib" ,glib) | |
1011 | ("gstreamer" ,gstreamer) | |
1012 | ("jack" ,jack-1) | |
1013 | ("openblas" ,openblas) | |
1014 | ("openfst" ,openfst) | |
1015 | ("portaudio" ,portaudio) | |
1016 | ("python" ,python))) | |
1017 | (native-inputs | |
1018 | `(("glib" ,glib "bin") ; glib-genmarshal | |
1019 | ("grep" ,grep) | |
1020 | ("sed" ,sed) | |
1021 | ("pkg-config" ,pkg-config) | |
1022 | ("which" ,which))) | |
1023 | (home-page "https://kaldi-asr.org/") | |
1024 | (synopsis "Speech recognition toolkit") | |
1025 | (description "Kaldi is an extensible toolkit for speech recognition | |
1026 | written in C++.") | |
1027 | (license license:asl2.0)))) | |
99260014 RW |
1028 | |
1029 | (define-public gst-kaldi-nnet2-online | |
1030 | (let ((commit "617e43e73c7cc45eb9119028c02bd4178f738c4a") | |
1031 | (revision "1")) | |
1032 | (package | |
1033 | (name "gst-kaldi-nnet2-online") | |
1034 | (version (git-version "0" revision commit)) | |
1035 | (source (origin | |
1036 | (method git-fetch) | |
1037 | (uri (git-reference | |
1038 | (url "https://github.com/alumae/gst-kaldi-nnet2-online.git") | |
1039 | (commit commit))) | |
1040 | (file-name (git-file-name name version)) | |
1041 | (sha256 | |
1042 | (base32 | |
1043 | "0xh3w67b69818s6ib02ara4lw7wamjdmh4jznvkpzrs4skbs9jx9")))) | |
1044 | (build-system gnu-build-system) | |
1045 | (arguments | |
1046 | `(#:tests? #f ; there are none | |
1047 | #:make-flags | |
1048 | (list (string-append "SHELL=" | |
1049 | (assoc-ref %build-inputs "bash") "/bin/bash") | |
1050 | (string-append "KALDI_ROOT=" | |
1051 | (assoc-ref %build-inputs "kaldi-src")) | |
1052 | (string-append "KALDILIBDIR=" | |
1053 | (assoc-ref %build-inputs "kaldi") "/lib") | |
1054 | "KALDI_FLAVOR=dynamic") | |
1055 | #:phases | |
1056 | (modify-phases %standard-phases | |
1057 | (add-after 'unpack 'chdir | |
1058 | (lambda _ (chdir "src") #t)) | |
1059 | (replace 'configure | |
1060 | (lambda* (#:key inputs #:allow-other-keys) | |
1061 | (let ((glib (assoc-ref inputs "glib"))) | |
1062 | (setenv "CXXFLAGS" "-std=c++11 -fPIC") | |
1063 | (setenv "CPLUS_INCLUDE_PATH" | |
1064 | (string-append glib "/include/glib-2.0:" | |
1065 | glib "/lib/glib-2.0/include:" | |
1066 | (assoc-ref inputs "gstreamer") | |
1067 | "/include/gstreamer-1.0:" | |
1068 | (getenv "CPLUS_INCLUDE_PATH")))) | |
1069 | (substitute* "Makefile" | |
1070 | (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") | |
1071 | (("\\$\\(error Cannot find") "#")))) | |
1072 | (add-before 'build 'build-depend | |
1073 | (lambda* (#:key make-flags #:allow-other-keys) | |
1074 | (apply invoke "make" "depend" make-flags))) | |
1075 | (replace 'install | |
1076 | (lambda* (#:key outputs #:allow-other-keys) | |
1077 | (let* ((out (assoc-ref outputs "out")) | |
1078 | (lib (string-append out "/lib/gstreamer-1.0"))) | |
1079 | (install-file "libgstkaldinnet2onlinedecoder.so" lib) | |
1080 | #t)))))) | |
1081 | (inputs | |
1082 | `(("glib" ,glib) | |
1083 | ("gstreamer" ,gstreamer) | |
1084 | ("jansson" ,jansson) | |
1085 | ("openfst" ,openfst) | |
1086 | ("kaldi" ,kaldi))) | |
1087 | (native-inputs | |
1088 | `(("bash" ,bash) | |
1089 | ("glib:bin" ,glib "bin") ; glib-genmarshal | |
1090 | ("kaldi-src" ,(package-source kaldi)) | |
1091 | ("pkg-config" ,pkg-config))) | |
1092 | (home-page "https://kaldi-asr.org/") | |
1093 | (synopsis "Gstreamer plugin for decoding speech") | |
1094 | (description "This package provides a GStreamer plugin that wraps | |
1095 | Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN | |
1096 | acoustic models. The iVectors are adapted to the current audio stream | |
1097 | automatically.") | |
1098 | (license license:asl2.0)))) | |
10451f6b RW |
1099 | |
1100 | (define-public kaldi-gstreamer-server | |
1101 | (let ((commit "1735ba49c5dc0ebfc184e45105fc600cd9f1f508") | |
1102 | (revision "1")) | |
1103 | (package | |
1104 | (name "kaldi-gstreamer-server") | |
1105 | (version (git-version "0" revision commit)) | |
1106 | (source (origin | |
1107 | (method git-fetch) | |
1108 | (uri (git-reference | |
1109 | (url "https://github.com/alumae/kaldi-gstreamer-server.git") | |
1110 | (commit commit))) | |
1111 | (file-name (git-file-name name version)) | |
1112 | (sha256 | |
1113 | (base32 | |
1114 | "0j701m7lbwmzqxsfanj882v7881hrbmpqybbczbxqpcbg8q34w0k")))) | |
1115 | (build-system gnu-build-system) | |
1116 | (arguments | |
1117 | `(#:tests? #f ; there are no tests that can be run automatically | |
1118 | #:modules ((guix build utils) | |
1119 | (guix build gnu-build-system) | |
1120 | (srfi srfi-26)) | |
1121 | #:phases | |
1122 | (modify-phases %standard-phases | |
1123 | (delete 'configure) | |
1124 | (replace 'build | |
1125 | (lambda* (#:key outputs #:allow-other-keys) | |
1126 | ;; Disable hash randomization to ensure the generated .pycs | |
1127 | ;; are reproducible. | |
1128 | (setenv "PYTHONHASHSEED" "0") | |
1129 | (with-directory-excursion "kaldigstserver" | |
1130 | (for-each (lambda (file) | |
1131 | (apply invoke | |
1132 | `("python" | |
1133 | "-m" "compileall" | |
1134 | "-f" ; force rebuild | |
1135 | ,file))) | |
1136 | (find-files "." "\\.py$"))) | |
1137 | #t)) | |
1138 | (replace 'install | |
1139 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1140 | (let* ((out (assoc-ref outputs "out")) | |
1141 | (bin (string-append out "/bin")) | |
1142 | (share (string-append out "/share/kaldi-gstreamer-server/"))) | |
1143 | ;; Install Python files | |
1144 | (with-directory-excursion "kaldigstserver" | |
1145 | (for-each (cut install-file <> share) | |
1146 | (find-files "." ".*"))) | |
1147 | ||
1148 | ;; Install sample configuration files | |
1149 | (for-each (cut install-file <> share) | |
1150 | (find-files "." "\\.yaml")) | |
1151 | ||
1152 | ;; Install executables | |
1153 | (mkdir-p bin) | |
1154 | (let* ((server (string-append bin "/kaldi-gst-server")) | |
1155 | (client (string-append bin "/kaldi-gst-client")) | |
1156 | (worker (string-append bin "/kaldi-gst-worker")) | |
1157 | (PYTHONPATH (getenv "PYTHONPATH")) | |
1158 | (GST_PLUGIN_PATH (string-append | |
1159 | (assoc-ref inputs "gst-kaldi-nnet2-online") | |
1160 | "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) | |
1161 | (wrap (lambda (wrapper what) | |
1162 | (with-output-to-file wrapper | |
1163 | (lambda _ | |
1164 | (format #t | |
1165 | "#!~a | |
1166 | export PYTHONPATH=~a | |
1167 | export GST_PLUGIN_PATH=~a | |
1168 | exec ~a ~a/~a \"$@\"~%" | |
1169 | (which "bash") PYTHONPATH GST_PLUGIN_PATH | |
1170 | (which "python") share what))) | |
1171 | (chmod wrapper #o555)))) | |
1172 | (for-each wrap | |
1173 | (list server client worker) | |
1174 | (list "master_server.py" | |
1175 | "client.py" | |
1176 | "worker.py"))) | |
1177 | #t)))))) | |
1178 | (inputs | |
1179 | `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online) | |
1180 | ("python2" ,python-2) | |
1181 | ("python2-futures" ,python2-futures) | |
1182 | ("python2-pygobject" ,python2-pygobject) | |
1183 | ("python2-pyyaml" ,python2-pyyaml) | |
1184 | ("python2-tornado" ,python2-tornado) | |
1185 | ("python2-ws4py" ,python2-ws4py-for-kaldi-gstreamer-server))) | |
1186 | (home-page "https://github.com/alumae/kaldi-gstreamer-server") | |
1187 | (synopsis "Real-time full-duplex speech recognition server") | |
1188 | (description "This is a real-time full-duplex speech recognition server, | |
1189 | based on the Kaldi toolkit and the GStreamer framework and implemented in | |
1190 | Python.") | |
1191 | (license license:bsd-2)))) | |
0dfeb285 RW |
1192 | |
1193 | (define-public grpc | |
1194 | (package | |
1195 | (name "grpc") | |
1196 | (version "1.16.1") | |
1197 | (source (origin | |
1198 | (method git-fetch) | |
1199 | (uri (git-reference | |
1200 | (url "https://github.com/grpc/grpc.git") | |
1201 | (commit (string-append "v" version)))) | |
1202 | (file-name (git-file-name name version)) | |
1203 | (sha256 | |
1204 | (base32 | |
1205 | "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2")))) | |
1206 | (build-system cmake-build-system) | |
1207 | (arguments | |
1208 | `(#:tests? #f ; no test target | |
1209 | #:configure-flags | |
1210 | (list "-DgRPC_ZLIB_PROVIDER=package" | |
1211 | "-DgRPC_CARES_PROVIDER=package" | |
1212 | "-DgRPC_SSL_PROVIDER=package" | |
1213 | "-DgRPC_PROTOBUF_PROVIDER=package"))) | |
1214 | (inputs | |
1215 | `(("c-ares" ,c-ares-next) | |
1216 | ("openssl" ,openssl) | |
1217 | ("zlib" ,zlib))) | |
1218 | (native-inputs | |
1219 | `(("protobuf" ,protobuf-next) | |
1220 | ("python" ,python-wrapper))) | |
1221 | (home-page "https://grpc.io") | |
1222 | (synopsis "High performance universal RPC framework") | |
1223 | (description "gRPC is a modern open source high performance @dfn{Remote | |
1224 | Procedure Call} (RPC) framework that can run in any environment. It can | |
1225 | efficiently connect services in and across data centers with pluggable support | |
1226 | for load balancing, tracing, health checking and authentication. It is also | |
1227 | applicable in last mile of distributed computing to connect devices, mobile | |
1228 | applications and browsers to backend services.") | |
1229 | (license license:asl2.0))) |