Commit | Line | Data |
---|---|---|
aa5fac33 | 1 | ;;; GNU Guix --- Functional package management for GNU |
e5a19fed | 2 | ;;; Copyright © 2015, 2016 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 |
d70f5139 RW |
49 | (let ((commit "8d5131b6c1595920dd30644cd1435b4f344b46c8") |
50 | (revision "4")) | |
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 | |
d70f5139 | 62 | "1fq0vhiprdryw8iisxxwyld3xdr5za6y8458p22ff56al98h22fv")))) |
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") | |
d70f5139 | 86 | (version "0.5.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 | |
d70f5139 | 94 | "0bhickil88lalp9jdj1kmf4is70zinhx8ha9rng0g3z50r4a2qmv")))) |
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") | |
125 | #t)) | |
126 | (add-after 'unpack 'fix-llvm-flag | |
127 | (lambda _ | |
128 | (substitute* "src/Makefile" | |
129 | (("-lLLVM-\\$\\(shell \\$\\(LLVM_CONFIG_HOST\\) --version\\)") | |
130 | "$(shell $(LLVM_CONFIG_HOST) --libs)")) | |
4f54a63e | 131 | #t)) |
d70f5139 RW |
132 | (add-before 'check 'set-home |
133 | ;; Some tests require a home directory to be set. | |
134 | (lambda _ (setenv "HOME" "/tmp") #t)) | |
c2e87caa | 135 | (add-after 'unpack 'hardcode-soname-map |
d70f5139 RW |
136 | ;; ./src/runtime_ccall.cpp creates a map from library names to paths |
137 | ;; using the output of "/sbin/ldconfig -p". Since ldconfig is not | |
138 | ;; used in Guix, we patch runtime_ccall.cpp to contain a static map. | |
6d149ec3 RW |
139 | (lambda* (#:key inputs #:allow-other-keys) |
140 | (use-modules (ice-9 match)) | |
d70f5139 | 141 | (substitute* "src/runtime_ccall.cpp" |
6d149ec3 RW |
142 | (("jl_read_sonames.*;") |
143 | (string-join | |
144 | (map (match-lambda | |
145 | ((input libname soname) | |
146 | (string-append | |
147 | "sonameMap[\"" libname "\"] = " | |
148 | "\"" (assoc-ref inputs input) "/lib/" soname "\";"))) | |
149 | '(("libc" "libc" "libc.so.6") | |
c2e87caa | 150 | ("pcre2" "libpcre2-8" "libpcre2-8.so") |
6d149ec3 RW |
151 | ("mpfr" "libmpfr" "libmpfr.so") |
152 | ("openblas" "libblas" "libopenblas.so") | |
153 | ("arpack-ng" "libarpack" "libarpack.so") | |
154 | ("lapack" "liblapack" "liblapack.so") | |
c2e87caa | 155 | ("libgit2" "libgit2" "libgit2.so") |
6d149ec3 RW |
156 | ("gmp" "libgmp" "libgmp.so") |
157 | ("openlibm" "libopenlibm" "libopenlibm.so") | |
158 | ("openspecfun" "libopenspecfun" "libopenspecfun.so") | |
159 | ("fftw" "libfftw3" "libfftw3.so") | |
160 | ("fftwf" "libfftw3f" "libfftw3f.so")))))) | |
d70f5139 RW |
161 | (substitute* "base/fft/FFTW.jl" |
162 | (("const libfftw = Base.libfftw_name") | |
163 | (string-append "const libfftw = \"" | |
164 | (assoc-ref inputs "fftw") "/lib/libfftw3.so" | |
165 | "\"")) | |
166 | (("const libfftwf = Base.libfftwf_name") | |
167 | (string-append "const libfftwf = \"" | |
168 | (assoc-ref inputs "fftwf") "/lib/libfftw3f.so" | |
169 | "\""))) | |
170 | (substitute* "base/math.jl" | |
171 | (("const libm = Base.libm_name") | |
172 | (string-append "const libm = \"" | |
173 | (assoc-ref inputs "openlibm") | |
174 | "/lib/libopenlibm.so" | |
175 | "\"")) | |
176 | (("const openspecfun = \"libopenspecfun\"") | |
177 | (string-append "const openspecfun = \"" | |
178 | (assoc-ref inputs "openspecfun") | |
179 | "/lib/libopenspecfun.so" | |
180 | "\""))) | |
181 | (substitute* "base/pcre.jl" | |
182 | (("const PCRE_LIB = \"libpcre2-8\"") | |
183 | (string-append "const PCRE_LIB = \"" | |
184 | (assoc-ref inputs "pcre2") | |
185 | "/lib/libpcre2-8.so" "\""))) | |
6d149ec3 | 186 | #t)) |
c2e87caa RW |
187 | (add-before 'build 'fix-include-and-link-paths |
188 | (lambda* (#:key inputs #:allow-other-keys) | |
189 | ;; LIBUTF8PROC is a linker flag, not a build target. It is | |
190 | ;; included in the LIBFILES_* variable which is used as a | |
191 | ;; collection of build targets and a list of libraries to link | |
192 | ;; against. | |
193 | (substitute* "src/flisp/Makefile" | |
194 | (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\): \\$\\(OBJS\\) \\$\\(LIBFILES_release\\)") | |
195 | "$(BUILDDIR)/$(EXENAME): $(OBJS) $(LLT_release)") | |
196 | (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\)-debug: \\$\\(DOBJS\\) \\$\\(LIBFILES_debug\\)") | |
197 | "$(BUILDDIR)/$(EXENAME)-debug: $(DOBJS) $(LLT_debug)")) | |
198 | ||
199 | ;; The REPL must be linked with libuv. | |
200 | (substitute* "ui/Makefile" | |
201 | (("JLDFLAGS \\+= ") | |
202 | (string-append "JLDFLAGS += " | |
203 | (assoc-ref %build-inputs "libuv") | |
204 | "/lib/libuv.so "))) | |
205 | ||
c2e87caa RW |
206 | (substitute* "base/Makefile" |
207 | (("\\$\\(build_includedir\\)/uv-errno.h") | |
208 | (string-append (assoc-ref inputs "libuv") | |
209 | "/include/uv-errno.h"))) | |
6d149ec3 | 210 | #t)) |
c2e87caa | 211 | (add-before 'build 'replace-default-shell |
6d149ec3 RW |
212 | (lambda _ |
213 | (substitute* "base/client.jl" | |
214 | (("/bin/sh") (which "sh"))) | |
215 | #t)) | |
c2e87caa RW |
216 | (add-after 'unpack 'hardcode-paths |
217 | (lambda _ | |
218 | (substitute* "base/interactiveutil.jl" | |
219 | (("`which") (string-append "`" (which "which"))) | |
220 | (("`wget") (string-append "`" (which "wget")))) | |
221 | #t)) | |
222 | (add-before 'check 'disable-broken-tests | |
223 | (lambda _ | |
224 | (substitute* "test/choosetests.jl" | |
d70f5139 RW |
225 | ;; These tests fail, probably because some of the input |
226 | ;; binaries have been stripped and thus backtraces don't look | |
227 | ;; as expected. | |
228 | (("\"backtrace\",") "") | |
229 | (("\"compile\",") "") | |
230 | (("\"replutil\",") "") | |
231 | (("\"cmdlineargs\",") "")) | |
c2e87caa | 232 | #t))) |
aa5fac33 RW |
233 | #:make-flags |
234 | (list | |
235 | (string-append "prefix=" (assoc-ref %outputs "out")) | |
de4b3828 RW |
236 | |
237 | ;; Passing the MARCH flag is necessary to build binary substitutes for | |
238 | ;; the supported architectures. | |
239 | ,(match (or (%current-target-system) | |
240 | (%current-system)) | |
241 | ("x86_64-linux" "MARCH=x86-64") | |
446c7e4d MW |
242 | ("i686-linux" "MARCH=pentium4") |
243 | ;; Prevent errors when querying this package on unsupported | |
244 | ;; platforms, e.g. when running "guix package --search=" | |
245 | (_ "MARCH=UNSUPPORTED")) | |
de4b3828 | 246 | |
aa5fac33 | 247 | "CONFIG_SHELL=bash" ;needed to build bundled libraries |
aa5fac33 RW |
248 | "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no |
249 | ;build system for a shared library. | |
aa5fac33 RW |
250 | "USE_SYSTEM_LAPACK=1" |
251 | "USE_SYSTEM_BLAS=1" | |
252 | "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1 | |
253 | ||
254 | "USE_SYSTEM_FFTW=1" | |
255 | "LIBFFTWNAME=libfftw3" | |
256 | "LIBFFTWFNAME=libfftw3f" | |
257 | ||
258 | ;; TODO: Suitesparse does not install shared libraries, so we cannot | |
259 | ;; use the suitesparse package. | |
260 | ;; "USE_SYSTEM_SUITESPARSE=1" | |
261 | ;; (string-append "SUITESPARSE_INC=-I " | |
262 | ;; (assoc-ref %build-inputs "suitesparse") | |
263 | ;; "/include") | |
264 | ||
c2e87caa | 265 | "USE_GPL_LIBS=1" ;proudly |
aa5fac33 | 266 | "USE_SYSTEM_UTF8PROC=1" |
c2e87caa RW |
267 | (string-append "UTF8PROC_INC=" |
268 | (assoc-ref %build-inputs "utf8proc") | |
269 | "/include") | |
aa5fac33 RW |
270 | "USE_SYSTEM_LLVM=1" |
271 | "USE_SYSTEM_LIBUNWIND=1" | |
c2e87caa RW |
272 | "USE_SYSTEM_LIBUV=1" |
273 | (string-append "LIBUV=" | |
274 | (assoc-ref %build-inputs "libuv") | |
275 | "/lib/libuv.so") | |
276 | (string-append "LIBUV_INC=" | |
277 | (assoc-ref %build-inputs "libuv") | |
278 | "/include") | |
279 | "USE_SYSTEM_PATCHELF=1" | |
aa5fac33 RW |
280 | "USE_SYSTEM_PCRE=1" |
281 | "USE_SYSTEM_OPENLIBM=1" | |
282 | "USE_SYSTEM_GMP=1" | |
283 | "USE_SYSTEM_MPFR=1" | |
284 | "USE_SYSTEM_ARPACK=1" | |
285 | "USE_SYSTEM_LIBGIT2=1" | |
286 | "USE_SYSTEM_OPENSPECFUN=1"))) | |
287 | (inputs | |
d70f5139 | 288 | `(("llvm" ,llvm) |
aa5fac33 | 289 | ("arpack-ng" ,arpack-ng) |
c2e87caa | 290 | ("coreutils" ,coreutils) ;for bindings to "mkdir" and the like |
aa5fac33 RW |
291 | ("lapack" ,lapack) |
292 | ("openblas" ,openblas) ;Julia does not build with Atlas | |
d70f5139 | 293 | ("libunwind" ,libunwind-for-julia) |
aa5fac33 RW |
294 | ("openlibm" ,openlibm) |
295 | ("openspecfun" ,openspecfun) | |
c2e87caa | 296 | ("libgit2" ,libgit2) |
aa5fac33 RW |
297 | ("fftw" ,fftw) |
298 | ("fftwf" ,fftwf) | |
19afbea1 | 299 | ("fortran" ,gfortran) |
c2e87caa RW |
300 | ("libuv" ,libuv-julia) |
301 | ("pcre2" ,pcre2) | |
aa5fac33 | 302 | ("utf8proc" ,utf8proc) |
aa5fac33 | 303 | ("mpfr" ,mpfr) |
c2e87caa RW |
304 | ("wget" ,wget) |
305 | ("which" ,which) | |
5f010781 | 306 | ("zlib" ,zlib) |
4f54a63e | 307 | ("gmp" ,gmp) |
d70f5139 | 308 | ("virtualenv" ,python2-virtualenv) |
4f54a63e RW |
309 | ;; FIXME: The following inputs are downloaded from upstream to allow us |
310 | ;; to use the lightweight Julia release tarball. Ideally, these inputs | |
311 | ;; would eventually be replaced with proper Guix packages. | |
d70f5139 RW |
312 | |
313 | ;; TODO: run "make -f contrib/repackage_system_suitesparse4.make" to copy static lib | |
4f54a63e RW |
314 | ("suitesparse" |
315 | ,(origin | |
316 | (method url-fetch) | |
d70f5139 | 317 | (uri "http://faculty.cse.tamu.edu/davis/SuiteSparse/SuiteSparse-4.4.5.tar.gz") |
4f54a63e RW |
318 | (sha256 |
319 | (base32 | |
d70f5139 | 320 | "1jcbxb8jx5wlcixzf6n5dca2rcfx6mlcms1k2rl5gp67ay3bix43")))) |
4f54a63e RW |
321 | ("objconv" |
322 | ,(origin | |
323 | (method url-fetch) | |
324 | (uri "http://www.agner.org/optimize/objconv.zip") | |
325 | (sha256 | |
326 | (base32 | |
327 | "1fi7qa2sd9vb35dvkgripjf0fayzg2qmff215f8agfqfiwd1g8qs")))) | |
328 | ("dsfmt" | |
329 | ,(origin | |
330 | (method url-fetch) | |
331 | (uri (string-append | |
332 | "http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/" | |
333 | "SFMT/dSFMT-src-2.2.3.tar.gz")) | |
334 | (sha256 | |
335 | (base32 | |
d70f5139 | 336 | "03kaqbjbi6viz0n33dk5jlf6ayxqlsq4804n7kwkndiga9s4hd42")))))) |
aa5fac33 | 337 | (native-inputs |
d70f5139 RW |
338 | `(("openssl" ,openssl) |
339 | ("perl" ,perl) | |
aa5fac33 RW |
340 | ("patchelf" ,patchelf) |
341 | ("pkg-config" ,pkg-config) | |
c2e87caa | 342 | ("python" ,python-2))) |
9e54e957 RW |
343 | ;; Julia is not officially released for ARM and MIPS. |
344 | ;; See https://github.com/JuliaLang/julia/issues/10639 | |
345 | (supported-systems '("i686-linux" "x86_64-linux")) | |
aa5fac33 RW |
346 | (home-page "http://julialang.org/") |
347 | (synopsis "High-performance dynamic language for technical computing") | |
348 | (description | |
349 | "Julia is a high-level, high-performance dynamic programming language for | |
350 | technical computing, with syntax that is familiar to users of other technical | |
351 | computing environments. It provides a sophisticated compiler, distributed | |
352 | parallel execution, numerical accuracy, and an extensive mathematical function | |
353 | library.") | |
354 | (license license:expat))) |