Commit | Line | Data |
---|---|---|
741115b6 | 1 | ;;; GNU Guix --- Functional package management for GNU |
96193caa | 2 | ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ricardo Wurmus <rekado@elephly.net> |
3d72867e | 3 | ;;; Copyright © 2016, 2020, 2021 Efraim Flashner <efraim@flashner.co.il> |
382550f0 | 4 | ;;; Copyright © 2016, 2017, 2020 Marius Bakke <mbakke@fastmail.com> |
be6eb2f1 | 5 | ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com> |
d2a7cb46 | 6 | ;;; Copyright © 2018, 2019, 2020 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> |
d60b064d | 13 | ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr> |
5dc04da4 | 14 | ;;; Copyright © 2019, 2020 Guillaume Le Vaillant <glv@posteo.net> |
5e42d197 | 15 | ;;; Copyright © 2019 Brett Gilio <brettg@gnu.org> |
d9e9a261 | 16 | ;;; Copyright © 2020 Konrad Hinsen <konrad.hinsen@fastmail.net> |
bcbd6340 | 17 | ;;; Copyright © 2020 Edouard Klein <edk@beaver-labs.com> |
df76cadf | 18 | ;;; Copyright © 2020, 2021 Vinicius Monego <monego@posteo.net> |
5f37d7e3 | 19 | ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com> |
741115b6 RW |
20 | ;;; |
21 | ;;; This file is part of GNU Guix. | |
22 | ;;; | |
23 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
24 | ;;; under the terms of the GNU General Public License as published by | |
25 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
26 | ;;; your option) any later version. | |
27 | ;;; | |
28 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
29 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
30 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
31 | ;;; GNU General Public License for more details. | |
32 | ;;; | |
33 | ;;; You should have received a copy of the GNU General Public License | |
34 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
35 | ||
36 | (define-module (gnu packages machine-learning) | |
37 | #:use-module ((guix licenses) #:prefix license:) | |
38 | #:use-module (guix packages) | |
39 | #:use-module (guix utils) | |
40 | #:use-module (guix download) | |
23aab4ab | 41 | #:use-module (guix svn-download) |
c1670a81 | 42 | #:use-module (guix build-system cmake) |
741115b6 | 43 | #:use-module (guix build-system gnu) |
0a3063d6 | 44 | #:use-module (guix build-system ocaml) |
be6eb2f1 | 45 | #:use-module (guix build-system python) |
8406138b | 46 | #:use-module (guix build-system r) |
a9b34762 | 47 | #:use-module (guix git-download) |
71f80f54 | 48 | #:use-module (gnu packages) |
0dfeb285 | 49 | #:use-module (gnu packages adns) |
5a14e81e | 50 | #:use-module (gnu packages algebra) |
b9445d0b | 51 | #:use-module (gnu packages audio) |
23aab4ab | 52 | #:use-module (gnu packages autotools) |
b9445d0b | 53 | #:use-module (gnu packages base) |
99260014 | 54 | #:use-module (gnu packages bash) |
0931c609 | 55 | #:use-module (gnu packages boost) |
be6eb2f1 | 56 | #:use-module (gnu packages check) |
0931c609 | 57 | #:use-module (gnu packages compression) |
b6540374 | 58 | #:use-module (gnu packages cmake) |
9e37e537 | 59 | #:use-module (gnu packages cran) |
4fa16c9a | 60 | #:use-module (gnu packages databases) |
23aab4ab | 61 | #:use-module (gnu packages dejagnu) |
0931c609 | 62 | #:use-module (gnu packages gcc) |
b9445d0b | 63 | #:use-module (gnu packages glib) |
f1765b57 | 64 | #:use-module (gnu packages graphviz) |
b9445d0b | 65 | #:use-module (gnu packages gstreamer) |
5f0ff6a9 | 66 | #:use-module (gnu packages image) |
b9445d0b | 67 | #:use-module (gnu packages linux) |
8cd10a76 | 68 | #:use-module (gnu packages llvm) |
0931c609 | 69 | #:use-module (gnu packages maths) |
112c2c01 | 70 | #:use-module (gnu packages mpi) |
0a3063d6 | 71 | #:use-module (gnu packages ocaml) |
3929f46c | 72 | #:use-module (gnu packages onc-rpc) |
791c11d6 | 73 | #:use-module (gnu packages perl) |
c1670a81 | 74 | #:use-module (gnu packages pkg-config) |
0dfeb285 | 75 | #:use-module (gnu packages protobuf) |
0931c609 | 76 | #:use-module (gnu packages python) |
dbcd2050 | 77 | #:use-module (gnu packages python-build) |
b6540374 | 78 | #:use-module (gnu packages python-check) |
ec1224a7 | 79 | #:use-module (gnu packages python-science) |
10451f6b | 80 | #:use-module (gnu packages python-web) |
44d10b1f | 81 | #:use-module (gnu packages python-xyz) |
c61557b1 | 82 | #:use-module (gnu packages rpc) |
4fa16c9a | 83 | #:use-module (gnu packages serialization) |
f1765b57 | 84 | #:use-module (gnu packages sphinx) |
c1670a81 | 85 | #:use-module (gnu packages statistics) |
4fa16c9a | 86 | #:use-module (gnu packages sqlite) |
c1670a81 | 87 | #:use-module (gnu packages swig) |
99260014 | 88 | #:use-module (gnu packages web) |
5f0ff6a9 | 89 | #:use-module (gnu packages xml) |
39bb4937 RW |
90 | #:use-module (gnu packages xorg) |
91 | #:use-module (ice-9 match)) | |
741115b6 | 92 | |
a9b34762 MM |
93 | (define-public fann |
94 | ;; The last release is >100 commits behind, so we package from git. | |
95 | (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7")) | |
96 | (package | |
97 | (name "fann") | |
98 | (version (string-append "2.2.0-1." (string-take commit 8))) | |
99 | (source (origin | |
100 | (method git-fetch) | |
101 | (uri (git-reference | |
b0e7b699 | 102 | (url "https://github.com/libfann/fann") |
a9b34762 MM |
103 | (commit commit))) |
104 | (file-name (string-append name "-" version "-checkout")) | |
105 | (sha256 | |
106 | (base32 | |
107 | "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x")))) | |
108 | (build-system cmake-build-system) | |
109 | (arguments | |
110 | `(#:phases | |
111 | (modify-phases %standard-phases | |
112 | (replace 'check | |
113 | (lambda* (#:key outputs #:allow-other-keys) | |
114 | (let* ((out (assoc-ref outputs "out"))) | |
115 | (with-directory-excursion (string-append (getcwd) "/tests") | |
116 | (invoke "./fann_tests")))))))) | |
117 | (home-page "http://leenissen.dk/fann/wp/") | |
118 | (synopsis "Fast Artificial Neural Network") | |
119 | (description | |
bd2bd80d MB |
120 | "FANN is a neural network library, which implements multilayer |
121 | artificial neural networks in C with support for both fully connected and | |
122 | sparsely connected networks.") | |
a9b34762 MM |
123 | (license license:lgpl2.1)))) |
124 | ||
741115b6 RW |
125 | (define-public libsvm |
126 | (package | |
127 | (name "libsvm") | |
2cffa2f2 | 128 | (version "3.23") |
741115b6 RW |
129 | (source |
130 | (origin | |
131 | (method url-fetch) | |
d1308c5e TGR |
132 | (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/" |
133 | name "-" version ".tar.gz")) | |
741115b6 | 134 | (sha256 |
2cffa2f2 | 135 | (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5")))) |
741115b6 RW |
136 | (build-system gnu-build-system) |
137 | (arguments | |
2cffa2f2 | 138 | `(#:tests? #f ; no "check" target |
741115b6 RW |
139 | #:phases (modify-phases %standard-phases |
140 | (delete 'configure) | |
141 | (replace | |
d1308c5e | 142 | 'install ; no ‘install’ target |
741115b6 RW |
143 | (lambda* (#:key outputs #:allow-other-keys) |
144 | (let* ((out (assoc-ref outputs "out")) | |
145 | (bin (string-append out "/bin/"))) | |
146 | (mkdir-p bin) | |
147 | (for-each (lambda (file) | |
148 | (copy-file file (string-append bin file))) | |
149 | '("svm-train" | |
150 | "svm-predict" | |
151 | "svm-scale"))) | |
152 | #t))))) | |
62290cd4 | 153 | (home-page "https://www.csie.ntu.edu.tw/~cjlin/libsvm/") |
741115b6 RW |
154 | (synopsis "Library for Support Vector Machines") |
155 | (description | |
156 | "LIBSVM is a machine learning library for support vector | |
157 | classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and | |
158 | distribution estimation (one-class SVM). It supports multi-class | |
159 | classification.") | |
160 | (license license:bsd-3))) | |
71f80f54 RW |
161 | |
162 | (define-public python-libsvm | |
163 | (package (inherit libsvm) | |
164 | (name "python-libsvm") | |
165 | (build-system gnu-build-system) | |
166 | (arguments | |
2cffa2f2 | 167 | `(#:tests? #f ; no "check" target |
71f80f54 RW |
168 | #:make-flags '("-C" "python") |
169 | #:phases | |
170 | (modify-phases %standard-phases | |
171 | (delete 'configure) | |
172 | (replace | |
d1308c5e | 173 | 'install ; no ‘install’ target |
71f80f54 RW |
174 | (lambda* (#:key inputs outputs #:allow-other-keys) |
175 | (let ((site (string-append (assoc-ref outputs "out") | |
176 | "/lib/python" | |
177 | (string-take | |
178 | (string-take-right | |
179 | (assoc-ref inputs "python") 5) 3) | |
180 | "/site-packages/"))) | |
181 | (substitute* "python/svm.py" | |
182 | (("../libsvm.so.2") "libsvm.so.2")) | |
183 | (mkdir-p site) | |
184 | (for-each (lambda (file) | |
185 | (copy-file file (string-append site (basename file)))) | |
186 | (find-files "python" "\\.py")) | |
187 | (copy-file "libsvm.so.2" | |
188 | (string-append site "libsvm.so.2"))) | |
189 | #t))))) | |
190 | (inputs | |
191 | `(("python" ,python))) | |
192 | (synopsis "Python bindings of libSVM"))) | |
0931c609 | 193 | |
23aab4ab RW |
194 | (define-public ghmm |
195 | ;; The latest release candidate is several years and a couple of fixes have | |
196 | ;; been published since. This is why we download the sources from the SVN | |
197 | ;; repository. | |
198 | (let ((svn-revision 2341)) | |
199 | (package | |
200 | (name "ghmm") | |
201 | (version (string-append "0.9-rc3-0." (number->string svn-revision))) | |
202 | (source (origin | |
203 | (method svn-fetch) | |
204 | (uri (svn-reference | |
205 | (url "http://svn.code.sf.net/p/ghmm/code/trunk") | |
206 | (revision svn-revision))) | |
e3a69938 | 207 | (file-name (string-append name "-" version "-checkout")) |
23aab4ab RW |
208 | (sha256 |
209 | (base32 | |
210 | "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq")))) | |
211 | (build-system gnu-build-system) | |
212 | (arguments | |
ced12a7b RW |
213 | `(#:imported-modules (,@%gnu-build-system-modules |
214 | (guix build python-build-system)) | |
3cb8cb66 MB |
215 | #:modules ((guix build python-build-system) |
216 | ,@%gnu-build-system-modules) | |
ced12a7b | 217 | #:phases |
23aab4ab RW |
218 | (modify-phases %standard-phases |
219 | (add-after 'unpack 'enter-dir | |
220 | (lambda _ (chdir "ghmm") #t)) | |
ced12a7b RW |
221 | (delete 'check) |
222 | (add-after 'install 'check | |
223 | (assoc-ref %standard-phases 'check)) | |
224 | (add-before 'check 'fix-PYTHONPATH | |
225 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
9c2563a8 | 226 | (let ((python-version (python-version |
ced12a7b RW |
227 | (assoc-ref inputs "python")))) |
228 | (setenv "PYTHONPATH" | |
229 | (string-append (getenv "PYTHONPATH") | |
230 | ":" (assoc-ref outputs "out") | |
231 | "/lib/python" python-version | |
232 | "/site-packages"))) | |
23aab4ab RW |
233 | #t)) |
234 | (add-after 'enter-dir 'fix-runpath | |
235 | (lambda* (#:key outputs #:allow-other-keys) | |
236 | (substitute* "ghmmwrapper/setup.py" | |
237 | (("^(.*)extra_compile_args = \\[" line indent) | |
238 | (string-append indent | |
239 | "extra_link_args = [\"-Wl,-rpath=" | |
240 | (assoc-ref outputs "out") "/lib\"],\n" | |
241 | line | |
242 | "\"-Wl,-rpath=" | |
243 | (assoc-ref outputs "out") | |
244 | "/lib\", "))) | |
245 | #t)) | |
246 | (add-after 'enter-dir 'disable-broken-tests | |
247 | (lambda _ | |
248 | (substitute* "tests/Makefile.am" | |
249 | ;; GHMM_SILENT_TESTS is assumed to be a command. | |
250 | (("TESTS_ENVIRONMENT.*") "") | |
251 | ;; Do not build broken tests. | |
252 | (("chmm .*") "") | |
253 | (("read_fa .*") "") | |
254 | (("mcmc .*") "") | |
255 | (("label_higher_order_test.*$") | |
256 | "label_higher_order_test\n")) | |
257 | ||
258 | ;; These Python unittests are broken as there is no gato. | |
259 | ;; See https://sourceforge.net/p/ghmm/support-requests/3/ | |
260 | (substitute* "ghmmwrapper/ghmmunittests.py" | |
261 | (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)" | |
262 | line indent) | |
263 | (string-append indent | |
264 | "@unittest.skip(\"Disabled by Guix\")\n" | |
265 | line))) | |
a491856f | 266 | #t))))) |
23aab4ab RW |
267 | (inputs |
268 | `(("python" ,python-2) ; only Python 2 is supported | |
269 | ("libxml2" ,libxml2))) | |
270 | (native-inputs | |
271 | `(("pkg-config" ,pkg-config) | |
272 | ("dejagnu" ,dejagnu) | |
273 | ("swig" ,swig) | |
274 | ("autoconf" ,autoconf) | |
275 | ("automake" ,automake) | |
276 | ("libtool" ,libtool))) | |
277 | (home-page "http://ghmm.org") | |
278 | (synopsis "Hidden Markov Model library") | |
279 | (description | |
280 | "The General Hidden Markov Model library (GHMM) is a C library with | |
281 | additional Python bindings implementing a wide range of types of @dfn{Hidden | |
d1e4ad1b | 282 | Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic |
23aab4ab RW |
283 | training, HMM clustering, HMM mixtures.") |
284 | (license license:lgpl2.0+)))) | |
285 | ||
791c11d6 BW |
286 | (define-public mcl |
287 | (package | |
288 | (name "mcl") | |
289 | (version "14.137") | |
290 | (source (origin | |
291 | (method url-fetch) | |
292 | (uri (string-append | |
293 | "http://micans.org/mcl/src/mcl-" | |
294 | (string-replace-substring version "." "-") | |
295 | ".tar.gz")) | |
296 | (sha256 | |
297 | (base32 | |
298 | "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m")))) | |
299 | (build-system gnu-build-system) | |
300 | (arguments | |
301 | `(#:configure-flags (list "--enable-blast"))) | |
302 | (inputs | |
303 | `(("perl" ,perl))) | |
304 | (home-page "http://micans.org/mcl/") | |
305 | (synopsis "Clustering algorithm for graphs") | |
306 | (description | |
307 | "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a | |
308 | fast and scalable unsupervised cluster algorithm for graphs (also known as | |
309 | networks) based on simulation of (stochastic) flow in graphs.") | |
310 | ;; In the LICENCE file and web page it says "The software is licensed | |
311 | ;; under the GNU General Public License, version 3.", but in several of | |
312 | ;; the source code files it suggests GPL3 or later. | |
313 | ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html | |
314 | (license license:gpl3))) | |
315 | ||
0a3063d6 BW |
316 | (define-public ocaml-mcl |
317 | (package | |
318 | (name "ocaml-mcl") | |
319 | (version "12-068oasis4") | |
320 | (source | |
321 | (origin | |
fb168a31 RW |
322 | (method git-fetch) |
323 | (uri (git-reference | |
b0e7b699 | 324 | (url "https://github.com/fhcrc/mcl") |
fb168a31 RW |
325 | (commit version))) |
326 | (file-name (git-file-name name version)) | |
0a3063d6 BW |
327 | (sha256 |
328 | (base32 | |
fb168a31 | 329 | "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p")))) |
0a3063d6 BW |
330 | (build-system ocaml-build-system) |
331 | (arguments | |
b24aaeec | 332 | `(#:phases |
0a3063d6 BW |
333 | (modify-phases %standard-phases |
334 | (add-before 'configure 'patch-paths | |
335 | (lambda _ | |
0a3063d6 BW |
336 | (substitute* "setup.ml" |
337 | (("LDFLAGS=-fPIC") | |
b24aaeec RW |
338 | (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))) |
339 | (("-std=c89") "-std=gnu99") | |
340 | ||
341 | ;; This is a mutable string, which is no longer supported. Use | |
342 | ;; a byte buffer instead. | |
343 | (("String.make \\(String.length s\\)") | |
344 | "Bytes.make (String.length s)") | |
345 | ||
346 | ;; These two belong together. | |
347 | (("OASISString.replace_chars") | |
348 | "Bytes.to_string (OASISString.replace_chars") | |
349 | ((" s;") | |
350 | " s);")) | |
351 | (substitute* "myocamlbuild.ml" | |
352 | (("std=c89") "std=gnu99")) | |
353 | ;; Since we build with a more recent OCaml, we have to use C99 or | |
354 | ;; later. This causes problems with the old C code. | |
355 | (substitute* "src/impala/matrix.c" | |
356 | (("restrict") "restrict_")) | |
0a3063d6 | 357 | #t))))) |
b24aaeec RW |
358 | (native-inputs |
359 | `(("ocamlbuild" ,ocamlbuild))) | |
0a3063d6 BW |
360 | (home-page "https://github.com/fhcrc/mcl") |
361 | (synopsis "OCaml wrappers around MCL") | |
362 | (description | |
363 | "This package provides OCaml bindings for the MCL graph clustering | |
364 | algorithm.") | |
365 | (license license:gpl3))) | |
366 | ||
0931c609 RW |
367 | (define-public randomjungle |
368 | (package | |
369 | (name "randomjungle") | |
370 | (version "2.1.0") | |
371 | (source | |
372 | (origin | |
373 | (method url-fetch) | |
374 | (uri (string-append | |
df4c8434 BH |
375 | "https://www.imbs.uni-luebeck.de/fileadmin/files/Software" |
376 | "/randomjungle/randomjungle-" version ".tar_.gz")) | |
1e92d311 | 377 | (patches (search-patches "randomjungle-disable-static-build.patch")) |
0931c609 RW |
378 | (sha256 |
379 | (base32 | |
380 | "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w")))) | |
381 | (build-system gnu-build-system) | |
382 | (arguments | |
383 | `(#:configure-flags | |
1e92d311 MB |
384 | (list "--disable-static" |
385 | (string-append "--with-boost=" | |
0931c609 RW |
386 | (assoc-ref %build-inputs "boost"))) |
387 | #:phases | |
388 | (modify-phases %standard-phases | |
389 | (add-before | |
390 | 'configure 'set-CXXFLAGS | |
391 | (lambda _ | |
392 | (setenv "CXXFLAGS" "-fpermissive ") | |
393 | #t))))) | |
394 | (inputs | |
395 | `(("boost" ,boost) | |
396 | ("gsl" ,gsl) | |
397 | ("libxml2" ,libxml2) | |
398 | ("zlib" ,zlib))) | |
399 | (native-inputs | |
25e0037a EF |
400 | `(("gfortran" ,gfortran) |
401 | ("gfortran:lib" ,gfortran "lib"))) | |
47818201 RW |
402 | ;; Non-portable assembly instructions are used so building fails on |
403 | ;; platforms other than x86_64 or i686. | |
404 | (supported-systems '("x86_64-linux" "i686-linux")) | |
df4c8434 | 405 | (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224") |
0931c609 RW |
406 | (synopsis "Implementation of the Random Forests machine learning method") |
407 | (description | |
408 | "Random Jungle is an implementation of Random Forests. It is supposed to | |
409 | analyse high dimensional data. In genetics, it can be used for analysing big | |
410 | Genome Wide Association (GWA) data. Random Forests is a powerful machine | |
411 | learning method. Most interesting features are variable selection, missing | |
412 | value imputation, classifier creation, generalization error estimation and | |
413 | sample proximities between pairs of cases.") | |
414 | (license license:gpl3+))) | |
c1670a81 | 415 | |
7d4cab74 RW |
416 | (define-public openfst |
417 | (package | |
418 | (name "openfst") | |
e4d51494 | 419 | (version "1.7.9") |
7d4cab74 RW |
420 | (source (origin |
421 | (method url-fetch) | |
422 | (uri (string-append "http://www.openfst.org/twiki/pub/FST/" | |
423 | "FstDownload/openfst-" version ".tar.gz")) | |
424 | (sha256 | |
425 | (base32 | |
e4d51494 | 426 | "1pmx1yhn2gknj0an0zwqmzgwjaycapi896244np50a8y3nrsw6ck")))) |
7d4cab74 RW |
427 | (build-system gnu-build-system) |
428 | (home-page "http://www.openfst.org") | |
429 | (synopsis "Library for weighted finite-state transducers") | |
430 | (description "OpenFst is a library for constructing, combining, | |
431 | optimizing, and searching weighted finite-state transducers (FSTs).") | |
432 | (license license:asl2.0))) | |
433 | ||
c1670a81 RW |
434 | (define-public shogun |
435 | (package | |
436 | (name "shogun") | |
5a14e81e | 437 | (version "6.1.3") |
c1670a81 RW |
438 | (source |
439 | (origin | |
440 | (method url-fetch) | |
441 | (uri (string-append | |
442 | "ftp://shogun-toolbox.org/shogun/releases/" | |
443 | (version-major+minor version) | |
444 | "/sources/shogun-" version ".tar.bz2")) | |
445 | (sha256 | |
446 | (base32 | |
5a14e81e | 447 | "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp")) |
c1670a81 RW |
448 | (modules '((guix build utils) |
449 | (ice-9 rdelim))) | |
450 | (snippet | |
451 | '(begin | |
452 | ;; Remove non-free sources and files referencing them | |
453 | (for-each delete-file | |
454 | (find-files "src/shogun/classifier/svm/" | |
455 | "SVMLight\\.(cpp|h)")) | |
456 | (for-each delete-file | |
457 | (find-files "examples/undocumented/libshogun/" | |
458 | (string-append | |
459 | "(classifier_.*svmlight.*|" | |
460 | "evaluation_cross_validation_locked_comparison).cpp"))) | |
461 | ;; Remove non-free functions. | |
462 | (define (delete-ifdefs file) | |
463 | (with-atomic-file-replacement file | |
464 | (lambda (in out) | |
465 | (let loop ((line (read-line in 'concat)) | |
466 | (skipping? #f)) | |
467 | (if (eof-object? line) | |
468 | #t | |
469 | (let ((skip-next? | |
470 | (or (and skipping? | |
471 | (not (string-prefix? | |
472 | "#endif //USE_SVMLIGHT" line))) | |
473 | (string-prefix? | |
474 | "#ifdef USE_SVMLIGHT" line)))) | |
475 | (when (or (not skipping?) | |
476 | (and skipping? (not skip-next?))) | |
477 | (display line out)) | |
478 | (loop (read-line in 'concat) skip-next?))))))) | |
5a14e81e KK |
479 | (for-each delete-ifdefs |
480 | (append | |
481 | (find-files "src/shogun/classifier/mkl" | |
482 | "^MKLClassification\\.cpp") | |
483 | (find-files "src/shogun/classifier/svm" | |
484 | "^SVMLightOneClass\\.(cpp|h)") | |
485 | (find-files "src/shogun/multiclass" | |
486 | "^ScatterSVM\\.(cpp|h)") | |
487 | (find-files "src/shogun/kernel/" | |
488 | "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)") | |
489 | (find-files "src/shogun/regression/svr" | |
490 | "^(MKLRegression|SVRLight)\\.(cpp|h)") | |
491 | (find-files "src/shogun/transfer/domain_adaptation" | |
c0d7c124 | 492 | "^DomainAdaptationSVM\\.(cpp|h)"))) |
6cbee49d | 493 | #t)))) |
c1670a81 RW |
494 | (build-system cmake-build-system) |
495 | (arguments | |
496 | '(#:tests? #f ;no check target | |
497 | #:phases | |
dc1d3cde KK |
498 | (modify-phases %standard-phases |
499 | (add-after 'unpack 'delete-broken-symlinks | |
500 | (lambda _ | |
501 | (for-each delete-file '("applications/arts/data" | |
502 | "applications/asp/data" | |
503 | "applications/easysvm/data" | |
504 | "applications/msplicer/data" | |
505 | "applications/ocr/data" | |
5a14e81e KK |
506 | "examples/meta/data" |
507 | "examples/undocumented/data")) | |
dc1d3cde KK |
508 | #t)) |
509 | (add-after 'unpack 'change-R-target-path | |
510 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e KK |
511 | (substitute* '("src/interfaces/r/CMakeLists.txt" |
512 | "examples/meta/r/CMakeLists.txt") | |
dc1d3cde KK |
513 | (("\\$\\{R_COMPONENT_LIB_PATH\\}") |
514 | (string-append (assoc-ref outputs "out") | |
515 | "/lib/R/library/"))) | |
516 | #t)) | |
517 | (add-after 'unpack 'fix-octave-modules | |
518 | (lambda* (#:key outputs #:allow-other-keys) | |
5a14e81e | 519 | (substitute* "src/interfaces/octave/CMakeLists.txt" |
dc1d3cde | 520 | (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}") |
5a14e81e KK |
521 | "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave") |
522 | ;; change target directory | |
dc1d3cde KK |
523 | (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}") |
524 | (string-append (assoc-ref outputs "out") | |
525 | "/share/octave/packages"))) | |
5a14e81e KK |
526 | (substitute* '("src/interfaces/octave/swig_typemaps.i" |
527 | "src/interfaces/octave/sg_print_functions.cpp") | |
528 | ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave. | |
529 | (("octave/config\\.h") "octave/octave-config.h") | |
530 | (("octave/oct-obj.h") "octave/ovl.h")) | |
dc1d3cde | 531 | #t)) |
5a14e81e KK |
532 | (add-after 'unpack 'move-rxcpp |
533 | (lambda* (#:key inputs #:allow-other-keys) | |
534 | (let ((rxcpp-dir "shogun/third-party/rxcpp")) | |
535 | (mkdir-p rxcpp-dir) | |
536 | (install-file (assoc-ref inputs "rxcpp") rxcpp-dir) | |
537 | #t))) | |
dc1d3cde | 538 | (add-before 'build 'set-HOME |
c1670a81 | 539 | ;; $HOME needs to be set at some point during the build phase |
dc1d3cde | 540 | (lambda _ (setenv "HOME" "/tmp") #t))) |
c1670a81 RW |
541 | #:configure-flags |
542 | (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE" | |
543 | "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT | |
5a14e81e KK |
544 | "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags |
545 | ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas | |
546 | ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray | |
547 | ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist | |
548 | ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file | |
549 | "-DINTERFACE_OCTAVE=ON" | |
550 | "-DINTERFACE_PYTHON=ON" | |
551 | "-DINTERFACE_R=ON"))) | |
c1670a81 RW |
552 | (inputs |
553 | `(("python" ,python) | |
554 | ("numpy" ,python-numpy) | |
2d7c4ae3 | 555 | ("r-minimal" ,r-minimal) |
5537603f | 556 | ("octave" ,octave-cli) |
c1670a81 | 557 | ("swig" ,swig) |
5a14e81e | 558 | ("eigen" ,eigen) |
c1670a81 RW |
559 | ("hdf5" ,hdf5) |
560 | ("atlas" ,atlas) | |
561 | ("arpack" ,arpack-ng) | |
562 | ("lapack" ,lapack) | |
563 | ("glpk" ,glpk) | |
564 | ("libxml2" ,libxml2) | |
565 | ("lzo" ,lzo) | |
566 | ("zlib" ,zlib))) | |
567 | (native-inputs | |
5a14e81e KK |
568 | `(("pkg-config" ,pkg-config) |
569 | ("rxcpp" ,rxcpp))) | |
6b5b656f RW |
570 | ;; Non-portable SSE instructions are used so building fails on platforms |
571 | ;; other than x86_64. | |
572 | (supported-systems '("x86_64-linux")) | |
df10a64e | 573 | (home-page "https://shogun-toolbox.org/") |
c1670a81 RW |
574 | (synopsis "Machine learning toolbox") |
575 | (description | |
576 | "The Shogun Machine learning toolbox provides a wide range of unified and | |
cc24c4cb VC |
577 | efficient Machine Learning (ML) methods. The toolbox seamlessly |
578 | combines multiple data representations, algorithm classes, and general purpose | |
c1670a81 RW |
579 | tools. This enables both rapid prototyping of data pipelines and extensibility |
580 | in terms of new algorithms.") | |
581 | (license license:gpl3+))) | |
8406138b | 582 | |
b6540374 VM |
583 | (define-public python-onnx |
584 | (package | |
585 | (name "python-onnx") | |
df76cadf | 586 | (version "1.8.1") |
b6540374 VM |
587 | (source |
588 | (origin | |
589 | (method url-fetch) | |
590 | (uri (pypi-uri "onnx" version)) | |
591 | ;; ONNX will build googletest from a git checkout. Patch CMake | |
592 | ;; to use googletest from Guix and enable tests by default. | |
593 | (patches (search-patches "python-onnx-use-system-googletest.patch")) | |
594 | (sha256 | |
df76cadf | 595 | (base32 "1ys5f4kqkabm4mgivsw80zz8xj1svanfbpszqbw9j15914hcarcx")))) |
b6540374 VM |
596 | (build-system python-build-system) |
597 | (native-inputs | |
598 | `(("cmake" ,cmake) | |
599 | ("googletest" ,googletest) | |
600 | ("pybind11" ,pybind11) | |
601 | ("python-coverage" ,python-coverage) | |
602 | ("python-nbval" ,python-nbval) | |
603 | ("python-pytest" ,python-pytest) | |
604 | ("python-pytest-runner" ,python-pytest-runner))) | |
605 | (inputs | |
606 | `(("protobuf" ,protobuf))) | |
607 | (propagated-inputs | |
608 | `(("python-numpy" ,python-numpy) | |
609 | ("python-protobuf" ,python-protobuf) | |
610 | ("python-six" ,python-six) | |
611 | ("python-tabulate" ,python-tabulate) | |
612 | ("python-typing-extensions" | |
613 | ,python-typing-extensions))) | |
614 | (home-page "https://onnx.ai/") | |
615 | (synopsis "Open Neural Network Exchange") | |
616 | (description | |
617 | "Open Neural Network Exchange (ONNX) provides an open source format for | |
618 | AI models, both deep learning and traditional ML. It defines an extensible | |
619 | computation graph model, as well as definitions of built-in operators and | |
620 | standard data types.") | |
621 | (license license:expat))) | |
622 | ||
3a354e10 KK |
623 | (define-public rxcpp |
624 | (package | |
625 | (name "rxcpp") | |
e91a0bff | 626 | (version "4.1.0") |
3a354e10 KK |
627 | (source |
628 | (origin | |
5daafe0b TGR |
629 | (method git-fetch) |
630 | (uri (git-reference | |
b0e7b699 | 631 | (url "https://github.com/ReactiveX/RxCpp") |
5daafe0b | 632 | (commit (string-append "v" version)))) |
3a354e10 | 633 | (sha256 |
5daafe0b TGR |
634 | (base32 "1rdpa3jlc181jd08nk437aar085h28i45s6nzrv65apb3xyyz0ij")) |
635 | (file-name (git-file-name name version)))) | |
3a354e10 KK |
636 | (build-system cmake-build-system) |
637 | (arguments | |
638 | `(#:phases | |
639 | (modify-phases %standard-phases | |
640 | (add-after 'unpack 'remove-werror | |
641 | (lambda _ | |
642 | (substitute* (find-files ".") | |
643 | (("-Werror") "")) | |
644 | #t)) | |
645 | (replace 'check | |
646 | (lambda _ | |
647 | (invoke "ctest")))))) | |
648 | (native-inputs | |
649 | `(("catch" ,catch-framework))) | |
650 | (home-page "http://reactivex.io/") | |
651 | (synopsis "Reactive Extensions for C++") | |
652 | (description | |
653 | "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for | |
654 | values-distributed-in-time. ReactiveX is a library for composing asynchronous | |
655 | and event-based programs by using observable sequences. | |
656 | ||
657 | It extends the observer pattern to support sequences of data and/or events and | |
658 | adds operators that allow you to compose sequences together declaratively while | |
659 | abstracting away concerns about things like low-level threading, | |
660 | synchronization, thread-safety, concurrent data structures, and non-blocking | |
661 | I/O.") | |
662 | (license license:asl2.0))) | |
663 | ||
39bb4937 RW |
664 | (define-public gemmlowp-for-tensorflow |
665 | ;; The commit hash is taken from "tensorflow/workspace.bzl". | |
666 | (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98") | |
667 | (revision "2")) | |
668 | (package | |
669 | (name "gemmlowp") | |
670 | (version (git-version "0" revision commit)) | |
671 | (source (origin | |
672 | (method url-fetch) | |
673 | (uri (string-append "https://mirror.bazel.build/" | |
674 | "github.com/google/gemmlowp/archive/" | |
675 | commit ".zip")) | |
676 | (file-name (string-append "gemmlowp-" version ".zip")) | |
677 | (sha256 | |
678 | (base32 | |
679 | "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq")))) | |
680 | (build-system cmake-build-system) | |
681 | (arguments | |
682 | `(#:configure-flags | |
683 | (list ,@(match (%current-system) | |
684 | ((or "x86_64-linux" "i686-linux") | |
a32e3b90 | 685 | '("-DCMAKE_CXX_FLAGS=-msse2")) |
39bb4937 RW |
686 | (_ '()))) |
687 | #:phases | |
688 | (modify-phases %standard-phases | |
689 | ;; This directory contains the CMakeLists.txt. | |
690 | (add-after 'unpack 'chdir | |
691 | (lambda _ (chdir "contrib") #t)) | |
692 | ;; There is no install target | |
693 | (replace 'install | |
694 | (lambda* (#:key outputs #:allow-other-keys) | |
695 | (let* ((out (assoc-ref outputs "out")) | |
696 | (lib (string-append out "/lib/")) | |
697 | (inc (string-append out "/include/"))) | |
698 | (install-file "../build/libeight_bit_int_gemm.so" lib) | |
699 | (for-each (lambda (dir) | |
700 | (let ((target (string-append inc "/" dir))) | |
701 | (mkdir-p target) | |
702 | (for-each (lambda (h) | |
703 | (install-file h target)) | |
704 | (find-files (string-append "../" dir) | |
705 | "\\.h$")))) | |
706 | '("meta" "profiling" "public" "fixedpoint" | |
707 | "eight_bit_int_gemm" "internal")) | |
708 | #t)))))) | |
709 | (native-inputs | |
710 | `(("unzip" ,unzip))) | |
711 | (home-page "https://github.com/google/gemmlowp") | |
712 | (synopsis "Small self-contained low-precision GEMM library") | |
713 | (description | |
714 | "This is a small self-contained low-precision @dfn{general matrix | |
715 | multiplication} (GEMM) library. It is not a full linear algebra library. | |
716 | Low-precision means that the input and output matrix entries are integers on | |
717 | at most 8 bits. To avoid overflow, results are internally accumulated on more | |
718 | than 8 bits, and at the end only some significant 8 bits are kept.") | |
719 | (license license:asl2.0)))) | |
f05c7eb4 | 720 | |
5f0ff6a9 MB |
721 | (define-public dlib |
722 | (package | |
723 | (name "dlib") | |
d2a7cb46 | 724 | (version "19.20") |
5f0ff6a9 MB |
725 | (source (origin |
726 | (method url-fetch) | |
727 | (uri (string-append | |
728 | "http://dlib.net/files/dlib-" version ".tar.bz2")) | |
729 | (sha256 | |
730 | (base32 | |
d2a7cb46 | 731 | "139jyi19qz37wwmmy48gil9d1kkh2r3w3bwdzabha6ayxmba96nz")) |
5f0ff6a9 MB |
732 | (modules '((guix build utils))) |
733 | (snippet | |
734 | '(begin | |
735 | ;; Delete ~13MB of bundled dependencies. | |
736 | (delete-file-recursively "dlib/external") | |
0ef7ea66 MB |
737 | (delete-file-recursively "docs/dlib/external") |
738 | #t)))) | |
5f0ff6a9 MB |
739 | (build-system cmake-build-system) |
740 | (arguments | |
f90b2691 EF |
741 | `(#:configure-flags '("-DBUILD_SHARED_LIBS=ON") |
742 | #:phases | |
5f0ff6a9 MB |
743 | (modify-phases %standard-phases |
744 | (add-after 'unpack 'disable-asserts | |
745 | (lambda _ | |
746 | ;; config.h recommends explicitly enabling or disabling asserts | |
747 | ;; when building as a shared library. By default neither is set. | |
748 | (substitute* "dlib/config.h" | |
749 | (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS")) | |
750 | #t)) | |
4fba38db MB |
751 | (add-after 'disable-asserts 'disable-failing-tests |
752 | (lambda _ | |
753 | ;; One test times out on MIPS, so we need to disable it. | |
0ef7ea66 | 754 | ;; Others are flaky on some platforms. |
4fba38db MB |
755 | (let* ((system ,(or (%current-target-system) |
756 | (%current-system))) | |
757 | (disabled-tests (cond | |
758 | ((string-prefix? "mips64" system) | |
759 | '("object_detector" ; timeout | |
760 | "data_io")) | |
761 | ((string-prefix? "armhf" system) | |
a343c461 | 762 | '("learning_to_track")) |
4fba38db | 763 | ((string-prefix? "i686" system) |
0ef7ea66 | 764 | '("optimization")) |
4fba38db | 765 | (else '())))) |
4fba38db MB |
766 | (for-each |
767 | (lambda (test) | |
768 | (substitute* "dlib/test/makefile" | |
0ef7ea66 MB |
769 | (((string-append "SRC \\+= " test "\\.cpp")) ""))) |
770 | disabled-tests) | |
771 | #t))) | |
5f0ff6a9 MB |
772 | (replace 'check |
773 | (lambda _ | |
774 | ;; No test target, so we build and run the unit tests here. | |
8eaf53e3 | 775 | (let ((test-dir (string-append "../dlib-" ,version "/dlib/test"))) |
5f0ff6a9 | 776 | (with-directory-excursion test-dir |
8448e6bf TGR |
777 | (invoke "make" "-j" (number->string (parallel-job-count))) |
778 | (invoke "./dtest" "--runall")) | |
f90b2691 | 779 | #t)))))) |
5f0ff6a9 | 780 | (native-inputs |
3929f46c TGR |
781 | `(("pkg-config" ,pkg-config) |
782 | ;; For tests. | |
783 | ("libnsl" ,libnsl))) | |
5f0ff6a9 | 784 | (inputs |
f40841e9 | 785 | `(("giflib" ,giflib) |
4fba38db | 786 | ("lapack" ,lapack) |
4bd428a7 | 787 | ("libjpeg" ,libjpeg-turbo) |
5f0ff6a9 MB |
788 | ("libpng" ,libpng) |
789 | ("libx11" ,libx11) | |
790 | ("openblas" ,openblas) | |
791 | ("zlib" ,zlib))) | |
792 | (synopsis | |
793 | "Toolkit for making machine learning and data analysis applications in C++") | |
794 | (description | |
795 | "Dlib is a modern C++ toolkit containing machine learning algorithms and | |
796 | tools. It is used in both industry and academia in a wide range of domains | |
797 | including robotics, embedded devices, mobile phones, and large high performance | |
798 | computing environments.") | |
799 | (home-page "http://dlib.net") | |
800 | (license license:boost1.0))) | |
be6eb2f1 RW |
801 | |
802 | (define-public python-scikit-learn | |
803 | (package | |
804 | (name "python-scikit-learn") | |
96193caa | 805 | (version "0.24.1") |
be6eb2f1 RW |
806 | (source |
807 | (origin | |
4a89bdd1 RW |
808 | (method git-fetch) |
809 | (uri (git-reference | |
b0e7b699 | 810 | (url "https://github.com/scikit-learn/scikit-learn") |
4a89bdd1 RW |
811 | (commit version))) |
812 | (file-name (git-file-name name version)) | |
be6eb2f1 RW |
813 | (sha256 |
814 | (base32 | |
96193caa | 815 | "0dd854hi9h81pa3y6gwa6r4qjwrwq5fndi312h6dkqzfh7jbvgvd")))) |
be6eb2f1 RW |
816 | (build-system python-build-system) |
817 | (arguments | |
818 | `(#:phases | |
819 | (modify-phases %standard-phases | |
4a89bdd1 RW |
820 | (add-after 'build 'build-ext |
821 | (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t)) | |
822 | (replace 'check | |
823 | (lambda _ | |
824 | ;; Restrict OpenBLAS threads to prevent segfaults while testing! | |
825 | (setenv "OPENBLAS_NUM_THREADS" "1") | |
7ff3f3d2 MB |
826 | |
827 | ;; Some tests require write access to $HOME. | |
828 | (setenv "HOME" "/tmp") | |
829 | ||
830 | (invoke "pytest" "sklearn" "-m" "not network"))) | |
71804546 BL |
831 | (add-before 'reset-gzip-timestamps 'make-files-writable |
832 | (lambda* (#:key outputs #:allow-other-keys) | |
833 | ;; Make sure .gz files are writable so that the | |
834 | ;; 'reset-gzip-timestamps' phase can do its work. | |
835 | (let ((out (assoc-ref outputs "out"))) | |
836 | (for-each make-file-writable | |
837 | (find-files out "\\.gz$")) | |
838 | #t)))))) | |
be6eb2f1 RW |
839 | (inputs |
840 | `(("openblas" ,openblas))) | |
841 | (native-inputs | |
d9e9a261 | 842 | `(("python-pytest" ,python-pytest) |
4a89bdd1 | 843 | ("python-pandas" ,python-pandas) ;for tests |
be6eb2f1 RW |
844 | ("python-cython" ,python-cython))) |
845 | (propagated-inputs | |
846 | `(("python-numpy" ,python-numpy) | |
96193caa | 847 | ("python-threadpoolctl" ,python-threadpoolctl) |
d9e9a261 KH |
848 | ("python-scipy" ,python-scipy) |
849 | ("python-joblib" ,python-joblib))) | |
e51b34bb | 850 | (home-page "https://scikit-learn.org/") |
be6eb2f1 RW |
851 | (synopsis "Machine Learning in Python") |
852 | (description | |
4a89bdd1 RW |
853 | "Scikit-learn provides simple and efficient tools for data mining and |
854 | data analysis.") | |
382550f0 | 855 | (properties `((python2-variant . ,(delay python2-scikit-learn)))) |
be6eb2f1 RW |
856 | (license license:bsd-3))) |
857 | ||
382550f0 MB |
858 | ;; scikit-learn 0.22 and later only supports Python 3, so we stick with |
859 | ;; an older version here. | |
be6eb2f1 | 860 | (define-public python2-scikit-learn |
382550f0 MB |
861 | (let ((base (package-with-python2 (strip-python2-variant python-scikit-learn)))) |
862 | (package | |
863 | (inherit base) | |
864 | (version "0.20.4") | |
865 | (source (origin | |
866 | (method git-fetch) | |
867 | (uri (git-reference | |
b0e7b699 | 868 | (url "https://github.com/scikit-learn/scikit-learn") |
382550f0 MB |
869 | (commit version))) |
870 | (file-name (git-file-name "python-scikit-learn" version)) | |
871 | (sha256 | |
872 | (base32 | |
96193caa RW |
873 | "08zbzi8yx5wdlxfx9jap61vg1malc9ajf576w7a0liv6jvvrxlpj")))) |
874 | (inputs | |
875 | `(("openblas" ,openblas))) | |
876 | (native-inputs | |
877 | `(("python2-pytest" ,python2-pytest) | |
878 | ("python2-pandas" ,python2-pandas) ;for tests | |
879 | ("python2-cython" ,python2-cython))) | |
880 | (propagated-inputs | |
881 | `(("python2-numpy" ,python2-numpy) | |
882 | ("python2-scipy" ,python2-scipy) | |
883 | ("python2-joblib" ,python2-joblib)))))) | |
2dab4188 | 884 | |
3d72867e EF |
885 | (define-public python-threadpoolctl |
886 | (package | |
887 | (name "python-threadpoolctl") | |
888 | (version "2.1.0") | |
889 | (source | |
890 | (origin | |
891 | (method url-fetch) | |
892 | (uri (pypi-uri "threadpoolctl" version)) | |
893 | (sha256 | |
894 | (base32 | |
895 | "0szsxcm2fbxrn83iynn42bnvrdh7mfsmkhfn8pdn7swblfb7rifx")))) | |
896 | (build-system python-build-system) | |
897 | (arguments | |
898 | `(#:phases | |
899 | (modify-phases %standard-phases | |
900 | (replace 'check | |
901 | (lambda* (#:key tests? inputs outputs #:allow-other-keys) | |
902 | (when tests? | |
903 | (add-installed-pythonpath inputs outputs) | |
904 | (invoke "pytest")) | |
905 | #t))))) | |
906 | (native-inputs | |
907 | `(("python-pytest" ,python-pytest))) | |
908 | (home-page "https://github.com/joblib/threadpoolctl") | |
909 | (synopsis "Python helpers for common threading libraries") | |
910 | (description "Thread-pool Controls provides Python helpers to limit the | |
911 | number of threads used in the threadpool-backed of common native libraries used | |
912 | for scientific computing and data science (e.g. BLAS and OpenMP).") | |
913 | (license license:bsd-3))) | |
914 | ||
8cd10a76 VM |
915 | (define-public python-pynndescent |
916 | (package | |
917 | (name "python-pynndescent") | |
918 | (version "0.4.8") | |
919 | (source | |
920 | (origin | |
921 | (method url-fetch) | |
922 | (uri (pypi-uri "pynndescent" version)) | |
923 | (sha256 | |
924 | (base32 "0li1fclif50v6xrq7wh3lif9vv5jpj7xhrb0z6g89wwjnp9b9833")))) | |
925 | (build-system python-build-system) | |
926 | (native-inputs | |
927 | `(("python-nose" ,python-nose))) | |
928 | (propagated-inputs | |
929 | `(("python-joblib" ,python-joblib) | |
930 | ("python-llvmlite" ,python-llvmlite) | |
931 | ("python-numba" ,python-numba) | |
932 | ("python-scikit-learn" ,python-scikit-learn) | |
933 | ("python-scipy" ,python-scipy))) | |
934 | (home-page "https://github.com/lmcinnes/pynndescent") | |
935 | (synopsis "Nearest neighbor descent for approximate nearest neighbors") | |
936 | (description | |
937 | "PyNNDescent provides a Python implementation of Nearest Neighbor Descent | |
938 | for k-neighbor-graph construction and approximate nearest neighbor search.") | |
939 | (license license:bsd-2))) | |
940 | ||
6a5da0d0 VM |
941 | (define-public python-opentsne |
942 | (package | |
943 | (name "python-opentsne") | |
944 | (version "0.4.4") | |
945 | (source | |
946 | (origin | |
947 | ;; No tests in the PyPI tarball. | |
948 | (method git-fetch) | |
949 | (uri (git-reference | |
950 | (url "https://github.com/pavlin-policar/openTSNE") | |
951 | (commit (string-append "v" version)))) | |
952 | (file-name (string-append name "-" version "-checkout")) | |
953 | (sha256 | |
954 | (base32 "08wamsssmyf6511cbmglm67dp48i6xazs89m1cskdk219v90bc76")))) | |
955 | (build-system python-build-system) | |
956 | (arguments | |
957 | `(#:phases | |
958 | (modify-phases %standard-phases | |
959 | ;; Benchmarks require the 'macosko2015' data files. | |
960 | (add-after 'unpack 'delete-benchmark | |
961 | (lambda _ | |
962 | (delete-file-recursively "benchmarks") | |
963 | #t)) | |
964 | ;; Numba needs a writable dir to cache functions. | |
965 | (add-before 'check 'set-numba-cache-dir | |
966 | (lambda _ | |
967 | (setenv "NUMBA_CACHE_DIR" "/tmp") | |
968 | #t))))) | |
969 | (native-inputs | |
970 | `(("python-cython" ,python-cython))) | |
971 | (inputs | |
972 | `(("fftw" ,fftw))) | |
973 | (propagated-inputs | |
974 | `(("python-numpy" ,python-numpy) | |
975 | ("python-pynndescent" ,python-pynndescent) | |
976 | ("python-scikit-learn" ,python-scikit-learn) | |
977 | ("python-scipy" ,python-scipy))) | |
978 | (home-page "https://github.com/pavlin-policar/openTSNE") | |
979 | (synopsis "Extensible, parallel implementations of t-SNE") | |
980 | (description | |
981 | "This is a modular Python implementation of t-Distributed Stochastic | |
982 | Neighbor Embedding (t-SNE), a popular dimensionality-reduction algorithm for | |
983 | visualizing high-dimensional data sets.") | |
984 | (license license:bsd-3))) | |
985 | ||
639ae3f2 RJ |
986 | (define-public python-scikit-rebate |
987 | (package | |
988 | (name "python-scikit-rebate") | |
989 | (version "0.6") | |
990 | (source (origin | |
991 | (method url-fetch) | |
992 | (uri (pypi-uri "skrebate" version)) | |
993 | (sha256 | |
994 | (base32 | |
995 | "1h7qs9gjxpzqabzhb8rmpv3jpmi5iq41kqdibg48299h94iikiw7")))) | |
996 | (build-system python-build-system) | |
997 | ;; Pandas is only needed to run the tests. | |
998 | (native-inputs | |
999 | `(("python-pandas" ,python-pandas))) | |
1000 | (propagated-inputs | |
1001 | `(("python-numpy" ,python-numpy) | |
1002 | ("python-scipy" ,python-scipy) | |
1003 | ("python-scikit-learn" ,python-scikit-learn) | |
1004 | ("python-joblib" ,python-joblib))) | |
1005 | (home-page "https://epistasislab.github.io/scikit-rebate/") | |
1006 | (synopsis "Relief-based feature selection algorithms for Python") | |
1007 | (description "Scikit-rebate is a scikit-learn-compatible Python | |
1008 | implementation of ReBATE, a suite of Relief-based feature selection algorithms | |
1009 | for Machine Learning. These algorithms excel at identifying features that are | |
1010 | predictive of the outcome in supervised learning problems, and are especially | |
1011 | good at identifying feature interactions that are normally overlooked by | |
1012 | standard feature selection algorithms.") | |
1013 | (license license:expat))) | |
1014 | ||
2dab4188 FT |
1015 | (define-public python-autograd |
1016 | (let* ((commit "442205dfefe407beffb33550846434baa90c4de7") | |
1017 | (revision "0") | |
1018 | (version (git-version "0.0.0" revision commit))) | |
1019 | (package | |
1020 | (name "python-autograd") | |
1021 | (home-page "https://github.com/HIPS/autograd") | |
1022 | (source (origin | |
1023 | (method git-fetch) | |
1024 | (uri (git-reference | |
1025 | (url home-page) | |
1026 | (commit commit))) | |
1027 | (sha256 | |
1028 | (base32 | |
1029 | "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4")) | |
1030 | (file-name (git-file-name name version)))) | |
1031 | (version version) | |
1032 | (build-system python-build-system) | |
1033 | (native-inputs | |
1034 | `(("python-nose" ,python-nose) | |
1035 | ("python-pytest" ,python-pytest))) | |
1036 | (propagated-inputs | |
1037 | `(("python-future" ,python-future) | |
1038 | ("python-numpy" ,python-numpy))) | |
1039 | (arguments | |
1040 | `(#:phases (modify-phases %standard-phases | |
1041 | (replace 'check | |
1042 | (lambda _ | |
1043 | (invoke "py.test" "-v")))))) | |
1044 | (synopsis "Efficiently computes derivatives of NumPy code") | |
1045 | (description "Autograd can automatically differentiate native Python and | |
1046 | NumPy code. It can handle a large subset of Python's features, including loops, | |
1047 | ifs, recursion and closures, and it can even take derivatives of derivatives | |
1048 | of derivatives. It supports reverse-mode differentiation | |
1049 | (a.k.a. backpropagation), which means it can efficiently take gradients of | |
1050 | scalar-valued functions with respect to array-valued arguments, as well as | |
1051 | forward-mode differentiation, and the two can be composed arbitrarily. The | |
1052 | main intended application of Autograd is gradient-based optimization.") | |
1053 | (license license:expat)))) | |
1054 | ||
1055 | (define-public python2-autograd | |
1056 | (package-with-python2 python-autograd)) | |
112c2c01 FT |
1057 | |
1058 | (define-public lightgbm | |
1059 | (package | |
1060 | (name "lightgbm") | |
1061 | (version "2.0.12") | |
1062 | (source (origin | |
a2a7cc9b EF |
1063 | (method git-fetch) |
1064 | (uri (git-reference | |
1065 | (url "https://github.com/Microsoft/LightGBM") | |
1066 | (commit (string-append "v" version)))) | |
112c2c01 FT |
1067 | (sha256 |
1068 | (base32 | |
a2a7cc9b EF |
1069 | "0jlvyn7k81dzrh9ij3zw576wbgiwmmr26rzpdxjn1dbpc3njpvzi")) |
1070 | (file-name (git-file-name name version)))) | |
112c2c01 FT |
1071 | (native-inputs |
1072 | `(("python-pytest" ,python-pytest) | |
1073 | ("python-nose" ,python-nose))) | |
1074 | (inputs | |
1075 | `(("openmpi" ,openmpi))) | |
1076 | (propagated-inputs | |
1077 | `(("python-numpy" ,python-numpy) | |
1078 | ("python-scipy" ,python-scipy))) | |
1079 | (arguments | |
1080 | `(#:configure-flags | |
1081 | '("-DUSE_MPI=ON") | |
1082 | #:phases | |
1083 | (modify-phases %standard-phases | |
1084 | (replace 'check | |
a2a7cc9b EF |
1085 | (lambda _ |
1086 | (with-directory-excursion "../source" | |
112c2c01 FT |
1087 | (invoke "pytest" "tests/c_api_test/test_.py"))))))) |
1088 | (build-system cmake-build-system) | |
1089 | (home-page "https://github.com/Microsoft/LightGBM") | |
1090 | (synopsis "Gradient boosting framework based on decision tree algorithms") | |
1091 | (description "LightGBM is a gradient boosting framework that uses tree | |
1092 | based learning algorithms. It is designed to be distributed and efficient with | |
1093 | the following advantages: | |
1094 | ||
1095 | @itemize | |
1096 | @item Faster training speed and higher efficiency | |
1097 | @item Lower memory usage | |
1098 | @item Better accuracy | |
1099 | @item Parallel and GPU learning supported (not enabled in this package) | |
1100 | @item Capable of handling large-scale data | |
1101 | @end itemize\n") | |
1102 | (license license:expat))) | |
a8fb82a8 FT |
1103 | |
1104 | (define-public vowpal-wabbit | |
1105 | ;; Language bindings not included. | |
1106 | (package | |
1107 | (name "vowpal-wabbit") | |
1108 | (version "8.5.0") | |
1109 | (source (origin | |
4eb40497 EF |
1110 | (method git-fetch) |
1111 | (uri (git-reference | |
1112 | (url "https://github.com/JohnLangford/vowpal_wabbit") | |
1113 | (commit version))) | |
a8fb82a8 FT |
1114 | (sha256 |
1115 | (base32 | |
4eb40497 EF |
1116 | "04bwzk6ifgnz3fmzid8b7avxf9n5pnx9xcjm61nkjng1vv0bpj8x")) |
1117 | (file-name (git-file-name name version)))) | |
a8fb82a8 FT |
1118 | (inputs |
1119 | `(("boost" ,boost) | |
1120 | ("zlib" ,zlib))) | |
1121 | (arguments | |
1122 | `(#:configure-flags | |
1123 | (list (string-append "--with-boost=" | |
4eb40497 EF |
1124 | (assoc-ref %build-inputs "boost"))) |
1125 | #:phases | |
1126 | (modify-phases %standard-phases | |
1127 | (add-after 'unpack 'make-files-writable | |
1128 | (lambda _ | |
d9bba529 EF |
1129 | (for-each make-file-writable (find-files "." ".*")) #t)) |
1130 | (add-after 'install 'install-more-headers | |
1131 | (lambda* (#:key outputs #:allow-other-keys) | |
1132 | (for-each | |
1133 | (lambda (file) | |
1134 | (install-file file (string-append | |
1135 | (assoc-ref outputs "out") | |
1136 | "/include/vowpalwabbit"))) | |
1137 | (find-files "vowpalwabbit" "\\.h$")) | |
1138 | #t))))) | |
a8fb82a8 FT |
1139 | (build-system gnu-build-system) |
1140 | (home-page "https://github.com/JohnLangford/vowpal_wabbit") | |
1141 | (synopsis "Fast machine learning library for online learning") | |
1142 | (description "Vowpal Wabbit is a machine learning system with techniques | |
1143 | such as online, hashing, allreduce, reductions, learning2search, active, and | |
1144 | interactive learning.") | |
1145 | (license license:bsd-3))) | |
915c6bf6 LC |
1146 | |
1147 | (define-public python2-fastlmm | |
1148 | (package | |
1149 | (name "python2-fastlmm") | |
1150 | (version "0.2.21") | |
1151 | (source | |
1152 | (origin | |
1153 | (method url-fetch) | |
1154 | (uri (pypi-uri "fastlmm" version ".zip")) | |
1155 | (sha256 | |
1156 | (base32 | |
1157 | "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m")))) | |
1158 | (build-system python-build-system) | |
1159 | (arguments | |
237ee6f2 RW |
1160 | `(#:tests? #f ; some test files are missing |
1161 | #:python ,python-2)) ; only Python 2.7 is supported | |
915c6bf6 LC |
1162 | (propagated-inputs |
1163 | `(("python2-numpy" ,python2-numpy) | |
1164 | ("python2-scipy" ,python2-scipy) | |
1165 | ("python2-matplotlib" ,python2-matplotlib) | |
1166 | ("python2-pandas" ,python2-pandas) | |
1167 | ("python2-scikit-learn" ,python2-scikit-learn) | |
1168 | ("python2-pysnptools" ,python2-pysnptools))) | |
1169 | (native-inputs | |
1170 | `(("unzip" ,unzip) | |
1171 | ("python2-cython" ,python2-cython) | |
1172 | ("python2-mock" ,python2-mock) | |
1173 | ("python2-nose" ,python2-nose))) | |
1174 | (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/") | |
1175 | (synopsis "Perform genome-wide association studies on large data sets") | |
1176 | (description | |
1177 | "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed | |
1178 | Models, is a program for performing both single-SNP and SNP-set genome-wide | |
1179 | association studies (GWAS) on extremely large data sets.") | |
1180 | (license license:asl2.0))) | |
b9445d0b RW |
1181 | |
1182 | ;; There have been no proper releases yet. | |
1183 | (define-public kaldi | |
0877b74f RW |
1184 | (let ((commit "d4791c0f3fc1a09c042dac365e120899ee2ad21e") |
1185 | (revision "2")) | |
b9445d0b RW |
1186 | (package |
1187 | (name "kaldi") | |
1188 | (version (git-version "0" revision commit)) | |
1189 | (source (origin | |
1190 | (method git-fetch) | |
1191 | (uri (git-reference | |
b0e7b699 | 1192 | (url "https://github.com/kaldi-asr/kaldi") |
b9445d0b RW |
1193 | (commit commit))) |
1194 | (file-name (git-file-name name version)) | |
1195 | (sha256 | |
1196 | (base32 | |
0877b74f | 1197 | "07k80my6f19mhrkwbzhjsnpf9871wmrwkl0ym468i830w67qyjrz")))) |
b9445d0b RW |
1198 | (build-system gnu-build-system) |
1199 | (arguments | |
1200 | `(#:test-target "test" | |
1201 | #:phases | |
1202 | (modify-phases %standard-phases | |
1203 | (add-after 'unpack 'chdir | |
1204 | (lambda _ (chdir "src") #t)) | |
1205 | (replace 'configure | |
1206 | (lambda* (#:key build system inputs outputs #:allow-other-keys) | |
1207 | (when (not (or (string-prefix? "x86_64" system) | |
1208 | (string-prefix? "i686" system))) | |
1209 | (substitute* "makefiles/linux_openblas.mk" | |
1210 | (("-msse -msse2") ""))) | |
1211 | (substitute* "makefiles/default_rules.mk" | |
1212 | (("/bin/bash") (which "bash"))) | |
1213 | (substitute* "Makefile" | |
1214 | (("ext_depend: check_portaudio") | |
1215 | "ext_depend:")) | |
1216 | (substitute* '("online/Makefile" | |
1217 | "onlinebin/Makefile" | |
1218 | "gst-plugin/Makefile") | |
1219 | (("../../tools/portaudio/install") | |
1220 | (assoc-ref inputs "portaudio"))) | |
1221 | ||
1222 | ;; This `configure' script doesn't support variables passed as | |
1223 | ;; arguments, nor does it support "prefix". | |
1224 | (let ((out (assoc-ref outputs "out")) | |
1225 | (openblas (assoc-ref inputs "openblas")) | |
1226 | (openfst (assoc-ref inputs "openfst"))) | |
1227 | (substitute* "configure" | |
1228 | (("check_for_slow_expf;") "") | |
1229 | ;; This affects the RPATH and also serves as the installation | |
1230 | ;; directory. | |
1231 | (("KALDILIBDIR=`pwd`/lib") | |
1232 | (string-append "KALDILIBDIR=" out "/lib"))) | |
1233 | (mkdir-p out) ; must exist | |
1234 | (setenv "CONFIG_SHELL" (which "bash")) | |
1235 | (setenv "OPENFST_VER" ,(package-version openfst)) | |
1236 | (invoke "./configure" | |
1237 | "--use-cuda=no" | |
1238 | "--shared" | |
1239 | (string-append "--openblas-root=" openblas) | |
1240 | (string-append "--fst-root=" openfst))))) | |
1241 | (add-after 'build 'build-ext-and-gstreamer-plugin | |
1242 | (lambda _ | |
1243 | (invoke "make" "-C" "online" "depend") | |
1244 | (invoke "make" "-C" "online") | |
1245 | (invoke "make" "-C" "onlinebin" "depend") | |
1246 | (invoke "make" "-C" "onlinebin") | |
1247 | (invoke "make" "-C" "gst-plugin" "depend") | |
1248 | (invoke "make" "-C" "gst-plugin") | |
1249 | #t)) | |
1250 | ;; TODO: also install the executables. | |
1251 | (replace 'install | |
1252 | (lambda* (#:key outputs #:allow-other-keys) | |
1253 | (let* ((out (assoc-ref outputs "out")) | |
1fdd20c7 | 1254 | (inc (string-append out "/include")) |
b9445d0b RW |
1255 | (lib (string-append out "/lib"))) |
1256 | (mkdir-p lib) | |
1fdd20c7 RW |
1257 | ;; The build phase installed symlinks to the actual |
1258 | ;; libraries. Install the actual targets. | |
1259 | (for-each (lambda (file) | |
1260 | (let ((target (readlink file))) | |
1261 | (delete-file file) | |
1262 | (install-file target lib))) | |
1263 | (find-files lib "\\.so")) | |
1264 | ;; Install headers | |
1265 | (for-each (lambda (file) | |
1266 | (let ((target-dir (string-append inc "/" (dirname file)))) | |
1267 | (install-file file target-dir))) | |
1268 | (find-files "." "\\.h")) | |
1269 | (install-file "gst-plugin/libgstonlinegmmdecodefaster.so" | |
1270 | (string-append lib "/gstreamer-1.0")) | |
b9445d0b RW |
1271 | #t)))))) |
1272 | (inputs | |
1273 | `(("alsa-lib" ,alsa-lib) | |
1274 | ("gfortran" ,gfortran "lib") | |
1275 | ("glib" ,glib) | |
1276 | ("gstreamer" ,gstreamer) | |
1277 | ("jack" ,jack-1) | |
1278 | ("openblas" ,openblas) | |
1279 | ("openfst" ,openfst) | |
1280 | ("portaudio" ,portaudio) | |
1281 | ("python" ,python))) | |
1282 | (native-inputs | |
1283 | `(("glib" ,glib "bin") ; glib-genmarshal | |
1284 | ("grep" ,grep) | |
1285 | ("sed" ,sed) | |
1286 | ("pkg-config" ,pkg-config) | |
1287 | ("which" ,which))) | |
1288 | (home-page "https://kaldi-asr.org/") | |
1289 | (synopsis "Speech recognition toolkit") | |
1290 | (description "Kaldi is an extensible toolkit for speech recognition | |
1291 | written in C++.") | |
1292 | (license license:asl2.0)))) | |
99260014 RW |
1293 | |
1294 | (define-public gst-kaldi-nnet2-online | |
b3cf5f86 RW |
1295 | (let ((commit "cb227ef43b66a9835c14eb0ad39e08ee03c210ad") |
1296 | (revision "2")) | |
99260014 RW |
1297 | (package |
1298 | (name "gst-kaldi-nnet2-online") | |
1299 | (version (git-version "0" revision commit)) | |
1300 | (source (origin | |
1301 | (method git-fetch) | |
1302 | (uri (git-reference | |
b0e7b699 | 1303 | (url "https://github.com/alumae/gst-kaldi-nnet2-online") |
99260014 RW |
1304 | (commit commit))) |
1305 | (file-name (git-file-name name version)) | |
1306 | (sha256 | |
1307 | (base32 | |
b3cf5f86 | 1308 | "1i6ffwiavxx07ri0lxix6s8q0r31x7i4xxvhys5jxkixf5q34w8g")))) |
99260014 RW |
1309 | (build-system gnu-build-system) |
1310 | (arguments | |
1311 | `(#:tests? #f ; there are none | |
1312 | #:make-flags | |
1313 | (list (string-append "SHELL=" | |
1314 | (assoc-ref %build-inputs "bash") "/bin/bash") | |
1315 | (string-append "KALDI_ROOT=" | |
1316 | (assoc-ref %build-inputs "kaldi-src")) | |
1317 | (string-append "KALDILIBDIR=" | |
1318 | (assoc-ref %build-inputs "kaldi") "/lib") | |
1319 | "KALDI_FLAVOR=dynamic") | |
1320 | #:phases | |
1321 | (modify-phases %standard-phases | |
1322 | (add-after 'unpack 'chdir | |
1323 | (lambda _ (chdir "src") #t)) | |
1324 | (replace 'configure | |
1325 | (lambda* (#:key inputs #:allow-other-keys) | |
1326 | (let ((glib (assoc-ref inputs "glib"))) | |
ad60a348 | 1327 | (setenv "CXXFLAGS" "-fPIC") |
99260014 RW |
1328 | (setenv "CPLUS_INCLUDE_PATH" |
1329 | (string-append glib "/include/glib-2.0:" | |
1330 | glib "/lib/glib-2.0/include:" | |
1331 | (assoc-ref inputs "gstreamer") | |
ad60a348 | 1332 | "/include/gstreamer-1.0"))) |
99260014 RW |
1333 | (substitute* "Makefile" |
1334 | (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "") | |
ad60a348 MB |
1335 | (("\\$\\(error Cannot find") "#")) |
1336 | #t)) | |
99260014 RW |
1337 | (add-before 'build 'build-depend |
1338 | (lambda* (#:key make-flags #:allow-other-keys) | |
1339 | (apply invoke "make" "depend" make-flags))) | |
1340 | (replace 'install | |
1341 | (lambda* (#:key outputs #:allow-other-keys) | |
1342 | (let* ((out (assoc-ref outputs "out")) | |
1343 | (lib (string-append out "/lib/gstreamer-1.0"))) | |
1344 | (install-file "libgstkaldinnet2onlinedecoder.so" lib) | |
1345 | #t)))))) | |
1346 | (inputs | |
1347 | `(("glib" ,glib) | |
1348 | ("gstreamer" ,gstreamer) | |
1349 | ("jansson" ,jansson) | |
1350 | ("openfst" ,openfst) | |
1351 | ("kaldi" ,kaldi))) | |
1352 | (native-inputs | |
1353 | `(("bash" ,bash) | |
1354 | ("glib:bin" ,glib "bin") ; glib-genmarshal | |
1355 | ("kaldi-src" ,(package-source kaldi)) | |
1356 | ("pkg-config" ,pkg-config))) | |
1357 | (home-page "https://kaldi-asr.org/") | |
1358 | (synopsis "Gstreamer plugin for decoding speech") | |
1359 | (description "This package provides a GStreamer plugin that wraps | |
1360 | Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN | |
1361 | acoustic models. The iVectors are adapted to the current audio stream | |
1362 | automatically.") | |
1363 | (license license:asl2.0)))) | |
10451f6b RW |
1364 | |
1365 | (define-public kaldi-gstreamer-server | |
1228c2ab RW |
1366 | ;; This is the tip of the py3 branch |
1367 | (let ((commit "f68cab490be7eb0da2af1475fbc16655f50a60cb") | |
1368 | (revision "2")) | |
10451f6b RW |
1369 | (package |
1370 | (name "kaldi-gstreamer-server") | |
1371 | (version (git-version "0" revision commit)) | |
1372 | (source (origin | |
1373 | (method git-fetch) | |
1374 | (uri (git-reference | |
b0e7b699 | 1375 | (url "https://github.com/alumae/kaldi-gstreamer-server") |
10451f6b RW |
1376 | (commit commit))) |
1377 | (file-name (git-file-name name version)) | |
1378 | (sha256 | |
1379 | (base32 | |
1228c2ab | 1380 | "17lh1368vkg8ngrcbn2phvigzlmalrqg6djx2gg61qq1a0nj87dm")))) |
10451f6b RW |
1381 | (build-system gnu-build-system) |
1382 | (arguments | |
1383 | `(#:tests? #f ; there are no tests that can be run automatically | |
1384 | #:modules ((guix build utils) | |
1385 | (guix build gnu-build-system) | |
1386 | (srfi srfi-26)) | |
1387 | #:phases | |
1388 | (modify-phases %standard-phases | |
1389 | (delete 'configure) | |
1390 | (replace 'build | |
1391 | (lambda* (#:key outputs #:allow-other-keys) | |
1392 | ;; Disable hash randomization to ensure the generated .pycs | |
1393 | ;; are reproducible. | |
1394 | (setenv "PYTHONHASHSEED" "0") | |
1395 | (with-directory-excursion "kaldigstserver" | |
46d07f84 RW |
1396 | ;; See https://github.com/alumae/kaldi-gstreamer-server/issues/232 |
1397 | (substitute* "master_server.py" | |
1398 | (("\\.replace\\('\\\\.*") ")")) | |
1399 | ||
1228c2ab RW |
1400 | ;; This is a Python 2 file |
1401 | (delete-file "decoder_test.py") | |
1402 | (delete-file "test-buffer.py") | |
1403 | ||
10451f6b RW |
1404 | (for-each (lambda (file) |
1405 | (apply invoke | |
1406 | `("python" | |
1407 | "-m" "compileall" | |
1408 | "-f" ; force rebuild | |
1409 | ,file))) | |
1410 | (find-files "." "\\.py$"))) | |
1411 | #t)) | |
1412 | (replace 'install | |
1413 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1414 | (let* ((out (assoc-ref outputs "out")) | |
1415 | (bin (string-append out "/bin")) | |
1416 | (share (string-append out "/share/kaldi-gstreamer-server/"))) | |
1417 | ;; Install Python files | |
1418 | (with-directory-excursion "kaldigstserver" | |
1419 | (for-each (cut install-file <> share) | |
1420 | (find-files "." ".*"))) | |
1421 | ||
1422 | ;; Install sample configuration files | |
1423 | (for-each (cut install-file <> share) | |
1424 | (find-files "." "\\.yaml")) | |
1425 | ||
1426 | ;; Install executables | |
1427 | (mkdir-p bin) | |
1428 | (let* ((server (string-append bin "/kaldi-gst-server")) | |
1429 | (client (string-append bin "/kaldi-gst-client")) | |
1430 | (worker (string-append bin "/kaldi-gst-worker")) | |
1431 | (PYTHONPATH (getenv "PYTHONPATH")) | |
1432 | (GST_PLUGIN_PATH (string-append | |
1433 | (assoc-ref inputs "gst-kaldi-nnet2-online") | |
1434 | "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}")) | |
1435 | (wrap (lambda (wrapper what) | |
1436 | (with-output-to-file wrapper | |
1437 | (lambda _ | |
1438 | (format #t | |
1439 | "#!~a | |
1440 | export PYTHONPATH=~a | |
1441 | export GST_PLUGIN_PATH=~a | |
1442 | exec ~a ~a/~a \"$@\"~%" | |
1443 | (which "bash") PYTHONPATH GST_PLUGIN_PATH | |
1444 | (which "python") share what))) | |
1445 | (chmod wrapper #o555)))) | |
1446 | (for-each wrap | |
1447 | (list server client worker) | |
1448 | (list "master_server.py" | |
1449 | "client.py" | |
1450 | "worker.py"))) | |
1451 | #t)))))) | |
1452 | (inputs | |
1453 | `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online) | |
1228c2ab RW |
1454 | ("python" ,python-wrapper) |
1455 | ("python-pygobject" ,python-pygobject) | |
1456 | ("python-pyyaml" ,python-pyyaml) | |
cb44af24 | 1457 | ("python-tornado" ,python-tornado-6))) |
10451f6b RW |
1458 | (home-page "https://github.com/alumae/kaldi-gstreamer-server") |
1459 | (synopsis "Real-time full-duplex speech recognition server") | |
1460 | (description "This is a real-time full-duplex speech recognition server, | |
1461 | based on the Kaldi toolkit and the GStreamer framework and implemented in | |
1462 | Python.") | |
1463 | (license license:bsd-2)))) | |
0dfeb285 | 1464 | |
4fa16c9a RW |
1465 | ;; Note that Tensorflow includes a "third_party" directory, which seems to not |
1466 | ;; only contain modified subsets of upstream library source code, but also | |
1467 | ;; adapter headers provided by Google (such as the fft.h header, which is not | |
1468 | ;; part of the upstream project code). The Tensorflow code includes headers | |
1469 | ;; from the "third_party" directory. It does not look like we can replace | |
1470 | ;; these headers with unmodified upstream files, so we keep them. | |
1471 | (define-public tensorflow | |
1472 | (package | |
1473 | (name "tensorflow") | |
1474 | (version "1.9.0") | |
1475 | (source | |
1476 | (origin | |
1477 | (method git-fetch) | |
1478 | (uri (git-reference | |
b0e7b699 | 1479 | (url "https://github.com/tensorflow/tensorflow") |
4fa16c9a RW |
1480 | (commit (string-append "v" version)))) |
1481 | (file-name (string-append "tensorflow-" version "-checkout")) | |
1482 | (sha256 | |
1483 | (base32 | |
1484 | "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa")))) | |
1485 | (build-system cmake-build-system) | |
1486 | (arguments | |
1487 | `(#:tests? #f ; no "check" target | |
1488 | #:build-type "Release" | |
1489 | #:configure-flags | |
1490 | (let ((protobuf (assoc-ref %build-inputs "protobuf")) | |
1491 | (protobuf:native (assoc-ref %build-inputs "protobuf:native")) | |
1492 | (jsoncpp (assoc-ref %build-inputs "jsoncpp")) | |
1493 | (snappy (assoc-ref %build-inputs "snappy")) | |
1494 | (sqlite (assoc-ref %build-inputs "sqlite"))) | |
1495 | (list | |
1496 | ;; Use protobuf from Guix | |
1497 | (string-append "-Dprotobuf_STATIC_LIBRARIES=" | |
1498 | protobuf "/lib/libprotobuf.so") | |
1499 | (string-append "-DPROTOBUF_PROTOC_EXECUTABLE=" | |
1500 | protobuf:native "/bin/protoc") | |
1501 | ||
1502 | ;; Use snappy from Guix | |
1503 | (string-append "-Dsnappy_STATIC_LIBRARIES=" | |
1504 | snappy "/lib/libsnappy.so") | |
1505 | ;; Yes, this is not actually the include directory but a prefix... | |
1506 | (string-append "-Dsnappy_INCLUDE_DIR=" snappy) | |
1507 | ||
1508 | ;; Use jsoncpp from Guix | |
1509 | (string-append "-Djsoncpp_STATIC_LIBRARIES=" | |
1510 | jsoncpp "/lib/libjsoncpp.so") | |
1511 | ;; Yes, this is not actually the include directory but a prefix... | |
1512 | (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp) | |
1513 | ||
1514 | ;; Use sqlite from Guix | |
1515 | (string-append "-Dsqlite_STATIC_LIBRARIES=" | |
1516 | sqlite "/lib/libsqlite.a") | |
1517 | ||
1518 | ;; Use system libraries wherever possible. Currently, this | |
1519 | ;; only affects zlib. | |
1520 | "-Dsystemlib_ALL=ON" | |
1521 | "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON" | |
1522 | "-Dtensorflow_BUILD_SHARED_LIB=ON" | |
1523 | "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF" | |
1524 | "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF" | |
1525 | "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF")) | |
1526 | #:make-flags | |
1527 | (list "CC=gcc") | |
1528 | #:modules ((ice-9 ftw) | |
1529 | (guix build utils) | |
0b967058 EF |
1530 | (guix build cmake-build-system) |
1531 | ((guix build python-build-system) | |
1532 | #:select (python-version))) | |
1533 | #:imported-modules (,@%cmake-build-system-modules | |
1534 | (guix build python-build-system)) | |
4fa16c9a RW |
1535 | #:phases |
1536 | (modify-phases %standard-phases | |
1537 | (add-after 'unpack 'set-source-file-times-to-1980 | |
1538 | ;; At the end of the tf_python_build_pip_package target, a ZIP | |
1539 | ;; archive should be generated via bdist_wheel, but it fails with | |
1540 | ;; "ZIP does not support timestamps before 1980". Luckily, | |
1541 | ;; SOURCE_DATE_EPOCH is respected, which we set to some time in | |
1542 | ;; 1980. | |
1543 | (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t)) | |
1544 | ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913 | |
1545 | (add-after 'unpack 'python3.7-compatibility | |
1546 | (lambda _ | |
1547 | (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc" | |
1548 | "tensorflow/python/lib/core/ndarray_tensor.cc" | |
1549 | "tensorflow/python/lib/core/py_func.cc") | |
1550 | (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8")) | |
1551 | (substitute* "tensorflow/c/eager/c_api.h" | |
1552 | (("unsigned char async") | |
1553 | "unsigned char is_async")) | |
1554 | ||
1555 | ;; Remove dependency on tensorboard, a complicated but probably | |
1556 | ;; optional package. | |
1557 | (substitute* "tensorflow/tools/pip_package/setup.py" | |
1558 | ((".*'tensorboard >.*") "")) | |
0b967058 EF |
1559 | |
1560 | ;; Fix the build with python-3.8, taken from rejected upstream patch: | |
1561 | ;; https://github.com/tensorflow/tensorflow/issues/34197 | |
1562 | (substitute* (find-files "tensorflow/python" ".*\\.cc$") | |
1563 | (("(nullptr,)(\\ +/. tp_print)" _ _ tp_print) | |
1564 | (string-append "NULL, " tp_print))) | |
4fa16c9a RW |
1565 | #t)) |
1566 | (add-after 'python3.7-compatibility 'chdir | |
1567 | (lambda _ (chdir "tensorflow/contrib/cmake") #t)) | |
1568 | (add-after 'chdir 'disable-downloads | |
1569 | (lambda* (#:key inputs #:allow-other-keys) | |
1570 | (substitute* (find-files "external" "\\.cmake$") | |
1571 | (("GIT_REPOSITORY.*") "") | |
1572 | (("GIT_TAG.*") "") | |
1573 | (("PREFIX ") | |
1574 | "DOWNLOAD_COMMAND \"\"\nPREFIX ")) | |
1575 | ||
1576 | ;; Use packages from Guix | |
1577 | (let ((grpc (assoc-ref inputs "grpc"))) | |
1578 | (substitute* "CMakeLists.txt" | |
1579 | ;; Sqlite | |
1580 | (("include\\(sqlite\\)") "") | |
1581 | (("\\$\\{sqlite_STATIC_LIBRARIES\\}") | |
1582 | (string-append (assoc-ref inputs "sqlite") | |
1583 | "/lib/libsqlite3.so")) | |
1584 | (("sqlite_copy_headers_to_destination") "") | |
1585 | ||
1586 | ;; PNG | |
1587 | (("include\\(png\\)") "") | |
1588 | (("\\$\\{png_STATIC_LIBRARIES\\}") | |
1589 | (string-append (assoc-ref inputs "libpng") | |
1590 | "/lib/libpng16.so")) | |
1591 | (("png_copy_headers_to_destination") "") | |
1592 | ||
1593 | ;; JPEG | |
1594 | (("include\\(jpeg\\)") "") | |
1595 | (("\\$\\{jpeg_STATIC_LIBRARIES\\}") | |
1596 | (string-append (assoc-ref inputs "libjpeg") | |
1597 | "/lib/libjpeg.so")) | |
1598 | (("jpeg_copy_headers_to_destination") "") | |
1599 | ||
1600 | ;; GIF | |
1601 | (("include\\(gif\\)") "") | |
1602 | (("\\$\\{gif_STATIC_LIBRARIES\\}") | |
1603 | (string-append (assoc-ref inputs "giflib") | |
1604 | "/lib/libgif.so")) | |
1605 | (("gif_copy_headers_to_destination") "") | |
1606 | ||
1607 | ;; lmdb | |
1608 | (("include\\(lmdb\\)") "") | |
1609 | (("\\$\\{lmdb_STATIC_LIBRARIES\\}") | |
1610 | (string-append (assoc-ref inputs "lmdb") | |
1611 | "/lib/liblmdb.so")) | |
1612 | (("lmdb_copy_headers_to_destination") "") | |
1613 | ||
1614 | ;; Protobuf | |
1615 | (("include\\(protobuf\\)") "") | |
1616 | (("protobuf_copy_headers_to_destination") "") | |
1617 | (("^ +protobuf") "") | |
1618 | ||
1619 | ;; gRPC | |
1620 | (("include\\(grpc\\)") | |
1621 | "find_package(grpc REQUIRED NAMES gRPC)") | |
1622 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "") | |
1623 | ||
1624 | ;; Eigen | |
1625 | (("include\\(eigen\\)") | |
1626 | (string-append "find_package(eigen REQUIRED NAMES Eigen3) | |
1627 | set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive " | |
1628 | (assoc-ref inputs "eigen") "/include/eigen3)")) | |
1629 | (("^ +eigen") "") | |
1630 | ||
1631 | ;; snappy | |
1632 | (("include\\(snappy\\)") | |
1633 | "add_definitions(-DTF_USE_SNAPPY)") | |
1634 | (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "") | |
1635 | ||
1636 | ;; jsoncpp | |
1637 | (("include\\(jsoncpp\\)") "") | |
1638 | (("^ +jsoncpp") "")) | |
1639 | ||
1640 | (substitute* "tf_core_framework.cmake" | |
1641 | ((" grpc") "") | |
1642 | (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin") | |
1643 | (which "grpc_cpp_plugin")) | |
1644 | ;; Link with gRPC libraries | |
1645 | (("add_library\\(tf_protos_cc.*" m) | |
1646 | (string-append m | |
1647 | (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \ | |
1648 | ~a/lib/libgrpc++_unsecure.a \ | |
1649 | ~a/lib/libgrpc_unsecure.a \ | |
1650 | ~a/lib/libaddress_sorting.a \ | |
1651 | ~a/lib/libgpr.a \ | |
1652 | ~a//lib/libcares.so | |
1653 | )\n" | |
1654 | grpc grpc grpc grpc | |
1655 | (assoc-ref inputs "c-ares")))))) | |
1656 | (substitute* "tf_tools.cmake" | |
1657 | (("add_dependencies\\(\\$\\{proto_text.*") "")) | |
1658 | ;; Remove dependency on bundled grpc | |
1659 | (substitute* "tf_core_distributed_runtime.cmake" | |
1660 | (("tf_core_cpu grpc") "tf_core_cpu")) | |
1661 | ||
1662 | ;; This directory is a dependency of many targets. | |
1663 | (mkdir-p "protobuf") | |
1664 | #t)) | |
1665 | (add-after 'configure 'unpack-third-party-sources | |
1666 | (lambda* (#:key inputs #:allow-other-keys) | |
1667 | ;; This is needed to configure bundled packages properly. | |
1668 | (setenv "CONFIG_SHELL" (which "bash")) | |
1669 | (for-each | |
1670 | (lambda (name) | |
1671 | (let* ((what (assoc-ref inputs (string-append name "-src"))) | |
1672 | (name* (string-map (lambda (c) | |
1673 | (if (char=? c #\-) | |
1674 | #\_ c)) name)) | |
1675 | (where (string-append "../build/" name* "/src/" name*))) | |
1676 | (cond | |
1677 | ((string-suffix? ".zip" what) | |
1678 | (mkdir-p where) | |
1679 | (with-directory-excursion where | |
1680 | (invoke "unzip" what))) | |
1681 | ((string-suffix? ".tar.gz" what) | |
1682 | (mkdir-p where) | |
1683 | (invoke "tar" "xf" what | |
1684 | "-C" where "--strip-components=1")) | |
1685 | (else | |
1686 | (let ((parent (dirname where))) | |
1687 | (mkdir-p parent) | |
1688 | (with-directory-excursion parent | |
1689 | (when (file-exists? name*) | |
1690 | (delete-file-recursively name*)) | |
1691 | (copy-recursively what name*) | |
1692 | (map make-file-writable | |
1693 | (find-files name* ".*")))))))) | |
1694 | (list "boringssl" | |
1695 | "cub" | |
1696 | "double-conversion" | |
1697 | "farmhash" | |
1698 | "fft2d" | |
1699 | "highwayhash" | |
1700 | "nsync" | |
1701 | "re2")) | |
1702 | ||
1703 | (rename-file "../build/cub/src/cub/cub-1.8.0/" | |
1704 | "../build/cub/src/cub/cub/") | |
1705 | #t)) | |
1706 | (add-after 'unpack 'fix-python-build | |
1707 | (lambda* (#:key inputs outputs #:allow-other-keys) | |
1708 | (mkdir-p "protobuf-src") | |
1709 | (invoke "tar" "xf" (assoc-ref inputs "protobuf:src") | |
1710 | "-C" "protobuf-src" "--strip-components=1") | |
1711 | (mkdir-p "eigen-src") | |
1712 | (invoke "tar" "xf" (assoc-ref inputs "eigen:src") | |
1713 | "-C" "eigen-src" "--strip-components=1") | |
1714 | ||
1715 | (substitute* "tensorflow/contrib/cmake/tf_python.cmake" | |
1716 | ;; Ensure that all Python dependencies can be found at build time. | |
1717 | (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m) | |
1718 | (string-append m ":" (getenv "PYTHONPATH"))) | |
1719 | ;; Take protobuf source files from our source package. | |
1720 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google") | |
1721 | (string-append (getcwd) "/protobuf-src/src/google"))) | |
1722 | ||
1723 | (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake" | |
1724 | "tensorflow/contrib/cmake/tf_python.cmake") | |
1725 | ;; Take Eigen source files from our source package. | |
1726 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/") | |
1727 | (string-append (getcwd) "/eigen-src/")) | |
1728 | ;; Take Eigen headers from our own package. | |
1729 | (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive") | |
1730 | (string-append (assoc-ref inputs "eigen") "/include/eigen3"))) | |
1731 | ||
1732 | ;; Correct the RUNPATH of ops libraries generated for Python. | |
1733 | ;; TODO: this doesn't work :( | |
1734 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1735 | ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build") | |
1736 | ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so: | |
1737 | ;; error: depends on 'libpywrap_tensorflow_internal.so', which | |
1738 | ;; cannot be found in RUNPATH ... | |
1739 | (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake" | |
1740 | (("set_target_properties.*") | |
1741 | (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \ | |
1742 | COMPILE_FLAGS ${target_compile_flags} \ | |
1743 | INSTALL_RPATH_USE_LINK_PATH TRUE \ | |
1744 | INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n"))) | |
1745 | #t)) | |
1746 | (add-after 'build 'build-pip-package | |
1747 | (lambda* (#:key outputs #:allow-other-keys) | |
1748 | (setenv "LDFLAGS" | |
1749 | (string-append "-Wl,-rpath=" | |
1750 | (assoc-ref outputs "out") "/lib")) | |
1751 | (invoke "make" "tf_python_build_pip_package") | |
1752 | #t)) | |
1753 | (add-after 'build-pip-package 'install-python | |
0b967058 | 1754 | (lambda* (#:key inputs outputs #:allow-other-keys) |
4fa16c9a | 1755 | (let ((out (assoc-ref outputs "out")) |
0b967058 EF |
1756 | (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))) |
1757 | (python-version (python-version | |
1758 | (assoc-ref inputs "python")))) | |
4fa16c9a RW |
1759 | (invoke "python" "-m" "pip" "install" wheel |
1760 | (string-append "--prefix=" out)) | |
1761 | ||
1762 | ;; XXX: broken RUNPATH, see fix-python-build phase. | |
1763 | (delete-file | |
1764 | (string-append | |
0b967058 EF |
1765 | out "/lib/python" python-version |
1766 | "/site-packages/tensorflow/contrib/" | |
4fa16c9a RW |
1767 | "seq2seq/python/ops/lib_beam_search_ops.so")) |
1768 | #t)))))) | |
1769 | (native-inputs | |
1770 | `(("pkg-config" ,pkg-config) | |
7373eb83 MB |
1771 | ("protobuf:native" ,protobuf-3.6) ; protoc |
1772 | ("protobuf:src" ,(package-source protobuf-3.6)) | |
4fa16c9a | 1773 | ("eigen:src" ,(package-source eigen-for-tensorflow)) |
0fdec2a3 MB |
1774 | ;; install_pip_packages.sh wants setuptools 39.1.0 specifically. |
1775 | ("python-setuptools" ,python-setuptools-for-tensorflow) | |
1776 | ||
4fa16c9a RW |
1777 | ;; The commit hashes and URLs for third-party source code are taken |
1778 | ;; from "tensorflow/workspace.bzl". | |
1779 | ("boringssl-src" | |
1780 | ,(let ((commit "ee7aa02") | |
1781 | (revision "1")) | |
1782 | (origin | |
1783 | (method git-fetch) | |
1784 | (uri (git-reference | |
1785 | (url "https://boringssl.googlesource.com/boringssl") | |
1786 | (commit commit))) | |
1787 | (file-name (string-append "boringssl-0-" revision | |
1788 | (string-take commit 7) | |
1789 | "-checkout")) | |
1790 | (sha256 | |
1791 | (base32 | |
1792 | "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw"))))) | |
1793 | ("cub-src" | |
1794 | ,(let ((version "1.8.0")) | |
1795 | (origin | |
1796 | (method url-fetch) | |
1797 | (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/" | |
1798 | "cub/archive/" version ".zip")) | |
1799 | (file-name (string-append "cub-" version ".zip")) | |
1800 | (sha256 | |
1801 | (base32 | |
1802 | "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb"))))) | |
1803 | ("double-conversion-src" | |
1804 | ,(let ((commit "5664746") | |
1805 | (revision "1")) | |
1806 | (origin | |
1807 | (method git-fetch) | |
1808 | (uri (git-reference | |
b0e7b699 | 1809 | (url "https://github.com/google/double-conversion") |
4fa16c9a RW |
1810 | (commit commit))) |
1811 | (file-name | |
1812 | (git-file-name "double-conversion" | |
1813 | (string-append "0-" revision "." | |
1814 | (string-take commit 7)))) | |
1815 | (sha256 | |
1816 | (base32 | |
1817 | "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1"))))) | |
1818 | ("farmhash-src" | |
1819 | ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45")) | |
1820 | (origin | |
1821 | (method url-fetch) | |
1822 | (uri (string-append | |
1823 | "https://mirror.bazel.build/github.com/google/farmhash/archive/" | |
1824 | commit ".tar.gz")) | |
1825 | (file-name (string-append "farmhash-0-" (string-take commit 7) | |
1826 | ".tar.gz")) | |
1827 | (sha256 | |
1828 | (base32 | |
1829 | "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35"))))) | |
1830 | ;; The license notice on the home page at | |
1831 | ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says: | |
1832 | ;; Copyright Takuya OOURA, 1996-2001 | |
1833 | ;; | |
1834 | ;; You may use, copy, modify and distribute this code for any purpose | |
1835 | ;; (include commercial use) and without fee. Please refer to this | |
1836 | ;; package when you modify this code. | |
1837 | ;; | |
1838 | ;; We take the identical tarball from the Bazel mirror, because the URL | |
1839 | ;; at the home page is not versioned and might change. | |
1840 | ("fft2d-src" | |
1841 | ,(origin | |
1842 | (method url-fetch) | |
1843 | (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz") | |
1844 | (file-name "fft2d.tar.gz") | |
1845 | (sha256 | |
1846 | (base32 | |
1847 | "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj")))) | |
1848 | ("highwayhash-src" | |
1849 | ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee") | |
1850 | (revision "1")) | |
1851 | (origin | |
1852 | (method git-fetch) | |
1853 | (uri (git-reference | |
b0e7b699 | 1854 | (url "https://github.com/google/highwayhash") |
4fa16c9a RW |
1855 | (commit commit))) |
1856 | (file-name (string-append "highwayhash-0-" revision | |
1857 | (string-take commit 7) | |
1858 | "-checkout")) | |
1859 | (sha256 | |
1860 | (base32 | |
1861 | "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6"))))) | |
1862 | ("nsync-src" | |
1863 | ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777") | |
1864 | (revision "1")) | |
1865 | (origin | |
1866 | (method url-fetch) | |
1867 | (uri (string-append "https://mirror.bazel.build/" | |
1868 | "github.com/google/nsync/archive/" | |
1869 | version ".tar.gz")) | |
1870 | (file-name (string-append "nsync-0." revision | |
1871 | "-" (string-take version 7) | |
1872 | ".tar.gz")) | |
1873 | (sha256 | |
1874 | (base32 | |
1875 | "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132"))))) | |
1876 | ("re2-src" | |
1877 | ,(let ((commit "e7efc48") | |
1878 | (revision "1")) | |
1879 | (origin | |
1880 | (method git-fetch) | |
1881 | (uri (git-reference | |
1882 | (url "https://github.com/google/re2") | |
1883 | (commit commit))) | |
1884 | (file-name (string-append "re2-0-" revision | |
1885 | (string-take commit 7) | |
1886 | "-checkout")) | |
1887 | (sha256 | |
1888 | (base32 | |
1889 | "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign"))))) | |
1890 | ("googletest" ,googletest) | |
1891 | ("swig" ,swig) | |
1892 | ("unzip" ,unzip))) | |
1893 | (propagated-inputs | |
1894 | `(("python-absl-py" ,python-absl-py) | |
1895 | ("python-astor" ,python-astor) | |
1896 | ("python-gast" ,python-gast) | |
1897 | ("python-grpcio" ,python-grpcio) | |
1898 | ("python-numpy" ,python-numpy) | |
7373eb83 | 1899 | ("python-protobuf" ,python-protobuf-3.6) |
4fa16c9a RW |
1900 | ("python-six" ,python-six) |
1901 | ("python-termcolo" ,python-termcolor) | |
1902 | ("python-wheel" ,python-wheel))) | |
1903 | (inputs | |
3b458d54 | 1904 | `(("c-ares" ,c-ares) |
4fa16c9a RW |
1905 | ("eigen" ,eigen-for-tensorflow) |
1906 | ("gemmlowp" ,gemmlowp-for-tensorflow) | |
1907 | ("lmdb" ,lmdb) | |
4bd428a7 | 1908 | ("libjpeg" ,libjpeg-turbo) |
4fa16c9a RW |
1909 | ("libpng" ,libpng) |
1910 | ("giflib" ,giflib) | |
80a8583a | 1911 | ("grpc" ,grpc-1.16.1 "static") |
447fafe3 | 1912 | ("grpc:bin" ,grpc-1.16.1) |
4fa16c9a RW |
1913 | ("jsoncpp" ,jsoncpp-for-tensorflow) |
1914 | ("snappy" ,snappy) | |
1915 | ("sqlite" ,sqlite) | |
7373eb83 | 1916 | ("protobuf" ,protobuf-3.6) |
4fa16c9a RW |
1917 | ("python" ,python-wrapper) |
1918 | ("zlib" ,zlib))) | |
1919 | (home-page "https://tensorflow.org") | |
1920 | (synopsis "Machine learning framework") | |
1921 | (description | |
1922 | "TensorFlow is a flexible platform for building and training machine | |
1923 | learning models. It provides a library for high performance numerical | |
1924 | computation and includes high level Python APIs, including both a sequential | |
1925 | API for beginners that allows users to build models quickly by plugging | |
1926 | together building blocks and a subclassing API with an imperative style for | |
1927 | advanced research.") | |
1928 | (license license:asl2.0))) | |
d60b064d NG |
1929 | |
1930 | (define-public python-iml | |
1931 | (package | |
1932 | (name "python-iml") | |
1933 | (version "0.6.2") | |
1934 | (source | |
1935 | (origin | |
1936 | (method url-fetch) | |
1937 | (uri (pypi-uri "iml" version)) | |
1938 | (sha256 | |
1939 | (base32 | |
1940 | "1k8szlpm19rcwcxdny9qdm3gmaqq8akb4xlvrzyz8c2d679aak6l")))) | |
1941 | (build-system python-build-system) | |
1942 | (propagated-inputs | |
7146c8c7 | 1943 | `(("ipython" ,python-ipython) |
d60b064d NG |
1944 | ("numpy" ,python-numpy) |
1945 | ("pandas" ,python-pandas) | |
1946 | ("scipy" ,python-scipy))) | |
bcbd6340 EK |
1947 | (native-inputs |
1948 | `(("nose" ,python-nose))) | |
dd003125 | 1949 | (home-page "https://github.com/interpretable-ml/iml") |
d60b064d NG |
1950 | (synopsis "Interpretable Machine Learning (iML) package") |
1951 | (description "Interpretable ML (iML) is a set of data type objects, | |
1952 | visualizations, and interfaces that can be used by any method designed to | |
1953 | explain the predictions of machine learning models (or really the output of | |
1954 | any function). It currently contains the interface and IO code from the Shap | |
1955 | project, and it will potentially also do the same for the Lime project.") | |
1956 | (license license:expat))) | |
d93ad191 RW |
1957 | |
1958 | (define-public python-keras-applications | |
1959 | (package | |
1960 | (name "python-keras-applications") | |
1961 | (version "1.0.8") | |
1962 | (source | |
1963 | (origin | |
1964 | (method url-fetch) | |
1965 | (uri (pypi-uri "Keras_Applications" version)) | |
1966 | (sha256 | |
1967 | (base32 | |
1968 | "1rcz31ca4axa6kzhjx4lwqxbg4wvlljkj8qj9a7p9sfd5fhzjyam")))) | |
1969 | (build-system python-build-system) | |
1970 | ;; The tests require Keras, but this package is needed to build Keras. | |
1971 | (arguments '(#:tests? #f)) | |
1972 | (propagated-inputs | |
1973 | `(("python-h5py" ,python-h5py) | |
1974 | ("python-numpy" ,python-numpy))) | |
1975 | (native-inputs | |
1976 | `(("python-pytest" ,python-pytest) | |
1977 | ("python-pytest-cov" ,python-pytest-cov) | |
1978 | ("python-pytest-pep8" ,python-pytest-pep8) | |
1979 | ("python-pytest-xdist" ,python-pytest-xdist))) | |
1980 | (home-page "https://github.com/keras-team/keras-applications") | |
1981 | (synopsis "Reference implementations of popular deep learning models") | |
1982 | (description | |
1983 | "This package provides reference implementations of popular deep learning | |
1984 | models for use with the Keras deep learning framework.") | |
1985 | (license license:expat))) | |
4abc5066 RW |
1986 | |
1987 | (define-public python-keras-preprocessing | |
1988 | (package | |
1989 | (name "python-keras-preprocessing") | |
1990 | (version "1.1.0") | |
1991 | (source | |
1992 | (origin | |
1993 | (method url-fetch) | |
1994 | (uri (pypi-uri "Keras_Preprocessing" version)) | |
1995 | (sha256 | |
1996 | (base32 | |
1997 | "1r98nm4k1svsqjyaqkfk23i31bl1kcfcyp7094yyj3c43phfp3as")))) | |
1998 | (build-system python-build-system) | |
1999 | (propagated-inputs | |
2000 | `(("python-numpy" ,python-numpy) | |
2001 | ("python-six" ,python-six))) | |
2002 | (native-inputs | |
2003 | `(("python-pandas" ,python-pandas) | |
2004 | ("python-pillow" ,python-pillow) | |
2005 | ("python-pytest" ,python-pytest) | |
2006 | ("python-pytest-cov" ,python-pytest-cov) | |
2007 | ("python-pytest-xdist" ,python-pytest-xdist) | |
2008 | ("tensorflow" ,tensorflow))) | |
2009 | (home-page "https://github.com/keras-team/keras-preprocessing/") | |
2010 | (synopsis "Data preprocessing and augmentation for deep learning models") | |
2011 | (description | |
2012 | "Keras Preprocessing is the data preprocessing and data augmentation | |
2013 | module of the Keras deep learning library. It provides utilities for working | |
2014 | with image data, text data, and sequence data.") | |
2015 | (license license:expat))) | |
f1765b57 RW |
2016 | |
2017 | (define-public python-keras | |
2018 | (package | |
2019 | (name "python-keras") | |
2020 | (version "2.2.4") | |
2021 | (source | |
2022 | (origin | |
2023 | (method url-fetch) | |
2024 | (uri (pypi-uri "Keras" version)) | |
b16e0827 | 2025 | (patches (search-patches "python-keras-integration-test.patch")) |
f1765b57 RW |
2026 | (sha256 |
2027 | (base32 | |
2028 | "1j8bsqzh49vjdxy6l1k4iwax5vpjzniynyd041xjavdzvfii1dlh")))) | |
2029 | (build-system python-build-system) | |
2030 | (arguments | |
2031 | `(#:phases | |
2032 | (modify-phases %standard-phases | |
2033 | (add-after 'unpack 'remove-tests-for-unavailable-features | |
2034 | (lambda _ | |
2035 | (delete-file "keras/backend/theano_backend.py") | |
2036 | (delete-file "keras/backend/cntk_backend.py") | |
2037 | (delete-file "tests/keras/backend/backend_test.py") | |
2038 | ||
2039 | ;; FIXME: This doesn't work because Tensorflow is missing the | |
2040 | ;; coder ops library. | |
2041 | (delete-file "tests/keras/test_callbacks.py") | |
2042 | #t)) | |
2043 | (replace 'check | |
2044 | (lambda _ | |
2045 | ;; These tests attempt to download data files from the internet. | |
2046 | (delete-file "tests/integration_tests/test_datasets.py") | |
2047 | (delete-file "tests/integration_tests/imagenet_utils_test.py") | |
5f37d7e3 MC |
2048 | ;; Backport https://github.com/keras-team/keras/pull/12479. |
2049 | (substitute* "tests/keras/engine/test_topology.py" | |
2050 | (("np.ones\\(\\(3, 2\\)\\)") | |
2051 | "1.")) | |
2052 | (invoke "python" "-m" "pytest" | |
2053 | ;; The following test fail only in the build container; | |
2054 | ;; skip it. | |
2055 | "-k" "not test_selu")))))) | |
f1765b57 RW |
2056 | (propagated-inputs |
2057 | `(("python-h5py" ,python-h5py) | |
2058 | ("python-keras-applications" ,python-keras-applications) | |
2059 | ("python-keras-preprocessing" ,python-keras-preprocessing) | |
2060 | ("python-numpy" ,python-numpy) | |
2061 | ("python-pydot" ,python-pydot) | |
2062 | ("python-pyyaml" ,python-pyyaml) | |
2063 | ("python-scipy" ,python-scipy) | |
2064 | ("python-six" ,python-six) | |
2065 | ("tensorflow" ,tensorflow) | |
2066 | ("graphviz" ,graphviz))) | |
2067 | (native-inputs | |
2068 | `(("python-pandas" ,python-pandas) | |
2069 | ("python-pytest" ,python-pytest) | |
2070 | ("python-pytest-cov" ,python-pytest-cov) | |
2071 | ("python-pytest-pep8" ,python-pytest-pep8) | |
2072 | ("python-pytest-timeout" ,python-pytest-timeout) | |
2073 | ("python-pytest-xdist" ,python-pytest-xdist) | |
2074 | ("python-sphinx" ,python-sphinx) | |
2075 | ("python-requests" ,python-requests))) | |
2076 | (home-page "https://github.com/keras-team/keras") | |
2077 | (synopsis "High-level deep learning framework") | |
2078 | (description "Keras is a high-level neural networks API, written in Python | |
2079 | and capable of running on top of TensorFlow. It was developed with a focus on | |
2080 | enabling fast experimentation. Use Keras if you need a deep learning library | |
2081 | that: | |
2082 | ||
2083 | @itemize | |
2084 | @item Allows for easy and fast prototyping (through user friendliness, | |
2085 | modularity, and extensibility). | |
2086 | @item Supports both convolutional networks and recurrent networks, as well as | |
2087 | combinations of the two. | |
2088 | @item Runs seamlessly on CPU and GPU. | |
2089 | @end itemize\n") | |
2090 | (license license:expat))) | |
6e760872 | 2091 | |
58b13287 GL |
2092 | (define-public gloo |
2093 | (let ((version "0.0.0") ; no proper version tag | |
2094 | (commit "ca528e32fea9ca8f2b16053cff17160290fc84ce") | |
2095 | (revision "0")) | |
2096 | (package | |
2097 | (name "gloo") | |
2098 | (version (git-version version revision commit)) | |
2099 | (source | |
2100 | (origin | |
2101 | (method git-fetch) | |
2102 | (uri (git-reference | |
b0e7b699 | 2103 | (url "https://github.com/facebookincubator/gloo") |
58b13287 GL |
2104 | (commit commit))) |
2105 | (file-name (git-file-name name version)) | |
2106 | (sha256 | |
2107 | (base32 | |
2108 | "1q9f80zy75f6njrzrqkmhc0g3qxs4gskr7ns2jdqanxa2ww7a99w")))) | |
2109 | (build-system cmake-build-system) | |
2110 | (native-inputs | |
2111 | `(("googletest" ,googletest))) | |
2112 | (arguments | |
2113 | `(#:configure-flags '("-DBUILD_TEST=1") | |
2114 | #:phases | |
2115 | (modify-phases %standard-phases | |
2116 | (replace 'check | |
2117 | (lambda _ | |
2118 | (invoke "make" "gloo_test") | |
2119 | #t))))) | |
2120 | (synopsis "Collective communications library") | |
2121 | (description | |
2122 | "Gloo is a collective communications library. It comes with a | |
2123 | number of collective algorithms useful for machine learning applications. | |
2124 | These include a barrier, broadcast, and allreduce.") | |
2125 | (home-page "https://github.com/facebookincubator/gloo") | |
2126 | (license license:bsd-3)))) | |
5e42d197 BG |
2127 | |
2128 | (define-public python-umap-learn | |
2129 | (package | |
2130 | (name "python-umap-learn") | |
2131 | (version "0.3.10") | |
2132 | (source | |
2133 | (origin | |
2134 | (method url-fetch) | |
2135 | (uri (pypi-uri "umap-learn" version)) | |
2136 | (sha256 | |
2137 | (base32 | |
2138 | "02ada2yy6km6zgk2836kg1c97yrcpalvan34p8c57446finnpki1")))) | |
2139 | (build-system python-build-system) | |
2140 | (native-inputs | |
e2ca10a4 RJ |
2141 | `(("python-joblib" ,python-joblib) |
2142 | ("python-nose" ,python-nose))) | |
5e42d197 BG |
2143 | (propagated-inputs |
2144 | `(("python-numba" ,python-numba) | |
2145 | ("python-numpy" ,python-numpy) | |
2146 | ("python-scikit-learn" ,python-scikit-learn) | |
2147 | ("python-scipy" ,python-scipy))) | |
2148 | (home-page "https://github.com/lmcinnes/umap") | |
2149 | (synopsis | |
2150 | "Uniform Manifold Approximation and Projection") | |
2151 | (description | |
2152 | "Uniform Manifold Approximation and Projection is a dimension reduction | |
2153 | technique that can be used for visualisation similarly to t-SNE, but also for | |
2154 | general non-linear dimension reduction.") | |
2155 | (license license:bsd-3))) |