gnu: rxcpp: Update to 4.1.0.
[jackhill/guix/guix.git] / gnu / packages / machine-learning.scm
CommitLineData
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>
5ed72097 6;;; Copyright © 2018, 2019 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)
4fa16c9a 52 #:use-module (gnu packages databases)
23aab4ab 53 #:use-module (gnu packages dejagnu)
0931c609 54 #:use-module (gnu packages gcc)
b9445d0b
RW
55 #:use-module (gnu packages glib)
56 #:use-module (gnu packages gstreamer)
5f0ff6a9 57 #:use-module (gnu packages image)
b9445d0b 58 #:use-module (gnu packages linux)
0931c609 59 #:use-module (gnu packages maths)
112c2c01 60 #:use-module (gnu packages mpi)
0a3063d6 61 #:use-module (gnu packages ocaml)
3929f46c 62 #:use-module (gnu packages onc-rpc)
791c11d6 63 #:use-module (gnu packages perl)
c1670a81 64 #:use-module (gnu packages pkg-config)
0dfeb285 65 #:use-module (gnu packages protobuf)
0931c609 66 #:use-module (gnu packages python)
10451f6b 67 #:use-module (gnu packages python-web)
44d10b1f 68 #:use-module (gnu packages python-xyz)
4fa16c9a 69 #:use-module (gnu packages serialization)
c1670a81 70 #:use-module (gnu packages statistics)
4fa16c9a 71 #:use-module (gnu packages sqlite)
c1670a81 72 #:use-module (gnu packages swig)
0dfeb285 73 #:use-module (gnu packages tls)
99260014 74 #:use-module (gnu packages web)
5f0ff6a9 75 #:use-module (gnu packages xml)
39bb4937
RW
76 #:use-module (gnu packages xorg)
77 #:use-module (ice-9 match))
741115b6 78
a9b34762
MM
79(define-public fann
80 ;; The last release is >100 commits behind, so we package from git.
81 (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7"))
82 (package
83 (name "fann")
84 (version (string-append "2.2.0-1." (string-take commit 8)))
85 (source (origin
86 (method git-fetch)
87 (uri (git-reference
88 (url "https://github.com/libfann/fann.git")
89 (commit commit)))
90 (file-name (string-append name "-" version "-checkout"))
91 (sha256
92 (base32
93 "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x"))))
94 (build-system cmake-build-system)
95 (arguments
96 `(#:phases
97 (modify-phases %standard-phases
98 (replace 'check
99 (lambda* (#:key outputs #:allow-other-keys)
100 (let* ((out (assoc-ref outputs "out")))
101 (with-directory-excursion (string-append (getcwd) "/tests")
102 (invoke "./fann_tests"))))))))
103 (home-page "http://leenissen.dk/fann/wp/")
104 (synopsis "Fast Artificial Neural Network")
105 (description
106 "FANN is a free open source neural network library, which implements
107multilayer artificial neural networks in C with support for both fully
108connected and sparsely connected networks.")
109 (license license:lgpl2.1))))
110
741115b6
RW
111(define-public libsvm
112 (package
113 (name "libsvm")
2cffa2f2 114 (version "3.23")
741115b6
RW
115 (source
116 (origin
117 (method url-fetch)
d1308c5e
TGR
118 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
119 name "-" version ".tar.gz"))
741115b6 120 (sha256
2cffa2f2 121 (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5"))))
741115b6
RW
122 (build-system gnu-build-system)
123 (arguments
2cffa2f2 124 `(#:tests? #f ; no "check" target
741115b6
RW
125 #:phases (modify-phases %standard-phases
126 (delete 'configure)
127 (replace
d1308c5e 128 'install ; no ‘install’ target
741115b6
RW
129 (lambda* (#:key outputs #:allow-other-keys)
130 (let* ((out (assoc-ref outputs "out"))
131 (bin (string-append out "/bin/")))
132 (mkdir-p bin)
133 (for-each (lambda (file)
134 (copy-file file (string-append bin file)))
135 '("svm-train"
136 "svm-predict"
137 "svm-scale")))
138 #t)))))
139 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
140 (synopsis "Library for Support Vector Machines")
141 (description
142 "LIBSVM is a machine learning library for support vector
143classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
144distribution estimation (one-class SVM). It supports multi-class
145classification.")
146 (license license:bsd-3)))
71f80f54
RW
147
148(define-public python-libsvm
149 (package (inherit libsvm)
150 (name "python-libsvm")
151 (build-system gnu-build-system)
152 (arguments
2cffa2f2 153 `(#:tests? #f ; no "check" target
71f80f54
RW
154 #:make-flags '("-C" "python")
155 #:phases
156 (modify-phases %standard-phases
157 (delete 'configure)
158 (replace
d1308c5e 159 'install ; no ‘install’ target
71f80f54
RW
160 (lambda* (#:key inputs outputs #:allow-other-keys)
161 (let ((site (string-append (assoc-ref outputs "out")
162 "/lib/python"
163 (string-take
164 (string-take-right
165 (assoc-ref inputs "python") 5) 3)
166 "/site-packages/")))
167 (substitute* "python/svm.py"
168 (("../libsvm.so.2") "libsvm.so.2"))
169 (mkdir-p site)
170 (for-each (lambda (file)
171 (copy-file file (string-append site (basename file))))
172 (find-files "python" "\\.py"))
173 (copy-file "libsvm.so.2"
174 (string-append site "libsvm.so.2")))
175 #t)))))
176 (inputs
177 `(("python" ,python)))
178 (synopsis "Python bindings of libSVM")))
0931c609 179
23aab4ab
RW
180(define-public ghmm
181 ;; The latest release candidate is several years and a couple of fixes have
182 ;; been published since. This is why we download the sources from the SVN
183 ;; repository.
184 (let ((svn-revision 2341))
185 (package
186 (name "ghmm")
187 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
188 (source (origin
189 (method svn-fetch)
190 (uri (svn-reference
191 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
192 (revision svn-revision)))
193 (file-name (string-append name "-" version))
194 (sha256
195 (base32
196 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
197 (build-system gnu-build-system)
198 (arguments
ced12a7b
RW
199 `(#:imported-modules (,@%gnu-build-system-modules
200 (guix build python-build-system))
201 #:phases
23aab4ab
RW
202 (modify-phases %standard-phases
203 (add-after 'unpack 'enter-dir
204 (lambda _ (chdir "ghmm") #t))
ced12a7b
RW
205 (delete 'check)
206 (add-after 'install 'check
207 (assoc-ref %standard-phases 'check))
208 (add-before 'check 'fix-PYTHONPATH
209 (lambda* (#:key inputs outputs #:allow-other-keys)
210 (let ((python-version ((@@ (guix build python-build-system)
211 get-python-version)
212 (assoc-ref inputs "python"))))
213 (setenv "PYTHONPATH"
214 (string-append (getenv "PYTHONPATH")
215 ":" (assoc-ref outputs "out")
216 "/lib/python" python-version
217 "/site-packages")))
23aab4ab
RW
218 #t))
219 (add-after 'enter-dir 'fix-runpath
220 (lambda* (#:key outputs #:allow-other-keys)
221 (substitute* "ghmmwrapper/setup.py"
222 (("^(.*)extra_compile_args = \\[" line indent)
223 (string-append indent
224 "extra_link_args = [\"-Wl,-rpath="
225 (assoc-ref outputs "out") "/lib\"],\n"
226 line
227 "\"-Wl,-rpath="
228 (assoc-ref outputs "out")
229 "/lib\", ")))
230 #t))
231 (add-after 'enter-dir 'disable-broken-tests
232 (lambda _
233 (substitute* "tests/Makefile.am"
234 ;; GHMM_SILENT_TESTS is assumed to be a command.
235 (("TESTS_ENVIRONMENT.*") "")
236 ;; Do not build broken tests.
237 (("chmm .*") "")
238 (("read_fa .*") "")
239 (("mcmc .*") "")
240 (("label_higher_order_test.*$")
241 "label_higher_order_test\n"))
242
243 ;; These Python unittests are broken as there is no gato.
244 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
245 (substitute* "ghmmwrapper/ghmmunittests.py"
246 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
247 line indent)
248 (string-append indent
249 "@unittest.skip(\"Disabled by Guix\")\n"
250 line)))
251 #t))
d10092b8 252 (add-after 'disable-broken-tests 'autogen
23aab4ab 253 (lambda _
3107259f 254 (invoke "bash" "autogen.sh"))))))
23aab4ab
RW
255 (inputs
256 `(("python" ,python-2) ; only Python 2 is supported
257 ("libxml2" ,libxml2)))
258 (native-inputs
259 `(("pkg-config" ,pkg-config)
260 ("dejagnu" ,dejagnu)
261 ("swig" ,swig)
262 ("autoconf" ,autoconf)
263 ("automake" ,automake)
264 ("libtool" ,libtool)))
265 (home-page "http://ghmm.org")
266 (synopsis "Hidden Markov Model library")
267 (description
268 "The General Hidden Markov Model library (GHMM) is a C library with
269additional Python bindings implementing a wide range of types of @dfn{Hidden
d1e4ad1b 270Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
23aab4ab
RW
271training, HMM clustering, HMM mixtures.")
272 (license license:lgpl2.0+))))
273
791c11d6
BW
274(define-public mcl
275 (package
276 (name "mcl")
277 (version "14.137")
278 (source (origin
279 (method url-fetch)
280 (uri (string-append
281 "http://micans.org/mcl/src/mcl-"
282 (string-replace-substring version "." "-")
283 ".tar.gz"))
284 (sha256
285 (base32
286 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
287 (build-system gnu-build-system)
288 (arguments
289 `(#:configure-flags (list "--enable-blast")))
290 (inputs
291 `(("perl" ,perl)))
292 (home-page "http://micans.org/mcl/")
293 (synopsis "Clustering algorithm for graphs")
294 (description
295 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
296fast and scalable unsupervised cluster algorithm for graphs (also known as
297networks) based on simulation of (stochastic) flow in graphs.")
298 ;; In the LICENCE file and web page it says "The software is licensed
299 ;; under the GNU General Public License, version 3.", but in several of
300 ;; the source code files it suggests GPL3 or later.
301 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
302 (license license:gpl3)))
303
0a3063d6
BW
304(define-public ocaml-mcl
305 (package
306 (name "ocaml-mcl")
307 (version "12-068oasis4")
308 (source
309 (origin
fb168a31
RW
310 (method git-fetch)
311 (uri (git-reference
312 (url "https://github.com/fhcrc/mcl.git")
313 (commit version)))
314 (file-name (git-file-name name version))
0a3063d6
BW
315 (sha256
316 (base32
fb168a31 317 "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p"))))
0a3063d6
BW
318 (build-system ocaml-build-system)
319 (arguments
b24aaeec 320 `(#:phases
0a3063d6
BW
321 (modify-phases %standard-phases
322 (add-before 'configure 'patch-paths
323 (lambda _
324 (substitute* "configure"
b24aaeec 325 (("/bin/sh") (which "sh")))
0a3063d6
BW
326 (substitute* "setup.ml"
327 (("LDFLAGS=-fPIC")
b24aaeec
RW
328 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh")))
329 (("-std=c89") "-std=gnu99")
330
331 ;; This is a mutable string, which is no longer supported. Use
332 ;; a byte buffer instead.
333 (("String.make \\(String.length s\\)")
334 "Bytes.make (String.length s)")
335
336 ;; These two belong together.
337 (("OASISString.replace_chars")
338 "Bytes.to_string (OASISString.replace_chars")
339 ((" s;")
340 " s);"))
341 (substitute* "myocamlbuild.ml"
342 (("std=c89") "std=gnu99"))
343 ;; Since we build with a more recent OCaml, we have to use C99 or
344 ;; later. This causes problems with the old C code.
345 (substitute* "src/impala/matrix.c"
346 (("restrict") "restrict_"))
0a3063d6 347 #t)))))
b24aaeec
RW
348 (native-inputs
349 `(("ocamlbuild" ,ocamlbuild)))
0a3063d6
BW
350 (home-page "https://github.com/fhcrc/mcl")
351 (synopsis "OCaml wrappers around MCL")
352 (description
353 "This package provides OCaml bindings for the MCL graph clustering
354algorithm.")
355 (license license:gpl3)))
356
0931c609
RW
357(define-public randomjungle
358 (package
359 (name "randomjungle")
360 (version "2.1.0")
361 (source
362 (origin
363 (method url-fetch)
364 (uri (string-append
df4c8434
BH
365 "https://www.imbs.uni-luebeck.de/fileadmin/files/Software"
366 "/randomjungle/randomjungle-" version ".tar_.gz"))
1e92d311 367 (patches (search-patches "randomjungle-disable-static-build.patch"))
0931c609
RW
368 (sha256
369 (base32
370 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
371 (build-system gnu-build-system)
372 (arguments
373 `(#:configure-flags
1e92d311
MB
374 (list "--disable-static"
375 (string-append "--with-boost="
0931c609
RW
376 (assoc-ref %build-inputs "boost")))
377 #:phases
378 (modify-phases %standard-phases
379 (add-before
380 'configure 'set-CXXFLAGS
381 (lambda _
382 (setenv "CXXFLAGS" "-fpermissive ")
383 #t)))))
384 (inputs
385 `(("boost" ,boost)
386 ("gsl" ,gsl)
387 ("libxml2" ,libxml2)
388 ("zlib" ,zlib)))
389 (native-inputs
25e0037a
EF
390 `(("gfortran" ,gfortran)
391 ("gfortran:lib" ,gfortran "lib")))
47818201
RW
392 ;; Non-portable assembly instructions are used so building fails on
393 ;; platforms other than x86_64 or i686.
394 (supported-systems '("x86_64-linux" "i686-linux"))
df4c8434 395 (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224")
0931c609
RW
396 (synopsis "Implementation of the Random Forests machine learning method")
397 (description
398 "Random Jungle is an implementation of Random Forests. It is supposed to
399analyse high dimensional data. In genetics, it can be used for analysing big
400Genome Wide Association (GWA) data. Random Forests is a powerful machine
401learning method. Most interesting features are variable selection, missing
402value imputation, classifier creation, generalization error estimation and
403sample proximities between pairs of cases.")
404 (license license:gpl3+)))
c1670a81 405
7d4cab74
RW
406(define-public openfst
407 (package
408 (name "openfst")
5ed72097 409 (version "1.7.2")
7d4cab74
RW
410 (source (origin
411 (method url-fetch)
412 (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
413 "FstDownload/openfst-" version ".tar.gz"))
414 (sha256
415 (base32
5ed72097 416 "0fqgk8195kz21is09gwzwnrg7fr9526bi9mh4apyskapz27pbhr1"))))
7d4cab74
RW
417 (build-system gnu-build-system)
418 (home-page "http://www.openfst.org")
419 (synopsis "Library for weighted finite-state transducers")
420 (description "OpenFst is a library for constructing, combining,
421optimizing, and searching weighted finite-state transducers (FSTs).")
422 (license license:asl2.0)))
423
c1670a81
RW
424(define-public shogun
425 (package
426 (name "shogun")
5a14e81e 427 (version "6.1.3")
c1670a81
RW
428 (source
429 (origin
430 (method url-fetch)
431 (uri (string-append
432 "ftp://shogun-toolbox.org/shogun/releases/"
433 (version-major+minor version)
434 "/sources/shogun-" version ".tar.bz2"))
435 (sha256
436 (base32
5a14e81e 437 "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp"))
c1670a81
RW
438 (modules '((guix build utils)
439 (ice-9 rdelim)))
440 (snippet
441 '(begin
442 ;; Remove non-free sources and files referencing them
443 (for-each delete-file
444 (find-files "src/shogun/classifier/svm/"
445 "SVMLight\\.(cpp|h)"))
446 (for-each delete-file
447 (find-files "examples/undocumented/libshogun/"
448 (string-append
449 "(classifier_.*svmlight.*|"
450 "evaluation_cross_validation_locked_comparison).cpp")))
451 ;; Remove non-free functions.
452 (define (delete-ifdefs file)
453 (with-atomic-file-replacement file
454 (lambda (in out)
455 (let loop ((line (read-line in 'concat))
456 (skipping? #f))
457 (if (eof-object? line)
458 #t
459 (let ((skip-next?
460 (or (and skipping?
461 (not (string-prefix?
462 "#endif //USE_SVMLIGHT" line)))
463 (string-prefix?
464 "#ifdef USE_SVMLIGHT" line))))
465 (when (or (not skipping?)
466 (and skipping? (not skip-next?)))
467 (display line out))
468 (loop (read-line in 'concat) skip-next?)))))))
5a14e81e
KK
469 (for-each delete-ifdefs
470 (append
471 (find-files "src/shogun/classifier/mkl"
472 "^MKLClassification\\.cpp")
473 (find-files "src/shogun/classifier/svm"
474 "^SVMLightOneClass\\.(cpp|h)")
475 (find-files "src/shogun/multiclass"
476 "^ScatterSVM\\.(cpp|h)")
477 (find-files "src/shogun/kernel/"
478 "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)")
479 (find-files "src/shogun/regression/svr"
480 "^(MKLRegression|SVRLight)\\.(cpp|h)")
481 (find-files "src/shogun/transfer/domain_adaptation"
c0d7c124 482 "^DomainAdaptationSVM\\.(cpp|h)")))
6cbee49d 483 #t))))
c1670a81
RW
484 (build-system cmake-build-system)
485 (arguments
486 '(#:tests? #f ;no check target
487 #:phases
dc1d3cde
KK
488 (modify-phases %standard-phases
489 (add-after 'unpack 'delete-broken-symlinks
490 (lambda _
491 (for-each delete-file '("applications/arts/data"
492 "applications/asp/data"
493 "applications/easysvm/data"
494 "applications/msplicer/data"
495 "applications/ocr/data"
5a14e81e
KK
496 "examples/meta/data"
497 "examples/undocumented/data"))
dc1d3cde
KK
498 #t))
499 (add-after 'unpack 'change-R-target-path
500 (lambda* (#:key outputs #:allow-other-keys)
5a14e81e
KK
501 (substitute* '("src/interfaces/r/CMakeLists.txt"
502 "examples/meta/r/CMakeLists.txt")
dc1d3cde
KK
503 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
504 (string-append (assoc-ref outputs "out")
505 "/lib/R/library/")))
506 #t))
507 (add-after 'unpack 'fix-octave-modules
508 (lambda* (#:key outputs #:allow-other-keys)
5a14e81e 509 (substitute* "src/interfaces/octave/CMakeLists.txt"
dc1d3cde 510 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
5a14e81e
KK
511 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave")
512 ;; change target directory
dc1d3cde
KK
513 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
514 (string-append (assoc-ref outputs "out")
515 "/share/octave/packages")))
5a14e81e
KK
516 (substitute* '("src/interfaces/octave/swig_typemaps.i"
517 "src/interfaces/octave/sg_print_functions.cpp")
518 ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave.
519 (("octave/config\\.h") "octave/octave-config.h")
520 (("octave/oct-obj.h") "octave/ovl.h"))
dc1d3cde 521 #t))
5a14e81e
KK
522 (add-after 'unpack 'move-rxcpp
523 (lambda* (#:key inputs #:allow-other-keys)
524 (let ((rxcpp-dir "shogun/third-party/rxcpp"))
525 (mkdir-p rxcpp-dir)
526 (install-file (assoc-ref inputs "rxcpp") rxcpp-dir)
527 #t)))
dc1d3cde 528 (add-before 'build 'set-HOME
c1670a81 529 ;; $HOME needs to be set at some point during the build phase
dc1d3cde 530 (lambda _ (setenv "HOME" "/tmp") #t)))
c1670a81
RW
531 #:configure-flags
532 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
533 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
5a14e81e
KK
534 "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags
535 ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas
536 ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray
537 ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist
538 ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file
539 "-DINTERFACE_OCTAVE=ON"
540 "-DINTERFACE_PYTHON=ON"
541 "-DINTERFACE_R=ON")))
c1670a81
RW
542 (inputs
543 `(("python" ,python)
544 ("numpy" ,python-numpy)
2d7c4ae3 545 ("r-minimal" ,r-minimal)
5537603f 546 ("octave" ,octave-cli)
c1670a81 547 ("swig" ,swig)
5a14e81e 548 ("eigen" ,eigen)
c1670a81
RW
549 ("hdf5" ,hdf5)
550 ("atlas" ,atlas)
551 ("arpack" ,arpack-ng)
552 ("lapack" ,lapack)
553 ("glpk" ,glpk)
554 ("libxml2" ,libxml2)
555 ("lzo" ,lzo)
556 ("zlib" ,zlib)))
557 (native-inputs
5a14e81e
KK
558 `(("pkg-config" ,pkg-config)
559 ("rxcpp" ,rxcpp)))
6b5b656f
RW
560 ;; Non-portable SSE instructions are used so building fails on platforms
561 ;; other than x86_64.
562 (supported-systems '("x86_64-linux"))
c1670a81
RW
563 (home-page "http://shogun-toolbox.org/")
564 (synopsis "Machine learning toolbox")
565 (description
566 "The Shogun Machine learning toolbox provides a wide range of unified and
567efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
568combine multiple data representations, algorithm classes, and general purpose
569tools. This enables both rapid prototyping of data pipelines and extensibility
570in terms of new algorithms.")
571 (license license:gpl3+)))
8406138b 572
3a354e10
KK
573(define-public rxcpp
574 (package
575 (name "rxcpp")
e91a0bff 576 (version "4.1.0")
3a354e10
KK
577 (source
578 (origin
579 (method url-fetch)
580 (uri (string-append "https://github.com/ReactiveX/RxCpp/archive/v"
581 version ".tar.gz"))
582 (sha256
e91a0bff 583 (base32 "1smxrcm0s6bz05185dx1i2xjgn47rq7m247pblil6p3bmk3lkfyk"))
3a354e10
KK
584 (file-name (string-append name "-" version ".tar.gz"))))
585 (build-system cmake-build-system)
586 (arguments
587 `(#:phases
588 (modify-phases %standard-phases
589 (add-after 'unpack 'remove-werror
590 (lambda _
591 (substitute* (find-files ".")
592 (("-Werror") ""))
593 #t))
594 (replace 'check
595 (lambda _
596 (invoke "ctest"))))))
597 (native-inputs
598 `(("catch" ,catch-framework)))
599 (home-page "http://reactivex.io/")
600 (synopsis "Reactive Extensions for C++")
601 (description
602 "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for
603values-distributed-in-time. ReactiveX is a library for composing asynchronous
604and event-based programs by using observable sequences.
605
606It extends the observer pattern to support sequences of data and/or events and
607adds operators that allow you to compose sequences together declaratively while
608abstracting away concerns about things like low-level threading,
609synchronization, thread-safety, concurrent data structures, and non-blocking
610I/O.")
611 (license license:asl2.0)))
612
8406138b
RW
613(define-public r-adaptivesparsity
614 (package
615 (name "r-adaptivesparsity")
c0608f81 616 (version "1.6")
8406138b
RW
617 (source (origin
618 (method url-fetch)
619 (uri (cran-uri "AdaptiveSparsity" version))
620 (sha256
621 (base32
c0608f81 622 "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91"))))
8406138b
RW
623 (properties
624 `((upstream-name . "AdaptiveSparsity")))
625 (build-system r-build-system)
626 (arguments
627 `(#:phases
628 (modify-phases %standard-phases
629 (add-after 'unpack 'link-against-armadillo
630 (lambda _
631 (substitute* "src/Makevars"
632 (("PKG_LIBS=" prefix)
633 (string-append prefix "-larmadillo"))))))))
634 (propagated-inputs
c0608f81
RW
635 `(("r-mass" ,r-mass)
636 ("r-matrix" ,r-matrix)
637 ("r-rcpp" ,r-rcpp)
8406138b 638 ("r-rcpparmadillo" ,r-rcpparmadillo)))
60e36bff
LC
639 (inputs
640 `(("armadillo" ,armadillo)))
e9960d8c 641 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
8406138b
RW
642 (synopsis "Adaptive sparsity models")
643 (description
644 "This package implements the Figueiredo machine learning algorithm for
645adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
646geometric models.")
647 (license license:lgpl3+)))
e4785eb8 648
39bb4937
RW
649(define-public gemmlowp-for-tensorflow
650 ;; The commit hash is taken from "tensorflow/workspace.bzl".
651 (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98")
652 (revision "2"))
653 (package
654 (name "gemmlowp")
655 (version (git-version "0" revision commit))
656 (source (origin
657 (method url-fetch)
658 (uri (string-append "https://mirror.bazel.build/"
659 "github.com/google/gemmlowp/archive/"
660 commit ".zip"))
661 (file-name (string-append "gemmlowp-" version ".zip"))
662 (sha256
663 (base32
664 "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq"))))
665 (build-system cmake-build-system)
666 (arguments
667 `(#:configure-flags
668 (list ,@(match (%current-system)
669 ((or "x86_64-linux" "i686-linux")
670 '("-DCMAKE_CXX_FLAGS=-msse4.1"))
671 (_ '())))
672 #:phases
673 (modify-phases %standard-phases
674 ;; This directory contains the CMakeLists.txt.
675 (add-after 'unpack 'chdir
676 (lambda _ (chdir "contrib") #t))
677 ;; There is no install target
678 (replace 'install
679 (lambda* (#:key outputs #:allow-other-keys)
680 (let* ((out (assoc-ref outputs "out"))
681 (lib (string-append out "/lib/"))
682 (inc (string-append out "/include/")))
683 (install-file "../build/libeight_bit_int_gemm.so" lib)
684 (for-each (lambda (dir)
685 (let ((target (string-append inc "/" dir)))
686 (mkdir-p target)
687 (for-each (lambda (h)
688 (install-file h target))
689 (find-files (string-append "../" dir)
690 "\\.h$"))))
691 '("meta" "profiling" "public" "fixedpoint"
692 "eight_bit_int_gemm" "internal"))
693 #t))))))
694 (native-inputs
695 `(("unzip" ,unzip)))
696 (home-page "https://github.com/google/gemmlowp")
697 (synopsis "Small self-contained low-precision GEMM library")
698 (description
699 "This is a small self-contained low-precision @dfn{general matrix
700multiplication} (GEMM) library. It is not a full linear algebra library.
701Low-precision means that the input and output matrix entries are integers on
702at most 8 bits. To avoid overflow, results are internally accumulated on more
703than 8 bits, and at the end only some significant 8 bits are kept.")
704 (license license:asl2.0))))
705
5f0ff6a9
MB
706(define-public dlib
707 (package
708 (name "dlib")
abe97a58 709 (version "19.7")
5f0ff6a9
MB
710 (source (origin
711 (method url-fetch)
712 (uri (string-append
713 "http://dlib.net/files/dlib-" version ".tar.bz2"))
714 (sha256
715 (base32
abe97a58 716 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
5f0ff6a9
MB
717 (modules '((guix build utils)))
718 (snippet
719 '(begin
720 ;; Delete ~13MB of bundled dependencies.
721 (delete-file-recursively "dlib/external")
0ef7ea66
MB
722 (delete-file-recursively "docs/dlib/external")
723 #t))))
5f0ff6a9
MB
724 (build-system cmake-build-system)
725 (arguments
677bc34d 726 `(#:phases
5f0ff6a9
MB
727 (modify-phases %standard-phases
728 (add-after 'unpack 'disable-asserts
729 (lambda _
730 ;; config.h recommends explicitly enabling or disabling asserts
731 ;; when building as a shared library. By default neither is set.
732 (substitute* "dlib/config.h"
733 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
734 #t))
4fba38db
MB
735 (add-after 'disable-asserts 'disable-failing-tests
736 (lambda _
737 ;; One test times out on MIPS, so we need to disable it.
0ef7ea66 738 ;; Others are flaky on some platforms.
4fba38db
MB
739 (let* ((system ,(or (%current-target-system)
740 (%current-system)))
741 (disabled-tests (cond
742 ((string-prefix? "mips64" system)
743 '("object_detector" ; timeout
744 "data_io"))
745 ((string-prefix? "armhf" system)
a343c461 746 '("learning_to_track"))
4fba38db 747 ((string-prefix? "i686" system)
0ef7ea66 748 '("optimization"))
4fba38db 749 (else '()))))
4fba38db
MB
750 (for-each
751 (lambda (test)
752 (substitute* "dlib/test/makefile"
0ef7ea66
MB
753 (((string-append "SRC \\+= " test "\\.cpp")) "")))
754 disabled-tests)
755 #t)))
5f0ff6a9
MB
756 (replace 'check
757 (lambda _
758 ;; No test target, so we build and run the unit tests here.
8eaf53e3 759 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
5f0ff6a9 760 (with-directory-excursion test-dir
8448e6bf
TGR
761 (invoke "make" "-j" (number->string (parallel-job-count)))
762 (invoke "./dtest" "--runall"))
763 #t)))
5f0ff6a9
MB
764 (add-after 'install 'delete-static-library
765 (lambda* (#:key outputs #:allow-other-keys)
0ef7ea66
MB
766 (delete-file (string-append (assoc-ref outputs "out")
767 "/lib/libdlib.a"))
768 #t)))))
5f0ff6a9 769 (native-inputs
3929f46c
TGR
770 `(("pkg-config" ,pkg-config)
771 ;; For tests.
772 ("libnsl" ,libnsl)))
5f0ff6a9 773 (inputs
f40841e9 774 `(("giflib" ,giflib)
4fba38db 775 ("lapack" ,lapack)
5f0ff6a9
MB
776 ("libjpeg" ,libjpeg)
777 ("libpng" ,libpng)
778 ("libx11" ,libx11)
779 ("openblas" ,openblas)
780 ("zlib" ,zlib)))
781 (synopsis
782 "Toolkit for making machine learning and data analysis applications in C++")
783 (description
784 "Dlib is a modern C++ toolkit containing machine learning algorithms and
785tools. It is used in both industry and academia in a wide range of domains
786including robotics, embedded devices, mobile phones, and large high performance
787computing environments.")
788 (home-page "http://dlib.net")
789 (license license:boost1.0)))
be6eb2f1
RW
790
791(define-public python-scikit-learn
792 (package
793 (name "python-scikit-learn")
7ff3f3d2 794 (version "0.20.1")
be6eb2f1
RW
795 (source
796 (origin
4a89bdd1
RW
797 (method git-fetch)
798 (uri (git-reference
799 (url "https://github.com/scikit-learn/scikit-learn.git")
800 (commit version)))
801 (file-name (git-file-name name version))
be6eb2f1
RW
802 (sha256
803 (base32
650bc942 804 "0fkhwg3xn1s7ln9q1szq6kwc4jhwvjh8w4kmv9wcrqy7cq3lbv0d"))))
be6eb2f1
RW
805 (build-system python-build-system)
806 (arguments
807 `(#:phases
808 (modify-phases %standard-phases
4a89bdd1
RW
809 (add-after 'build 'build-ext
810 (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t))
811 (replace 'check
812 (lambda _
813 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
814 (setenv "OPENBLAS_NUM_THREADS" "1")
7ff3f3d2
MB
815
816 ;; Some tests require write access to $HOME.
817 (setenv "HOME" "/tmp")
818
819 (invoke "pytest" "sklearn" "-m" "not network")))
4a89bdd1
RW
820 ;; FIXME: This fails with permission denied
821 (delete 'reset-gzip-timestamps))))
be6eb2f1
RW
822 (inputs
823 `(("openblas" ,openblas)))
824 (native-inputs
4a89bdd1
RW
825 `(("python-pytest" ,python-pytest)
826 ("python-pandas" ,python-pandas) ;for tests
be6eb2f1
RW
827 ("python-cython" ,python-cython)))
828 (propagated-inputs
829 `(("python-numpy" ,python-numpy)
830 ("python-scipy" ,python-scipy)))
831 (home-page "http://scikit-learn.org/")
832 (synopsis "Machine Learning in Python")
833 (description
4a89bdd1
RW
834 "Scikit-learn provides simple and efficient tools for data mining and
835data analysis.")
be6eb2f1
RW
836 (license license:bsd-3)))
837
838(define-public python2-scikit-learn
7ff3f3d2 839 (package-with-python2 python-scikit-learn))
2dab4188
FT
840
841(define-public python-autograd
842 (let* ((commit "442205dfefe407beffb33550846434baa90c4de7")
843 (revision "0")
844 (version (git-version "0.0.0" revision commit)))
845 (package
846 (name "python-autograd")
847 (home-page "https://github.com/HIPS/autograd")
848 (source (origin
849 (method git-fetch)
850 (uri (git-reference
851 (url home-page)
852 (commit commit)))
853 (sha256
854 (base32
855 "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4"))
856 (file-name (git-file-name name version))))
857 (version version)
858 (build-system python-build-system)
859 (native-inputs
860 `(("python-nose" ,python-nose)
861 ("python-pytest" ,python-pytest)))
862 (propagated-inputs
863 `(("python-future" ,python-future)
864 ("python-numpy" ,python-numpy)))
865 (arguments
866 `(#:phases (modify-phases %standard-phases
867 (replace 'check
868 (lambda _
869 (invoke "py.test" "-v"))))))
870 (synopsis "Efficiently computes derivatives of NumPy code")
871 (description "Autograd can automatically differentiate native Python and
872NumPy code. It can handle a large subset of Python's features, including loops,
873ifs, recursion and closures, and it can even take derivatives of derivatives
874of derivatives. It supports reverse-mode differentiation
875(a.k.a. backpropagation), which means it can efficiently take gradients of
876scalar-valued functions with respect to array-valued arguments, as well as
877forward-mode differentiation, and the two can be composed arbitrarily. The
878main intended application of Autograd is gradient-based optimization.")
879 (license license:expat))))
880
881(define-public python2-autograd
882 (package-with-python2 python-autograd))
112c2c01
FT
883
884(define-public lightgbm
885 (package
886 (name "lightgbm")
887 (version "2.0.12")
888 (source (origin
889 (method url-fetch)
890 (uri (string-append
891 "https://github.com/Microsoft/LightGBM/archive/v"
892 version ".tar.gz"))
893 (sha256
894 (base32
895 "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1"))
896 (file-name (string-append name "-" version ".tar.gz"))))
897 (native-inputs
898 `(("python-pytest" ,python-pytest)
899 ("python-nose" ,python-nose)))
900 (inputs
901 `(("openmpi" ,openmpi)))
902 (propagated-inputs
903 `(("python-numpy" ,python-numpy)
904 ("python-scipy" ,python-scipy)))
905 (arguments
906 `(#:configure-flags
907 '("-DUSE_MPI=ON")
908 #:phases
909 (modify-phases %standard-phases
910 (replace 'check
911 (lambda* (#:key outputs #:allow-other-keys)
912 (with-directory-excursion ,(string-append "../LightGBM-" version)
913 (invoke "pytest" "tests/c_api_test/test_.py")))))))
914 (build-system cmake-build-system)
915 (home-page "https://github.com/Microsoft/LightGBM")
916 (synopsis "Gradient boosting framework based on decision tree algorithms")
917 (description "LightGBM is a gradient boosting framework that uses tree
918based learning algorithms. It is designed to be distributed and efficient with
919the following advantages:
920
921@itemize
922@item Faster training speed and higher efficiency
923@item Lower memory usage
924@item Better accuracy
925@item Parallel and GPU learning supported (not enabled in this package)
926@item Capable of handling large-scale data
927@end itemize\n")
928 (license license:expat)))
a8fb82a8
FT
929
930(define-public vowpal-wabbit
931 ;; Language bindings not included.
932 (package
933 (name "vowpal-wabbit")
934 (version "8.5.0")
935 (source (origin
936 (method url-fetch)
937 (uri (string-append
938 "https://github.com/JohnLangford/vowpal_wabbit/archive/"
939 version ".tar.gz"))
940 (sha256
941 (base32
942 "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr"))
943 (file-name (string-append name "-" version ".tar.gz"))))
944 (inputs
945 `(("boost" ,boost)
946 ("zlib" ,zlib)))
947 (arguments
948 `(#:configure-flags
949 (list (string-append "--with-boost="
950 (assoc-ref %build-inputs "boost")))))
951 (build-system gnu-build-system)
952 (home-page "https://github.com/JohnLangford/vowpal_wabbit")
953 (synopsis "Fast machine learning library for online learning")
954 (description "Vowpal Wabbit is a machine learning system with techniques
955such as online, hashing, allreduce, reductions, learning2search, active, and
956interactive learning.")
957 (license license:bsd-3)))
915c6bf6
LC
958
959(define-public python2-fastlmm
960 (package
961 (name "python2-fastlmm")
962 (version "0.2.21")
963 (source
964 (origin
965 (method url-fetch)
966 (uri (pypi-uri "fastlmm" version ".zip"))
967 (sha256
968 (base32
969 "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m"))))
970 (build-system python-build-system)
971 (arguments
237ee6f2
RW
972 `(#:tests? #f ; some test files are missing
973 #:python ,python-2)) ; only Python 2.7 is supported
915c6bf6
LC
974 (propagated-inputs
975 `(("python2-numpy" ,python2-numpy)
976 ("python2-scipy" ,python2-scipy)
977 ("python2-matplotlib" ,python2-matplotlib)
978 ("python2-pandas" ,python2-pandas)
979 ("python2-scikit-learn" ,python2-scikit-learn)
980 ("python2-pysnptools" ,python2-pysnptools)))
981 (native-inputs
982 `(("unzip" ,unzip)
983 ("python2-cython" ,python2-cython)
984 ("python2-mock" ,python2-mock)
985 ("python2-nose" ,python2-nose)))
986 (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/")
987 (synopsis "Perform genome-wide association studies on large data sets")
988 (description
989 "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed
990Models, is a program for performing both single-SNP and SNP-set genome-wide
991association studies (GWAS) on extremely large data sets.")
992 (license license:asl2.0)))
b9445d0b
RW
993
994;; There have been no proper releases yet.
995(define-public kaldi
996 (let ((commit "2f95609f0bb085bd3a1dc5eb0a39f3edea59e606")
997 (revision "1"))
998 (package
999 (name "kaldi")
1000 (version (git-version "0" revision commit))
1001 (source (origin
1002 (method git-fetch)
1003 (uri (git-reference
1004 (url "https://github.com/kaldi-asr/kaldi.git")
1005 (commit commit)))
1006 (file-name (git-file-name name version))
1007 (sha256
1008 (base32
1009 "082qh3pfi7hvncylp4xsmkfahbd7gb0whdfa4rwrx7fxk9rdh3kz"))))
1010 (build-system gnu-build-system)
1011 (arguments
1012 `(#:test-target "test"
1013 #:phases
1014 (modify-phases %standard-phases
1015 (add-after 'unpack 'chdir
1016 (lambda _ (chdir "src") #t))
1017 (replace 'configure
1018 (lambda* (#:key build system inputs outputs #:allow-other-keys)
1019 (when (not (or (string-prefix? "x86_64" system)
1020 (string-prefix? "i686" system)))
1021 (substitute* "makefiles/linux_openblas.mk"
1022 (("-msse -msse2") "")))
1023 (substitute* "makefiles/default_rules.mk"
1024 (("/bin/bash") (which "bash")))
1025 (substitute* "Makefile"
1026 (("ext_depend: check_portaudio")
1027 "ext_depend:"))
1028 (substitute* '("online/Makefile"
1029 "onlinebin/Makefile"
1030 "gst-plugin/Makefile")
1031 (("../../tools/portaudio/install")
1032 (assoc-ref inputs "portaudio")))
1033
1034 ;; This `configure' script doesn't support variables passed as
1035 ;; arguments, nor does it support "prefix".
1036 (let ((out (assoc-ref outputs "out"))
1037 (openblas (assoc-ref inputs "openblas"))
1038 (openfst (assoc-ref inputs "openfst")))
1039 (substitute* "configure"
1040 (("check_for_slow_expf;") "")
1041 ;; This affects the RPATH and also serves as the installation
1042 ;; directory.
1043 (("KALDILIBDIR=`pwd`/lib")
1044 (string-append "KALDILIBDIR=" out "/lib")))
1045 (mkdir-p out) ; must exist
1046 (setenv "CONFIG_SHELL" (which "bash"))
1047 (setenv "OPENFST_VER" ,(package-version openfst))
1048 (invoke "./configure"
1049 "--use-cuda=no"
1050 "--shared"
1051 (string-append "--openblas-root=" openblas)
1052 (string-append "--fst-root=" openfst)))))
1053 (add-after 'build 'build-ext-and-gstreamer-plugin
1054 (lambda _
1055 (invoke "make" "-C" "online" "depend")
1056 (invoke "make" "-C" "online")
1057 (invoke "make" "-C" "onlinebin" "depend")
1058 (invoke "make" "-C" "onlinebin")
1059 (invoke "make" "-C" "gst-plugin" "depend")
1060 (invoke "make" "-C" "gst-plugin")
1061 #t))
1062 ;; TODO: also install the executables.
1063 (replace 'install
1064 (lambda* (#:key outputs #:allow-other-keys)
1065 (let* ((out (assoc-ref outputs "out"))
1fdd20c7 1066 (inc (string-append out "/include"))
b9445d0b
RW
1067 (lib (string-append out "/lib")))
1068 (mkdir-p lib)
1fdd20c7
RW
1069 ;; The build phase installed symlinks to the actual
1070 ;; libraries. Install the actual targets.
1071 (for-each (lambda (file)
1072 (let ((target (readlink file)))
1073 (delete-file file)
1074 (install-file target lib)))
1075 (find-files lib "\\.so"))
1076 ;; Install headers
1077 (for-each (lambda (file)
1078 (let ((target-dir (string-append inc "/" (dirname file))))
1079 (install-file file target-dir)))
1080 (find-files "." "\\.h"))
1081 (install-file "gst-plugin/libgstonlinegmmdecodefaster.so"
1082 (string-append lib "/gstreamer-1.0"))
b9445d0b
RW
1083 #t))))))
1084 (inputs
1085 `(("alsa-lib" ,alsa-lib)
1086 ("gfortran" ,gfortran "lib")
1087 ("glib" ,glib)
1088 ("gstreamer" ,gstreamer)
1089 ("jack" ,jack-1)
1090 ("openblas" ,openblas)
1091 ("openfst" ,openfst)
1092 ("portaudio" ,portaudio)
1093 ("python" ,python)))
1094 (native-inputs
1095 `(("glib" ,glib "bin") ; glib-genmarshal
1096 ("grep" ,grep)
1097 ("sed" ,sed)
1098 ("pkg-config" ,pkg-config)
1099 ("which" ,which)))
1100 (home-page "https://kaldi-asr.org/")
1101 (synopsis "Speech recognition toolkit")
1102 (description "Kaldi is an extensible toolkit for speech recognition
1103written in C++.")
1104 (license license:asl2.0))))
99260014
RW
1105
1106(define-public gst-kaldi-nnet2-online
1107 (let ((commit "617e43e73c7cc45eb9119028c02bd4178f738c4a")
1108 (revision "1"))
1109 (package
1110 (name "gst-kaldi-nnet2-online")
1111 (version (git-version "0" revision commit))
1112 (source (origin
1113 (method git-fetch)
1114 (uri (git-reference
1115 (url "https://github.com/alumae/gst-kaldi-nnet2-online.git")
1116 (commit commit)))
1117 (file-name (git-file-name name version))
1118 (sha256
1119 (base32
1120 "0xh3w67b69818s6ib02ara4lw7wamjdmh4jznvkpzrs4skbs9jx9"))))
1121 (build-system gnu-build-system)
1122 (arguments
1123 `(#:tests? #f ; there are none
1124 #:make-flags
1125 (list (string-append "SHELL="
1126 (assoc-ref %build-inputs "bash") "/bin/bash")
1127 (string-append "KALDI_ROOT="
1128 (assoc-ref %build-inputs "kaldi-src"))
1129 (string-append "KALDILIBDIR="
1130 (assoc-ref %build-inputs "kaldi") "/lib")
1131 "KALDI_FLAVOR=dynamic")
1132 #:phases
1133 (modify-phases %standard-phases
1134 (add-after 'unpack 'chdir
1135 (lambda _ (chdir "src") #t))
1136 (replace 'configure
1137 (lambda* (#:key inputs #:allow-other-keys)
1138 (let ((glib (assoc-ref inputs "glib")))
1139 (setenv "CXXFLAGS" "-std=c++11 -fPIC")
1140 (setenv "CPLUS_INCLUDE_PATH"
1141 (string-append glib "/include/glib-2.0:"
1142 glib "/lib/glib-2.0/include:"
1143 (assoc-ref inputs "gstreamer")
1144 "/include/gstreamer-1.0:"
1145 (getenv "CPLUS_INCLUDE_PATH"))))
1146 (substitute* "Makefile"
1147 (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "")
1148 (("\\$\\(error Cannot find") "#"))))
1149 (add-before 'build 'build-depend
1150 (lambda* (#:key make-flags #:allow-other-keys)
1151 (apply invoke "make" "depend" make-flags)))
1152 (replace 'install
1153 (lambda* (#:key outputs #:allow-other-keys)
1154 (let* ((out (assoc-ref outputs "out"))
1155 (lib (string-append out "/lib/gstreamer-1.0")))
1156 (install-file "libgstkaldinnet2onlinedecoder.so" lib)
1157 #t))))))
1158 (inputs
1159 `(("glib" ,glib)
1160 ("gstreamer" ,gstreamer)
1161 ("jansson" ,jansson)
1162 ("openfst" ,openfst)
1163 ("kaldi" ,kaldi)))
1164 (native-inputs
1165 `(("bash" ,bash)
1166 ("glib:bin" ,glib "bin") ; glib-genmarshal
1167 ("kaldi-src" ,(package-source kaldi))
1168 ("pkg-config" ,pkg-config)))
1169 (home-page "https://kaldi-asr.org/")
1170 (synopsis "Gstreamer plugin for decoding speech")
1171 (description "This package provides a GStreamer plugin that wraps
1172Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN
1173acoustic models. The iVectors are adapted to the current audio stream
1174automatically.")
1175 (license license:asl2.0))))
10451f6b
RW
1176
1177(define-public kaldi-gstreamer-server
1178 (let ((commit "1735ba49c5dc0ebfc184e45105fc600cd9f1f508")
1179 (revision "1"))
1180 (package
1181 (name "kaldi-gstreamer-server")
1182 (version (git-version "0" revision commit))
1183 (source (origin
1184 (method git-fetch)
1185 (uri (git-reference
1186 (url "https://github.com/alumae/kaldi-gstreamer-server.git")
1187 (commit commit)))
1188 (file-name (git-file-name name version))
1189 (sha256
1190 (base32
1191 "0j701m7lbwmzqxsfanj882v7881hrbmpqybbczbxqpcbg8q34w0k"))))
1192 (build-system gnu-build-system)
1193 (arguments
1194 `(#:tests? #f ; there are no tests that can be run automatically
1195 #:modules ((guix build utils)
1196 (guix build gnu-build-system)
1197 (srfi srfi-26))
1198 #:phases
1199 (modify-phases %standard-phases
1200 (delete 'configure)
1201 (replace 'build
1202 (lambda* (#:key outputs #:allow-other-keys)
1203 ;; Disable hash randomization to ensure the generated .pycs
1204 ;; are reproducible.
1205 (setenv "PYTHONHASHSEED" "0")
1206 (with-directory-excursion "kaldigstserver"
1207 (for-each (lambda (file)
1208 (apply invoke
1209 `("python"
1210 "-m" "compileall"
1211 "-f" ; force rebuild
1212 ,file)))
1213 (find-files "." "\\.py$")))
1214 #t))
1215 (replace 'install
1216 (lambda* (#:key inputs outputs #:allow-other-keys)
1217 (let* ((out (assoc-ref outputs "out"))
1218 (bin (string-append out "/bin"))
1219 (share (string-append out "/share/kaldi-gstreamer-server/")))
1220 ;; Install Python files
1221 (with-directory-excursion "kaldigstserver"
1222 (for-each (cut install-file <> share)
1223 (find-files "." ".*")))
1224
1225 ;; Install sample configuration files
1226 (for-each (cut install-file <> share)
1227 (find-files "." "\\.yaml"))
1228
1229 ;; Install executables
1230 (mkdir-p bin)
1231 (let* ((server (string-append bin "/kaldi-gst-server"))
1232 (client (string-append bin "/kaldi-gst-client"))
1233 (worker (string-append bin "/kaldi-gst-worker"))
1234 (PYTHONPATH (getenv "PYTHONPATH"))
1235 (GST_PLUGIN_PATH (string-append
1236 (assoc-ref inputs "gst-kaldi-nnet2-online")
1237 "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}"))
1238 (wrap (lambda (wrapper what)
1239 (with-output-to-file wrapper
1240 (lambda _
1241 (format #t
1242 "#!~a
1243export PYTHONPATH=~a
1244export GST_PLUGIN_PATH=~a
1245exec ~a ~a/~a \"$@\"~%"
1246 (which "bash") PYTHONPATH GST_PLUGIN_PATH
1247 (which "python") share what)))
1248 (chmod wrapper #o555))))
1249 (for-each wrap
1250 (list server client worker)
1251 (list "master_server.py"
1252 "client.py"
1253 "worker.py")))
1254 #t))))))
1255 (inputs
1256 `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online)
1257 ("python2" ,python-2)
1258 ("python2-futures" ,python2-futures)
1259 ("python2-pygobject" ,python2-pygobject)
1260 ("python2-pyyaml" ,python2-pyyaml)
1261 ("python2-tornado" ,python2-tornado)
1262 ("python2-ws4py" ,python2-ws4py-for-kaldi-gstreamer-server)))
1263 (home-page "https://github.com/alumae/kaldi-gstreamer-server")
1264 (synopsis "Real-time full-duplex speech recognition server")
1265 (description "This is a real-time full-duplex speech recognition server,
1266based on the Kaldi toolkit and the GStreamer framework and implemented in
1267Python.")
1268 (license license:bsd-2))))
0dfeb285
RW
1269
1270(define-public grpc
1271 (package
1272 (name "grpc")
1273 (version "1.16.1")
1274 (source (origin
1275 (method git-fetch)
1276 (uri (git-reference
1277 (url "https://github.com/grpc/grpc.git")
1278 (commit (string-append "v" version))))
1279 (file-name (git-file-name name version))
1280 (sha256
1281 (base32
1282 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
1283 (build-system cmake-build-system)
1284 (arguments
1285 `(#:tests? #f ; no test target
1286 #:configure-flags
1287 (list "-DgRPC_ZLIB_PROVIDER=package"
1288 "-DgRPC_CARES_PROVIDER=package"
1289 "-DgRPC_SSL_PROVIDER=package"
1290 "-DgRPC_PROTOBUF_PROVIDER=package")))
1291 (inputs
1292 `(("c-ares" ,c-ares-next)
1293 ("openssl" ,openssl)
1294 ("zlib" ,zlib)))
1295 (native-inputs
1296 `(("protobuf" ,protobuf-next)
1297 ("python" ,python-wrapper)))
1298 (home-page "https://grpc.io")
1299 (synopsis "High performance universal RPC framework")
1300 (description "gRPC is a modern open source high performance @dfn{Remote
1301Procedure Call} (RPC) framework that can run in any environment. It can
1302efficiently connect services in and across data centers with pluggable support
1303for load balancing, tracing, health checking and authentication. It is also
1304applicable in last mile of distributed computing to connect devices, mobile
1305applications and browsers to backend services.")
1306 (license license:asl2.0)))
4fa16c9a
RW
1307
1308;; Note that Tensorflow includes a "third_party" directory, which seems to not
1309;; only contain modified subsets of upstream library source code, but also
1310;; adapter headers provided by Google (such as the fft.h header, which is not
1311;; part of the upstream project code). The Tensorflow code includes headers
1312;; from the "third_party" directory. It does not look like we can replace
1313;; these headers with unmodified upstream files, so we keep them.
1314(define-public tensorflow
1315 (package
1316 (name "tensorflow")
1317 (version "1.9.0")
1318 (source
1319 (origin
1320 (method git-fetch)
1321 (uri (git-reference
1322 (url "https://github.com/tensorflow/tensorflow.git")
1323 (commit (string-append "v" version))))
1324 (file-name (string-append "tensorflow-" version "-checkout"))
1325 (sha256
1326 (base32
1327 "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa"))))
1328 (build-system cmake-build-system)
1329 (arguments
1330 `(#:tests? #f ; no "check" target
1331 #:build-type "Release"
1332 #:configure-flags
1333 (let ((protobuf (assoc-ref %build-inputs "protobuf"))
1334 (protobuf:native (assoc-ref %build-inputs "protobuf:native"))
1335 (jsoncpp (assoc-ref %build-inputs "jsoncpp"))
1336 (snappy (assoc-ref %build-inputs "snappy"))
1337 (sqlite (assoc-ref %build-inputs "sqlite")))
1338 (list
1339 ;; Use protobuf from Guix
1340 (string-append "-Dprotobuf_STATIC_LIBRARIES="
1341 protobuf "/lib/libprotobuf.so")
1342 (string-append "-DPROTOBUF_PROTOC_EXECUTABLE="
1343 protobuf:native "/bin/protoc")
1344
1345 ;; Use snappy from Guix
1346 (string-append "-Dsnappy_STATIC_LIBRARIES="
1347 snappy "/lib/libsnappy.so")
1348 ;; Yes, this is not actually the include directory but a prefix...
1349 (string-append "-Dsnappy_INCLUDE_DIR=" snappy)
1350
1351 ;; Use jsoncpp from Guix
1352 (string-append "-Djsoncpp_STATIC_LIBRARIES="
1353 jsoncpp "/lib/libjsoncpp.so")
1354 ;; Yes, this is not actually the include directory but a prefix...
1355 (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp)
1356
1357 ;; Use sqlite from Guix
1358 (string-append "-Dsqlite_STATIC_LIBRARIES="
1359 sqlite "/lib/libsqlite.a")
1360
1361 ;; Use system libraries wherever possible. Currently, this
1362 ;; only affects zlib.
1363 "-Dsystemlib_ALL=ON"
1364 "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON"
1365 "-Dtensorflow_BUILD_SHARED_LIB=ON"
1366 "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF"
1367 "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF"
1368 "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF"))
1369 #:make-flags
1370 (list "CC=gcc")
1371 #:modules ((ice-9 ftw)
1372 (guix build utils)
1373 (guix build cmake-build-system))
1374 #:phases
1375 (modify-phases %standard-phases
1376 (add-after 'unpack 'set-source-file-times-to-1980
1377 ;; At the end of the tf_python_build_pip_package target, a ZIP
1378 ;; archive should be generated via bdist_wheel, but it fails with
1379 ;; "ZIP does not support timestamps before 1980". Luckily,
1380 ;; SOURCE_DATE_EPOCH is respected, which we set to some time in
1381 ;; 1980.
1382 (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t))
1383 ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913
1384 (add-after 'unpack 'python3.7-compatibility
1385 (lambda _
1386 (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc"
1387 "tensorflow/python/lib/core/ndarray_tensor.cc"
1388 "tensorflow/python/lib/core/py_func.cc")
1389 (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8"))
1390 (substitute* "tensorflow/c/eager/c_api.h"
1391 (("unsigned char async")
1392 "unsigned char is_async"))
1393
1394 ;; Remove dependency on tensorboard, a complicated but probably
1395 ;; optional package.
1396 (substitute* "tensorflow/tools/pip_package/setup.py"
1397 ((".*'tensorboard >.*") ""))
1398 #t))
1399 (add-after 'python3.7-compatibility 'chdir
1400 (lambda _ (chdir "tensorflow/contrib/cmake") #t))
1401 (add-after 'chdir 'disable-downloads
1402 (lambda* (#:key inputs #:allow-other-keys)
1403 (substitute* (find-files "external" "\\.cmake$")
1404 (("GIT_REPOSITORY.*") "")
1405 (("GIT_TAG.*") "")
1406 (("PREFIX ")
1407 "DOWNLOAD_COMMAND \"\"\nPREFIX "))
1408
1409 ;; Use packages from Guix
1410 (let ((grpc (assoc-ref inputs "grpc")))
1411 (substitute* "CMakeLists.txt"
1412 ;; Sqlite
1413 (("include\\(sqlite\\)") "")
1414 (("\\$\\{sqlite_STATIC_LIBRARIES\\}")
1415 (string-append (assoc-ref inputs "sqlite")
1416 "/lib/libsqlite3.so"))
1417 (("sqlite_copy_headers_to_destination") "")
1418
1419 ;; PNG
1420 (("include\\(png\\)") "")
1421 (("\\$\\{png_STATIC_LIBRARIES\\}")
1422 (string-append (assoc-ref inputs "libpng")
1423 "/lib/libpng16.so"))
1424 (("png_copy_headers_to_destination") "")
1425
1426 ;; JPEG
1427 (("include\\(jpeg\\)") "")
1428 (("\\$\\{jpeg_STATIC_LIBRARIES\\}")
1429 (string-append (assoc-ref inputs "libjpeg")
1430 "/lib/libjpeg.so"))
1431 (("jpeg_copy_headers_to_destination") "")
1432
1433 ;; GIF
1434 (("include\\(gif\\)") "")
1435 (("\\$\\{gif_STATIC_LIBRARIES\\}")
1436 (string-append (assoc-ref inputs "giflib")
1437 "/lib/libgif.so"))
1438 (("gif_copy_headers_to_destination") "")
1439
1440 ;; lmdb
1441 (("include\\(lmdb\\)") "")
1442 (("\\$\\{lmdb_STATIC_LIBRARIES\\}")
1443 (string-append (assoc-ref inputs "lmdb")
1444 "/lib/liblmdb.so"))
1445 (("lmdb_copy_headers_to_destination") "")
1446
1447 ;; Protobuf
1448 (("include\\(protobuf\\)") "")
1449 (("protobuf_copy_headers_to_destination") "")
1450 (("^ +protobuf") "")
1451
1452 ;; gRPC
1453 (("include\\(grpc\\)")
1454 "find_package(grpc REQUIRED NAMES gRPC)")
1455 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "")
1456
1457 ;; Eigen
1458 (("include\\(eigen\\)")
1459 (string-append "find_package(eigen REQUIRED NAMES Eigen3)
1460set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive "
1461 (assoc-ref inputs "eigen") "/include/eigen3)"))
1462 (("^ +eigen") "")
1463
1464 ;; snappy
1465 (("include\\(snappy\\)")
1466 "add_definitions(-DTF_USE_SNAPPY)")
1467 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "")
1468
1469 ;; jsoncpp
1470 (("include\\(jsoncpp\\)") "")
1471 (("^ +jsoncpp") ""))
1472
1473 (substitute* "tf_core_framework.cmake"
1474 ((" grpc") "")
1475 (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin")
1476 (which "grpc_cpp_plugin"))
1477 ;; Link with gRPC libraries
1478 (("add_library\\(tf_protos_cc.*" m)
1479 (string-append m
1480 (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \
1481~a/lib/libgrpc++_unsecure.a \
1482~a/lib/libgrpc_unsecure.a \
1483~a/lib/libaddress_sorting.a \
1484~a/lib/libgpr.a \
1485~a//lib/libcares.so
1486)\n"
1487 grpc grpc grpc grpc
1488 (assoc-ref inputs "c-ares"))))))
1489 (substitute* "tf_tools.cmake"
1490 (("add_dependencies\\(\\$\\{proto_text.*") ""))
1491 ;; Remove dependency on bundled grpc
1492 (substitute* "tf_core_distributed_runtime.cmake"
1493 (("tf_core_cpu grpc") "tf_core_cpu"))
1494
1495 ;; This directory is a dependency of many targets.
1496 (mkdir-p "protobuf")
1497 #t))
1498 (add-after 'configure 'unpack-third-party-sources
1499 (lambda* (#:key inputs #:allow-other-keys)
1500 ;; This is needed to configure bundled packages properly.
1501 (setenv "CONFIG_SHELL" (which "bash"))
1502 (for-each
1503 (lambda (name)
1504 (let* ((what (assoc-ref inputs (string-append name "-src")))
1505 (name* (string-map (lambda (c)
1506 (if (char=? c #\-)
1507 #\_ c)) name))
1508 (where (string-append "../build/" name* "/src/" name*)))
1509 (cond
1510 ((string-suffix? ".zip" what)
1511 (mkdir-p where)
1512 (with-directory-excursion where
1513 (invoke "unzip" what)))
1514 ((string-suffix? ".tar.gz" what)
1515 (mkdir-p where)
1516 (invoke "tar" "xf" what
1517 "-C" where "--strip-components=1"))
1518 (else
1519 (let ((parent (dirname where)))
1520 (mkdir-p parent)
1521 (with-directory-excursion parent
1522 (when (file-exists? name*)
1523 (delete-file-recursively name*))
1524 (copy-recursively what name*)
1525 (map make-file-writable
1526 (find-files name* ".*"))))))))
1527 (list "boringssl"
1528 "cub"
1529 "double-conversion"
1530 "farmhash"
1531 "fft2d"
1532 "highwayhash"
1533 "nsync"
1534 "re2"))
1535
1536 (rename-file "../build/cub/src/cub/cub-1.8.0/"
1537 "../build/cub/src/cub/cub/")
1538 #t))
1539 (add-after 'unpack 'fix-python-build
1540 (lambda* (#:key inputs outputs #:allow-other-keys)
1541 (mkdir-p "protobuf-src")
1542 (invoke "tar" "xf" (assoc-ref inputs "protobuf:src")
1543 "-C" "protobuf-src" "--strip-components=1")
1544 (mkdir-p "eigen-src")
1545 (invoke "tar" "xf" (assoc-ref inputs "eigen:src")
1546 "-C" "eigen-src" "--strip-components=1")
1547
1548 (substitute* "tensorflow/contrib/cmake/tf_python.cmake"
1549 ;; Ensure that all Python dependencies can be found at build time.
1550 (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m)
1551 (string-append m ":" (getenv "PYTHONPATH")))
1552 ;; Take protobuf source files from our source package.
1553 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google")
1554 (string-append (getcwd) "/protobuf-src/src/google")))
1555
1556 (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake"
1557 "tensorflow/contrib/cmake/tf_python.cmake")
1558 ;; Take Eigen source files from our source package.
1559 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/")
1560 (string-append (getcwd) "/eigen-src/"))
1561 ;; Take Eigen headers from our own package.
1562 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive")
1563 (string-append (assoc-ref inputs "eigen") "/include/eigen3")))
1564
1565 ;; Correct the RUNPATH of ops libraries generated for Python.
1566 ;; TODO: this doesn't work :(
1567 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1568 ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build")
1569 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1570 ;; error: depends on 'libpywrap_tensorflow_internal.so', which
1571 ;; cannot be found in RUNPATH ...
1572 (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake"
1573 (("set_target_properties.*")
1574 (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \
1575COMPILE_FLAGS ${target_compile_flags} \
1576INSTALL_RPATH_USE_LINK_PATH TRUE \
1577INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n")))
1578 #t))
1579 (add-after 'build 'build-pip-package
1580 (lambda* (#:key outputs #:allow-other-keys)
1581 (setenv "LDFLAGS"
1582 (string-append "-Wl,-rpath="
1583 (assoc-ref outputs "out") "/lib"))
1584 (invoke "make" "tf_python_build_pip_package")
1585 #t))
1586 (add-after 'build-pip-package 'install-python
1587 (lambda* (#:key outputs #:allow-other-keys)
1588 (let ((out (assoc-ref outputs "out"))
1589 (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))))
1590 (invoke "python" "-m" "pip" "install" wheel
1591 (string-append "--prefix=" out))
1592
1593 ;; XXX: broken RUNPATH, see fix-python-build phase.
1594 (delete-file
1595 (string-append
1596 out "/lib/python3.7/site-packages/tensorflow/contrib/"
1597 "seq2seq/python/ops/lib_beam_search_ops.so"))
1598 #t))))))
1599 (native-inputs
1600 `(("pkg-config" ,pkg-config)
1601 ("protobuf:native" ,protobuf-next) ; protoc
1602 ("protobuf:src" ,(package-source protobuf-next))
1603 ("eigen:src" ,(package-source eigen-for-tensorflow))
1604 ;; The commit hashes and URLs for third-party source code are taken
1605 ;; from "tensorflow/workspace.bzl".
1606 ("boringssl-src"
1607 ,(let ((commit "ee7aa02")
1608 (revision "1"))
1609 (origin
1610 (method git-fetch)
1611 (uri (git-reference
1612 (url "https://boringssl.googlesource.com/boringssl")
1613 (commit commit)))
1614 (file-name (string-append "boringssl-0-" revision
1615 (string-take commit 7)
1616 "-checkout"))
1617 (sha256
1618 (base32
1619 "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw")))))
1620 ("cub-src"
1621 ,(let ((version "1.8.0"))
1622 (origin
1623 (method url-fetch)
1624 (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/"
1625 "cub/archive/" version ".zip"))
1626 (file-name (string-append "cub-" version ".zip"))
1627 (sha256
1628 (base32
1629 "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb")))))
1630 ("double-conversion-src"
1631 ,(let ((commit "5664746")
1632 (revision "1"))
1633 (origin
1634 (method git-fetch)
1635 (uri (git-reference
1636 (url "https://github.com/google/double-conversion.git")
1637 (commit commit)))
1638 (file-name
1639 (git-file-name "double-conversion"
1640 (string-append "0-" revision "."
1641 (string-take commit 7))))
1642 (sha256
1643 (base32
1644 "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1")))))
1645 ("farmhash-src"
1646 ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
1647 (origin
1648 (method url-fetch)
1649 (uri (string-append
1650 "https://mirror.bazel.build/github.com/google/farmhash/archive/"
1651 commit ".tar.gz"))
1652 (file-name (string-append "farmhash-0-" (string-take commit 7)
1653 ".tar.gz"))
1654 (sha256
1655 (base32
1656 "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35")))))
1657 ;; The license notice on the home page at
1658 ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says:
1659 ;; Copyright Takuya OOURA, 1996-2001
1660 ;;
1661 ;; You may use, copy, modify and distribute this code for any purpose
1662 ;; (include commercial use) and without fee. Please refer to this
1663 ;; package when you modify this code.
1664 ;;
1665 ;; We take the identical tarball from the Bazel mirror, because the URL
1666 ;; at the home page is not versioned and might change.
1667 ("fft2d-src"
1668 ,(origin
1669 (method url-fetch)
1670 (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz")
1671 (file-name "fft2d.tar.gz")
1672 (sha256
1673 (base32
1674 "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj"))))
1675 ("highwayhash-src"
1676 ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee")
1677 (revision "1"))
1678 (origin
1679 (method git-fetch)
1680 (uri (git-reference
1681 (url "https://github.com/google/highwayhash.git")
1682 (commit commit)))
1683 (file-name (string-append "highwayhash-0-" revision
1684 (string-take commit 7)
1685 "-checkout"))
1686 (sha256
1687 (base32
1688 "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6")))))
1689 ("nsync-src"
1690 ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777")
1691 (revision "1"))
1692 (origin
1693 (method url-fetch)
1694 (uri (string-append "https://mirror.bazel.build/"
1695 "github.com/google/nsync/archive/"
1696 version ".tar.gz"))
1697 (file-name (string-append "nsync-0." revision
1698 "-" (string-take version 7)
1699 ".tar.gz"))
1700 (sha256
1701 (base32
1702 "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132")))))
1703 ("re2-src"
1704 ,(let ((commit "e7efc48")
1705 (revision "1"))
1706 (origin
1707 (method git-fetch)
1708 (uri (git-reference
1709 (url "https://github.com/google/re2")
1710 (commit commit)))
1711 (file-name (string-append "re2-0-" revision
1712 (string-take commit 7)
1713 "-checkout"))
1714 (sha256
1715 (base32
1716 "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign")))))
1717 ("googletest" ,googletest)
1718 ("swig" ,swig)
1719 ("unzip" ,unzip)))
1720 (propagated-inputs
1721 `(("python-absl-py" ,python-absl-py)
1722 ("python-astor" ,python-astor)
1723 ("python-gast" ,python-gast)
1724 ("python-grpcio" ,python-grpcio)
1725 ("python-numpy" ,python-numpy)
1726 ("python-protobuf" ,python-protobuf-next)
1727 ("python-six" ,python-six)
1728 ("python-termcolo" ,python-termcolor)
1729 ("python-wheel" ,python-wheel)))
1730 (inputs
1731 `(("c-ares" ,c-ares-next)
1732 ("eigen" ,eigen-for-tensorflow)
1733 ("gemmlowp" ,gemmlowp-for-tensorflow)
1734 ("lmdb" ,lmdb)
1735 ("libjpeg" ,libjpeg)
1736 ("libpng" ,libpng)
1737 ("giflib" ,giflib)
1738 ("grpc" ,grpc)
1739 ("jsoncpp" ,jsoncpp-for-tensorflow)
1740 ("snappy" ,snappy)
1741 ("sqlite" ,sqlite)
1742 ("protobuf" ,protobuf-next)
1743 ("python" ,python-wrapper)
1744 ("zlib" ,zlib)))
1745 (home-page "https://tensorflow.org")
1746 (synopsis "Machine learning framework")
1747 (description
1748 "TensorFlow is a flexible platform for building and training machine
1749learning models. It provides a library for high performance numerical
1750computation and includes high level Python APIs, including both a sequential
1751API for beginners that allows users to build models quickly by plugging
1752together building blocks and a subclassing API with an imperative style for
1753advanced research.")
1754 (license license:asl2.0)))