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