Commit | Line | Data |
---|---|---|
aa5fac33 | 1 | ;;; GNU Guix --- Functional package management for GNU |
116b29bf | 2 | ;;; Copyright © 2015, 2016, 2017 Ricardo Wurmus <rekado@elephly.net> |
5f010781 | 3 | ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> |
aa5fac33 RW |
4 | ;;; |
5 | ;;; This file is part of GNU Guix. | |
6 | ;;; | |
7 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | |
8 | ;;; under the terms of the GNU General Public License as published by | |
9 | ;;; the Free Software Foundation; either version 3 of the License, or (at | |
10 | ;;; your option) any later version. | |
11 | ;;; | |
12 | ;;; GNU Guix is distributed in the hope that it will be useful, but | |
13 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ;;; GNU General Public License for more details. | |
16 | ;;; | |
17 | ;;; You should have received a copy of the GNU General Public License | |
18 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | |
19 | ||
20 | (define-module (gnu packages julia) | |
21 | #:use-module ((guix licenses) #:prefix license:) | |
22 | #:use-module (guix packages) | |
23 | #:use-module (guix download) | |
50b40d07 RW |
24 | #:use-module (guix utils) |
25 | #:use-module (guix git-download) | |
aa5fac33 RW |
26 | #:use-module (guix build-system gnu) |
27 | #:use-module (gnu packages) | |
28 | #:use-module (gnu packages algebra) | |
29 | #:use-module (gnu packages base) | |
5f010781 | 30 | #:use-module (gnu packages compression) |
aa5fac33 RW |
31 | #:use-module (gnu packages elf) |
32 | #:use-module (gnu packages gcc) | |
33 | #:use-module (gnu packages llvm) | |
50b40d07 | 34 | #:use-module (gnu packages libevent) |
aa5fac33 RW |
35 | #:use-module (gnu packages libunwind) |
36 | #:use-module (gnu packages maths) | |
37 | #:use-module (gnu packages multiprecision) ; mpfr | |
38 | #:use-module (gnu packages pcre) | |
39 | #:use-module (gnu packages perl) | |
40 | #:use-module (gnu packages pkg-config) | |
41 | #:use-module (gnu packages python) | |
42 | #:use-module (gnu packages textutils) | |
d70f5139 | 43 | #:use-module (gnu packages tls) |
de4b3828 | 44 | #:use-module (gnu packages version-control) |
c2e87caa | 45 | #:use-module (gnu packages wget) |
de4b3828 | 46 | #:use-module (ice-9 match)) |
aa5fac33 | 47 | |
50b40d07 | 48 | (define libuv-julia |
cc005f90 RW |
49 | (let ((commit "52d72a52cc7ccd570929990f010ed16e2ec604c8") |
50 | (revision "5")) | |
50b40d07 RW |
51 | (package (inherit libuv) |
52 | (name "libuv-julia") | |
d70f5139 | 53 | (version (string-append "1.9.0-" revision "." (string-take commit 8))) |
50b40d07 RW |
54 | (source (origin |
55 | (method git-fetch) | |
56 | (uri (git-reference | |
57 | (url "https://github.com/JuliaLang/libuv.git") | |
58 | (commit commit))) | |
59 | (file-name (string-append name "-" version "-checkout")) | |
60 | (sha256 | |
61 | (base32 | |
cc005f90 | 62 | "1daxh6ci6q7znxxajr3bm16dd53ragm0d681wf4kzg542qnjq3lh")))) |
50b40d07 RW |
63 | (build-system gnu-build-system) |
64 | (arguments | |
65 | (substitute-keyword-arguments (package-arguments libuv) | |
66 | ((#:phases phases) | |
67 | `(modify-phases ,phases | |
68 | (delete 'autogen))))) | |
69 | (home-page "https://github.com/JuliaLang/libuv")))) | |
70 | ||
d70f5139 RW |
71 | (define libunwind-for-julia |
72 | (package | |
73 | (inherit libunwind) | |
74 | (version "1.1-julia2") | |
75 | (source (origin | |
76 | (method url-fetch) | |
77 | (uri (string-append "https://s3.amazonaws.com/julialang/src/" | |
78 | "libunwind-" version ".tar.gz")) | |
79 | (sha256 | |
80 | (base32 | |
81 | "0499x7sg2v18a6cry6l8y713cgmic0adnjph8i0xr1db9p7n8qyv")))))) | |
82 | ||
aa5fac33 RW |
83 | (define-public julia |
84 | (package | |
85 | (name "julia") | |
cc005f90 | 86 | (version "0.6.0") |
aa5fac33 RW |
87 | (source (origin |
88 | (method url-fetch) | |
89 | (uri (string-append | |
90 | "https://github.com/JuliaLang/julia/releases/download/v" | |
4f54a63e | 91 | version "/julia-" version ".tar.gz")) |
aa5fac33 RW |
92 | (sha256 |
93 | (base32 | |
cc005f90 | 94 | "0rd6lcc9sic10q1j3c6f9qr901i1c4554m93n2sz5b3mh37byqhw")))) |
aa5fac33 RW |
95 | (build-system gnu-build-system) |
96 | (arguments | |
de4b3828 | 97 | `(#:test-target "test" |
aa5fac33 RW |
98 | #:modules ((ice-9 match) |
99 | (guix build gnu-build-system) | |
100 | (guix build utils)) | |
fb799cb7 | 101 | |
d70f5139 RW |
102 | ;; Do not strip binaries to keep support for full backtraces. |
103 | ;; See https://github.com/JuliaLang/julia/issues/17831 | |
104 | #:strip-binaries? #f | |
fb799cb7 LC |
105 | |
106 | ;; The DSOs use $ORIGIN to refer to each other, but (guix build | |
107 | ;; gremlin) doesn't support it yet, so skip this phase. | |
108 | #:validate-runpath? #f | |
109 | ||
aa5fac33 | 110 | #:phases |
6d149ec3 RW |
111 | (modify-phases %standard-phases |
112 | (delete 'configure) | |
4f54a63e RW |
113 | (add-after 'unpack 'prepare-deps |
114 | (lambda* (#:key inputs #:allow-other-keys) | |
d70f5139 | 115 | (mkdir "deps/srccache") |
4f54a63e | 116 | (copy-file (assoc-ref inputs "dsfmt") |
d70f5139 | 117 | "deps/srccache/dsfmt-2.2.3.tar.gz") |
4f54a63e | 118 | (copy-file (assoc-ref inputs "objconv") |
d70f5139 | 119 | "deps/srccache/objconv.zip") |
4f54a63e | 120 | (copy-file (assoc-ref inputs "suitesparse") |
d70f5139 RW |
121 | "deps/srccache/SuiteSparse-4.4.5.tar.gz") |
122 | (copy-file (string-append (assoc-ref inputs "virtualenv") | |
123 | "/bin/virtualenv") | |
124 | "julia-env") | |
cc005f90 RW |
125 | (copy-file (assoc-ref inputs "unicode-data") |
126 | "doc/UnicodeData.txt") | |
d70f5139 | 127 | #t)) |
cc005f90 RW |
128 | ;; FIXME: Building the documentation requires Julia packages that |
129 | ;; would be downloaded from the Internet. We should build them in a | |
130 | ;; separate build phase. | |
131 | (add-after 'unpack 'disable-documentation | |
d70f5139 | 132 | (lambda _ |
cc005f90 RW |
133 | (substitute* "Makefile" |
134 | (("(install: .*) \\$\\(BUILDROOT\\)/doc/_build/html/en/index.html" _ line) | |
135 | (string-append line "\n")) | |
136 | (("src ui doc deps") | |
137 | "src ui deps")) | |
4f54a63e | 138 | #t)) |
d70f5139 RW |
139 | (add-before 'check 'set-home |
140 | ;; Some tests require a home directory to be set. | |
141 | (lambda _ (setenv "HOME" "/tmp") #t)) | |
c2e87caa | 142 | (add-after 'unpack 'hardcode-soname-map |
d70f5139 RW |
143 | ;; ./src/runtime_ccall.cpp creates a map from library names to paths |
144 | ;; using the output of "/sbin/ldconfig -p". Since ldconfig is not | |
145 | ;; used in Guix, we patch runtime_ccall.cpp to contain a static map. | |
6d149ec3 RW |
146 | (lambda* (#:key inputs #:allow-other-keys) |
147 | (use-modules (ice-9 match)) | |
d70f5139 | 148 | (substitute* "src/runtime_ccall.cpp" |
9805ad6f LC |
149 | ;; Patch out invocations of '/sbin/ldconfig' to avoid getting |
150 | ;; error messages about missing '/sbin/ldconfig' on GuixSD. | |
151 | (("popen\\(.*ldconfig.*\\);") | |
152 | "NULL;\n") | |
153 | ||
154 | ;; Populate 'sonameMap'. | |
6d149ec3 RW |
155 | (("jl_read_sonames.*;") |
156 | (string-join | |
157 | (map (match-lambda | |
158 | ((input libname soname) | |
159 | (string-append | |
160 | "sonameMap[\"" libname "\"] = " | |
161 | "\"" (assoc-ref inputs input) "/lib/" soname "\";"))) | |
162 | '(("libc" "libc" "libc.so.6") | |
c2e87caa | 163 | ("pcre2" "libpcre2-8" "libpcre2-8.so") |
6d149ec3 RW |
164 | ("mpfr" "libmpfr" "libmpfr.so") |
165 | ("openblas" "libblas" "libopenblas.so") | |
166 | ("arpack-ng" "libarpack" "libarpack.so") | |
167 | ("lapack" "liblapack" "liblapack.so") | |
c2e87caa | 168 | ("libgit2" "libgit2" "libgit2.so") |
6d149ec3 RW |
169 | ("gmp" "libgmp" "libgmp.so") |
170 | ("openlibm" "libopenlibm" "libopenlibm.so") | |
171 | ("openspecfun" "libopenspecfun" "libopenspecfun.so") | |
cc005f90 RW |
172 | ("fftw" "libfftw3" "libfftw3_threads.so") |
173 | ("fftwf" "libfftw3f" "libfftw3f_threads.so")))))) | |
d70f5139 RW |
174 | (substitute* "base/fft/FFTW.jl" |
175 | (("const libfftw = Base.libfftw_name") | |
176 | (string-append "const libfftw = \"" | |
cc005f90 | 177 | (assoc-ref inputs "fftw") "/lib/libfftw3_threads.so" |
d70f5139 RW |
178 | "\"")) |
179 | (("const libfftwf = Base.libfftwf_name") | |
180 | (string-append "const libfftwf = \"" | |
cc005f90 | 181 | (assoc-ref inputs "fftwf") "/lib/libfftw3f_threads.so" |
d70f5139 RW |
182 | "\""))) |
183 | (substitute* "base/math.jl" | |
184 | (("const libm = Base.libm_name") | |
185 | (string-append "const libm = \"" | |
186 | (assoc-ref inputs "openlibm") | |
187 | "/lib/libopenlibm.so" | |
188 | "\"")) | |
189 | (("const openspecfun = \"libopenspecfun\"") | |
190 | (string-append "const openspecfun = \"" | |
191 | (assoc-ref inputs "openspecfun") | |
192 | "/lib/libopenspecfun.so" | |
193 | "\""))) | |
194 | (substitute* "base/pcre.jl" | |
195 | (("const PCRE_LIB = \"libpcre2-8\"") | |
196 | (string-append "const PCRE_LIB = \"" | |
197 | (assoc-ref inputs "pcre2") | |
198 | "/lib/libpcre2-8.so" "\""))) | |
6d149ec3 | 199 | #t)) |
c2e87caa RW |
200 | (add-before 'build 'fix-include-and-link-paths |
201 | (lambda* (#:key inputs #:allow-other-keys) | |
202 | ;; LIBUTF8PROC is a linker flag, not a build target. It is | |
203 | ;; included in the LIBFILES_* variable which is used as a | |
204 | ;; collection of build targets and a list of libraries to link | |
205 | ;; against. | |
206 | (substitute* "src/flisp/Makefile" | |
207 | (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\): \\$\\(OBJS\\) \\$\\(LIBFILES_release\\)") | |
208 | "$(BUILDDIR)/$(EXENAME): $(OBJS) $(LLT_release)") | |
209 | (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\)-debug: \\$\\(DOBJS\\) \\$\\(LIBFILES_debug\\)") | |
210 | "$(BUILDDIR)/$(EXENAME)-debug: $(DOBJS) $(LLT_debug)")) | |
211 | ||
212 | ;; The REPL must be linked with libuv. | |
213 | (substitute* "ui/Makefile" | |
214 | (("JLDFLAGS \\+= ") | |
215 | (string-append "JLDFLAGS += " | |
216 | (assoc-ref %build-inputs "libuv") | |
217 | "/lib/libuv.so "))) | |
218 | ||
c2e87caa RW |
219 | (substitute* "base/Makefile" |
220 | (("\\$\\(build_includedir\\)/uv-errno.h") | |
221 | (string-append (assoc-ref inputs "libuv") | |
222 | "/include/uv-errno.h"))) | |
6d149ec3 | 223 | #t)) |
c2e87caa | 224 | (add-before 'build 'replace-default-shell |
6d149ec3 RW |
225 | (lambda _ |
226 | (substitute* "base/client.jl" | |
227 | (("/bin/sh") (which "sh"))) | |
228 | #t)) | |
c2e87caa RW |
229 | (add-after 'unpack 'hardcode-paths |
230 | (lambda _ | |
231 | (substitute* "base/interactiveutil.jl" | |
232 | (("`which") (string-append "`" (which "which"))) | |
233 | (("`wget") (string-append "`" (which "wget")))) | |
234 | #t)) | |
235 | (add-before 'check 'disable-broken-tests | |
236 | (lambda _ | |
d40b5684 LC |
237 | ;; Adjust expected error messages to match what current libgit2 |
238 | ;; provides. | |
239 | (substitute* "test/libgit2.jl" | |
240 | (("Invalid Content-Type") "invalid Content-Type") | |
241 | (("Failed to resolve path") "failed to resolve path")) | |
242 | ||
c2e87caa | 243 | (substitute* "test/choosetests.jl" |
d70f5139 RW |
244 | ;; These tests fail, probably because some of the input |
245 | ;; binaries have been stripped and thus backtraces don't look | |
246 | ;; as expected. | |
247 | (("\"backtrace\",") "") | |
248 | (("\"compile\",") "") | |
249 | (("\"replutil\",") "") | |
cc005f90 RW |
250 | (("\"cmdlineargs\",") "") |
251 | ;; FIXME: This test fails with the following error: | |
252 | ;; Error in testset file: | |
253 | ;; Test Failed | |
254 | ;; Expression: download("ba\0d", "good") | |
255 | ;; Expected: ArgumentError | |
256 | ;; Thrown: Base.UVError | |
257 | (("\"file\",") "")) | |
c2e87caa | 258 | #t))) |
aa5fac33 RW |
259 | #:make-flags |
260 | (list | |
261 | (string-append "prefix=" (assoc-ref %outputs "out")) | |
de4b3828 RW |
262 | |
263 | ;; Passing the MARCH flag is necessary to build binary substitutes for | |
264 | ;; the supported architectures. | |
265 | ,(match (or (%current-target-system) | |
266 | (%current-system)) | |
267 | ("x86_64-linux" "MARCH=x86-64") | |
446c7e4d | 268 | ("i686-linux" "MARCH=pentium4") |
298fd38b | 269 | ("aarch64-linux" "MARCH=armv8-a") |
446c7e4d MW |
270 | ;; Prevent errors when querying this package on unsupported |
271 | ;; platforms, e.g. when running "guix package --search=" | |
272 | (_ "MARCH=UNSUPPORTED")) | |
de4b3828 | 273 | |
aa5fac33 | 274 | "CONFIG_SHELL=bash" ;needed to build bundled libraries |
aa5fac33 RW |
275 | "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no |
276 | ;build system for a shared library. | |
aa5fac33 RW |
277 | "USE_SYSTEM_LAPACK=1" |
278 | "USE_SYSTEM_BLAS=1" | |
279 | "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1 | |
280 | ||
281 | "USE_SYSTEM_FFTW=1" | |
282 | "LIBFFTWNAME=libfftw3" | |
283 | "LIBFFTWFNAME=libfftw3f" | |
284 | ||
285 | ;; TODO: Suitesparse does not install shared libraries, so we cannot | |
286 | ;; use the suitesparse package. | |
287 | ;; "USE_SYSTEM_SUITESPARSE=1" | |
288 | ;; (string-append "SUITESPARSE_INC=-I " | |
289 | ;; (assoc-ref %build-inputs "suitesparse") | |
290 | ;; "/include") | |
291 | ||
c2e87caa | 292 | "USE_GPL_LIBS=1" ;proudly |
aa5fac33 | 293 | "USE_SYSTEM_UTF8PROC=1" |
c2e87caa RW |
294 | (string-append "UTF8PROC_INC=" |
295 | (assoc-ref %build-inputs "utf8proc") | |
296 | "/include") | |
aa5fac33 | 297 | "USE_SYSTEM_LLVM=1" |
cc005f90 RW |
298 | "USE_LLVM_SHLIB=0" ; FIXME: fails when set to 1 |
299 | ||
aa5fac33 | 300 | "USE_SYSTEM_LIBUNWIND=1" |
c2e87caa RW |
301 | "USE_SYSTEM_LIBUV=1" |
302 | (string-append "LIBUV=" | |
303 | (assoc-ref %build-inputs "libuv") | |
304 | "/lib/libuv.so") | |
305 | (string-append "LIBUV_INC=" | |
306 | (assoc-ref %build-inputs "libuv") | |
307 | "/include") | |
308 | "USE_SYSTEM_PATCHELF=1" | |
aa5fac33 RW |
309 | "USE_SYSTEM_PCRE=1" |
310 | "USE_SYSTEM_OPENLIBM=1" | |
311 | "USE_SYSTEM_GMP=1" | |
312 | "USE_SYSTEM_MPFR=1" | |
313 | "USE_SYSTEM_ARPACK=1" | |
314 | "USE_SYSTEM_LIBGIT2=1" | |
315 | "USE_SYSTEM_OPENSPECFUN=1"))) | |
316 | (inputs | |
d4c06f32 | 317 | `(("llvm" ,llvm-3.9.1) |
c0edb5b5 LC |
318 | |
319 | ;; The bundled version is 3.3.0 so stick to that version. With other | |
320 | ;; versions, we get test failures in 'linalg/arnoldi' as described in | |
321 | ;; <https://bugs.gnu.org/30282>. | |
322 | ("arpack-ng" ,arpack-ng-3.3.0) | |
323 | ||
c2e87caa | 324 | ("coreutils" ,coreutils) ;for bindings to "mkdir" and the like |
aa5fac33 RW |
325 | ("lapack" ,lapack) |
326 | ("openblas" ,openblas) ;Julia does not build with Atlas | |
d70f5139 | 327 | ("libunwind" ,libunwind-for-julia) |
aa5fac33 RW |
328 | ("openlibm" ,openlibm) |
329 | ("openspecfun" ,openspecfun) | |
c2e87caa | 330 | ("libgit2" ,libgit2) |
aa5fac33 RW |
331 | ("fftw" ,fftw) |
332 | ("fftwf" ,fftwf) | |
19afbea1 | 333 | ("fortran" ,gfortran) |
c2e87caa RW |
334 | ("libuv" ,libuv-julia) |
335 | ("pcre2" ,pcre2) | |
aa5fac33 | 336 | ("utf8proc" ,utf8proc) |
aa5fac33 | 337 | ("mpfr" ,mpfr) |
c2e87caa RW |
338 | ("wget" ,wget) |
339 | ("which" ,which) | |
5f010781 | 340 | ("zlib" ,zlib) |
4f54a63e | 341 | ("gmp" ,gmp) |
d70f5139 | 342 | ("virtualenv" ,python2-virtualenv) |
4f54a63e RW |
343 | ;; FIXME: The following inputs are downloaded from upstream to allow us |
344 | ;; to use the lightweight Julia release tarball. Ideally, these inputs | |
345 | ;; would eventually be replaced with proper Guix packages. | |
d70f5139 RW |
346 | |
347 | ;; TODO: run "make -f contrib/repackage_system_suitesparse4.make" to copy static lib | |
4f54a63e RW |
348 | ("suitesparse" |
349 | ,(origin | |
350 | (method url-fetch) | |
d70f5139 | 351 | (uri "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.4.5.tar.gz") |
4f54a63e RW |
352 | (sha256 |
353 | (base32 | |
d70f5139 | 354 | "1jcbxb8jx5wlcixzf6n5dca2rcfx6mlcms1k2rl5gp67ay3bix43")))) |
4f54a63e RW |
355 | ("objconv" |
356 | ,(origin | |
357 | (method url-fetch) | |
81bf0fd0 MB |
358 | ;; No versioned URL, see <https://www.agner.org/optimize/> for updates. |
359 | (uri "https://www.agner.org/optimize/objconv.zip") | |
360 | (file-name "objconv-2018-08-15.zip") | |
4f54a63e RW |
361 | (sha256 |
362 | (base32 | |
81bf0fd0 | 363 | "09y4pwxfs6fl47cyingbf95i2rxx74wmycl9fd4ldcgvpx9bzdrx")))) |
4f54a63e RW |
364 | ("dsfmt" |
365 | ,(origin | |
366 | (method url-fetch) | |
367 | (uri (string-append | |
368 | "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/" | |
369 | "SFMT/dSFMT-src-2.2.3.tar.gz")) | |
370 | (sha256 | |
371 | (base32 | |
d70f5139 | 372 | "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42")))))) |
aa5fac33 | 373 | (native-inputs |
d70f5139 RW |
374 | `(("openssl" ,openssl) |
375 | ("perl" ,perl) | |
aa5fac33 RW |
376 | ("patchelf" ,patchelf) |
377 | ("pkg-config" ,pkg-config) | |
cc005f90 RW |
378 | ("python" ,python-2) |
379 | ("unicode-data" | |
380 | ,(origin | |
381 | (method url-fetch) | |
382 | (uri "http://www.unicode.org/Public/9.0.0/ucd/UnicodeData.txt") | |
383 | (sha256 | |
384 | (base32 | |
385 | "13zfannnr6sa6s27ggvcvzmh133ndi38pfyxsssvjmw2s8ac9pv8")))))) | |
9e54e957 RW |
386 | ;; Julia is not officially released for ARM and MIPS. |
387 | ;; See https://github.com/JuliaLang/julia/issues/10639 | |
298fd38b | 388 | (supported-systems '("i686-linux" "x86_64-linux" "aarch64-linux")) |
4f447d2f | 389 | (home-page "https://julialang.org/") |
aa5fac33 RW |
390 | (synopsis "High-performance dynamic language for technical computing") |
391 | (description | |
392 | "Julia is a high-level, high-performance dynamic programming language for | |
393 | technical computing, with syntax that is familiar to users of other technical | |
394 | computing environments. It provides a sophisticated compiler, distributed | |
395 | parallel execution, numerical accuracy, and an extensive mathematical function | |
396 | library.") | |
397 | (license license:expat))) |