gnu: upower: Enable GObject introspection.
[jackhill/guix/guix.git] / gnu / packages / julia.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;;
4 ;;; This file is part of GNU Guix.
5 ;;;
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
10 ;;;
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
15 ;;;
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19 (define-module (gnu packages julia)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix build-system gnu)
24 #:use-module (gnu packages)
25 #:use-module (gnu packages algebra)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages elf)
28 #:use-module (gnu packages gcc)
29 #:use-module (gnu packages llvm)
30 #:use-module (gnu packages libunwind)
31 #:use-module (gnu packages maths)
32 #:use-module (gnu packages multiprecision) ; mpfr
33 #:use-module (gnu packages pcre)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages pkg-config)
36 #:use-module (gnu packages python)
37 #:use-module (gnu packages textutils)
38 #:use-module (gnu packages version-control)
39 #:use-module (ice-9 match))
40
41 (define-public julia
42 (package
43 (name "julia")
44 (version "0.3.10")
45 (source (origin
46 (method url-fetch)
47 (uri (string-append
48 "https://github.com/JuliaLang/julia/releases/download/v"
49 version "/julia-" version "_c8ceeefcc1.tar.gz"))
50 (sha256
51 (base32
52 "0j6mw6wr35lxid10nh9gz7k6wck3a90ic92w99n1r052325gl9r7"))
53 (patches (list (search-patch "julia-0.3.10-fix-empty-array.patch")))))
54 (build-system gnu-build-system)
55 (arguments
56 `(#:test-target "test"
57 #:modules ((ice-9 match)
58 (guix build gnu-build-system)
59 (guix build utils))
60
61
62 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
63 ;; gremlin) doesn't support it yet, so skip this phase.
64 #:validate-runpath? #f
65
66 #:phases
67 (modify-phases %standard-phases
68 (delete 'configure)
69 (add-after
70 'unpack 'hardcode-soname-map
71 ;; ./src/ccall.cpp creates a map from library names to paths using the
72 ;; output of "/sbin/ldconfig -p". Since ldconfig is not used in Guix,
73 ;; we patch ccall.cpp to contain a static map.
74 (lambda* (#:key inputs #:allow-other-keys)
75 (use-modules (ice-9 match))
76 (substitute* "src/ccall.cpp"
77 (("jl_read_sonames.*;")
78 (string-join
79 (map (match-lambda
80 ((input libname soname)
81 (string-append
82 "sonameMap[\"" libname "\"] = "
83 "\"" (assoc-ref inputs input) "/lib/" soname "\";")))
84 '(("libc" "libc" "libc.so.6")
85 ("pcre" "libpcre" "libpcre.so")
86 ("mpfr" "libmpfr" "libmpfr.so")
87 ("openblas" "libblas" "libopenblas.so")
88 ("arpack-ng" "libarpack" "libarpack.so")
89 ("lapack" "liblapack" "liblapack.so")
90 ("gmp" "libgmp" "libgmp.so")
91 ("openlibm" "libopenlibm" "libopenlibm.so")
92 ("openspecfun" "libopenspecfun" "libopenspecfun.so")
93 ("fftw" "libfftw3" "libfftw3.so")
94 ("fftwf" "libfftw3f" "libfftw3f.so"))))))
95 #t))
96 ;; This phase will no longer be necessary in 0.3.11; see
97 ;; https://github.com/JuliaLang/julia/issues/12028
98 (add-before
99 'build 'fix-building-with-mcjit-llvm
100 (lambda _
101 (substitute* "src/cgutils.cpp"
102 (("addComdat\\(gv\\);") ""))
103 #t))
104 (add-before
105 'build 'patch-include-path
106 (lambda _
107 (substitute* "deps/Makefile"
108 (("/usr/include/double-conversion")
109 (string-append (assoc-ref %build-inputs "double-conversion")
110 "/include/double-conversion")))
111 #t))
112 (add-before
113 'build 'replace-default-shell
114 (lambda _
115 (substitute* "base/client.jl"
116 (("/bin/sh") (which "sh")))
117 #t))
118 (add-before
119 'check 'disable-broken-test
120 ;; One test fails because it produces slightly different output.
121 (lambda _
122 (substitute* "test/repl.jl"
123 (("@test output") "# @test output"))
124 #t)))
125 #:make-flags
126 (list
127 (string-append "prefix=" (assoc-ref %outputs "out"))
128
129 ;; Passing the MARCH flag is necessary to build binary substitutes for
130 ;; the supported architectures.
131 ,(match (or (%current-target-system)
132 (%current-system))
133 ("x86_64-linux" "MARCH=x86-64")
134 ("i686-linux" "MARCH=pentium4")
135 ;; Prevent errors when querying this package on unsupported
136 ;; platforms, e.g. when running "guix package --search="
137 (_ "MARCH=UNSUPPORTED"))
138
139 "CONFIG_SHELL=bash" ;needed to build bundled libraries
140 "USE_SYSTEM_LIBUV=0" ;Julia expects a modified libuv
141 "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no
142 ;build system for a shared library.
143 "USE_SYSTEM_RMATH=0" ;Julia uses a bundled version of R's math
144 ;library, patched to use the DSFMT RNG.
145
146 "USE_SYSTEM_LAPACK=1"
147 "USE_SYSTEM_BLAS=1"
148 "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1
149
150 "USE_SYSTEM_FFTW=1"
151 "LIBFFTWNAME=libfftw3"
152 "LIBFFTWFNAME=libfftw3f"
153
154 ;; TODO: Suitesparse does not install shared libraries, so we cannot
155 ;; use the suitesparse package.
156 ;; "USE_SYSTEM_SUITESPARSE=1"
157 ;; (string-append "SUITESPARSE_INC=-I "
158 ;; (assoc-ref %build-inputs "suitesparse")
159 ;; "/include")
160
161 "USE_SYSTEM_GRISU=1" ;for double-conversion
162 "USE_SYSTEM_UTF8PROC=1"
163 "USE_SYSTEM_LLVM=1"
164 "USE_SYSTEM_LIBUNWIND=1"
165 "USE_SYSTEM_PCRE=1"
166 "USE_SYSTEM_OPENLIBM=1"
167 "USE_SYSTEM_GMP=1"
168 "USE_SYSTEM_MPFR=1"
169 "USE_SYSTEM_ARPACK=1"
170 "USE_SYSTEM_LIBGIT2=1"
171 "USE_SYSTEM_OPENSPECFUN=1")))
172 (inputs
173 `(("llvm" ,llvm-3.5)
174 ("arpack-ng" ,arpack-ng)
175 ("lapack" ,lapack)
176 ("openblas" ,openblas) ;Julia does not build with Atlas
177 ("libunwind" ,libunwind)
178 ("openlibm" ,openlibm)
179 ("openspecfun" ,openspecfun)
180 ("double-conversion" ,double-conversion)
181 ("fftw" ,fftw)
182 ("fftwf" ,fftwf)
183 ("fortran" ,gfortran)
184 ("pcre" ,pcre)
185 ("utf8proc" ,utf8proc)
186 ("git" ,git)
187 ("mpfr" ,mpfr)
188 ("gmp" ,gmp)))
189 (native-inputs
190 `(("perl" ,perl)
191 ("patchelf" ,patchelf)
192 ("pkg-config" ,pkg-config)
193 ("python" ,python-2)
194 ("which" ,which)))
195 ;; Julia is not officially released for ARM and MIPS.
196 ;; See https://github.com/JuliaLang/julia/issues/10639
197 (supported-systems '("i686-linux" "x86_64-linux"))
198 (home-page "http://julialang.org/")
199 (synopsis "High-performance dynamic language for technical computing")
200 (description
201 "Julia is a high-level, high-performance dynamic programming language for
202 technical computing, with syntax that is familiar to users of other technical
203 computing environments. It provides a sophisticated compiler, distributed
204 parallel execution, numerical accuracy, and an extensive mathematical function
205 library.")
206 (license license:expat)))