1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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 utils)
24 #:use-module (guix git-download)
25 #:use-module (guix build-system gnu)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages algebra)
28 #:use-module (gnu packages base)
29 #:use-module (gnu packages elf)
30 #:use-module (gnu packages gcc)
31 #:use-module (gnu packages llvm)
32 #:use-module (gnu packages libevent)
33 #:use-module (gnu packages libunwind)
34 #:use-module (gnu packages maths)
35 #:use-module (gnu packages multiprecision) ; mpfr
36 #:use-module (gnu packages pcre)
37 #:use-module (gnu packages perl)
38 #:use-module (gnu packages pkg-config)
39 #:use-module (gnu packages python)
40 #:use-module (gnu packages textutils)
41 #:use-module (gnu packages version-control)
42 #:use-module (gnu packages wget)
43 #:use-module (ice-9 match))
46 (let ((commit "030481e9d659fd46702ab747caf2cbbe19d537ba")
48 (package (inherit libuv)
50 (version (string-append "0.11.26." revision "-" (string-take commit 8)))
54 (url "https://github.com/JuliaLang/libuv.git")
56 (file-name (string-append name "-" version "-checkout"))
59 "1ss63wfr2hghc8kb6ciry394gp6x58haz8vaj57l5mp80z04gd54"))))
60 (build-system gnu-build-system)
62 (substitute-keyword-arguments (package-arguments libuv)
64 `(modify-phases ,phases
66 (home-page "https://github.com/JuliaLang/libuv"))))
75 "https://github.com/JuliaLang/julia/releases/download/v"
76 version "/julia-" version "-full.tar.gz"))
79 "0sikirixvryf8z3d0skig22fpip64jk001qsha98iwsrcfiqpyds"))))
80 (build-system gnu-build-system)
82 `(#:test-target "test"
83 #:modules ((ice-9 match)
84 (guix build gnu-build-system)
88 ;; The DSOs use $ORIGIN to refer to each other, but (guix build
89 ;; gremlin) doesn't support it yet, so skip this phase.
90 #:validate-runpath? #f
93 (modify-phases %standard-phases
95 (add-after 'unpack 'hardcode-soname-map
96 ;; ./src/ccall.cpp creates a map from library names to paths using the
97 ;; output of "/sbin/ldconfig -p". Since ldconfig is not used in Guix,
98 ;; we patch ccall.cpp to contain a static map.
99 (lambda* (#:key inputs #:allow-other-keys)
100 (use-modules (ice-9 match))
101 (substitute* "src/ccall.cpp"
102 (("jl_read_sonames.*;")
105 ((input libname soname)
107 "sonameMap[\"" libname "\"] = "
108 "\"" (assoc-ref inputs input) "/lib/" soname "\";")))
109 '(("libc" "libc" "libc.so.6")
110 ("pcre2" "libpcre2-8" "libpcre2-8.so")
111 ("mpfr" "libmpfr" "libmpfr.so")
112 ("openblas" "libblas" "libopenblas.so")
113 ("arpack-ng" "libarpack" "libarpack.so")
114 ("lapack" "liblapack" "liblapack.so")
115 ("libgit2" "libgit2" "libgit2.so")
116 ("gmp" "libgmp" "libgmp.so")
117 ("openlibm" "libopenlibm" "libopenlibm.so")
118 ("openspecfun" "libopenspecfun" "libopenspecfun.so")
119 ("fftw" "libfftw3" "libfftw3.so")
120 ("fftwf" "libfftw3f" "libfftw3f.so"))))))
122 (add-before 'build 'fix-include-and-link-paths
123 (lambda* (#:key inputs #:allow-other-keys)
124 ;; LIBUTF8PROC is a linker flag, not a build target. It is
125 ;; included in the LIBFILES_* variable which is used as a
126 ;; collection of build targets and a list of libraries to link
128 (substitute* "src/flisp/Makefile"
129 (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\): \\$\\(OBJS\\) \\$\\(LIBFILES_release\\)")
130 "$(BUILDDIR)/$(EXENAME): $(OBJS) $(LLT_release)")
131 (("\\$\\(BUILDDIR\\)/\\$\\(EXENAME\\)-debug: \\$\\(DOBJS\\) \\$\\(LIBFILES_debug\\)")
132 "$(BUILDDIR)/$(EXENAME)-debug: $(DOBJS) $(LLT_debug)"))
134 ;; The REPL must be linked with libuv.
135 (substitute* "ui/Makefile"
137 (string-append "JLDFLAGS += "
138 (assoc-ref %build-inputs "libuv")
141 (substitute* "deps/Makefile"
142 (("/usr/include/double-conversion")
143 (string-append (assoc-ref %build-inputs "double-conversion")
144 "/include/double-conversion")))
145 (substitute* "base/Makefile"
146 (("\\$\\(build_includedir\\)/uv-errno.h")
147 (string-append (assoc-ref inputs "libuv")
148 "/include/uv-errno.h")))
150 (add-before 'build 'replace-default-shell
152 (substitute* "base/client.jl"
153 (("/bin/sh") (which "sh")))
155 (add-after 'unpack 'hardcode-paths
157 (substitute* "base/interactiveutil.jl"
158 (("`which") (string-append "`" (which "which")))
159 (("`wget") (string-append "`" (which "wget"))))
161 (add-before 'check 'disable-broken-tests
163 (substitute* "test/choosetests.jl"
164 ;; These tests time out. See
165 ;; https://github.com/JuliaLang/julia/issues/14374 for ongoing
167 (("\"replcompletions\",") "")
169 (substitute* "test/repl.jl"
170 ;; This test fails because we cannot escape the build
172 (("@test pwd\\(\\) == homedir\\(\\)") "#"))
176 (string-append "prefix=" (assoc-ref %outputs "out"))
178 ;; Passing the MARCH flag is necessary to build binary substitutes for
179 ;; the supported architectures.
180 ,(match (or (%current-target-system)
182 ("x86_64-linux" "MARCH=x86-64")
183 ("i686-linux" "MARCH=pentium4")
184 ;; Prevent errors when querying this package on unsupported
185 ;; platforms, e.g. when running "guix package --search="
186 (_ "MARCH=UNSUPPORTED"))
188 "CONFIG_SHELL=bash" ;needed to build bundled libraries
189 "USE_SYSTEM_DSFMT=0" ;not packaged for Guix and upstream has no
190 ;build system for a shared library.
191 "USE_SYSTEM_RMATH=0" ;Julia uses a bundled version of R's math
192 ;library, patched to use the DSFMT RNG.
194 "USE_SYSTEM_LAPACK=1"
196 "USE_BLAS64=0" ;needed when USE_SYSTEM_BLAS=1
199 "LIBFFTWNAME=libfftw3"
200 "LIBFFTWFNAME=libfftw3f"
202 ;; TODO: Suitesparse does not install shared libraries, so we cannot
203 ;; use the suitesparse package.
204 ;; "USE_SYSTEM_SUITESPARSE=1"
205 ;; (string-append "SUITESPARSE_INC=-I "
206 ;; (assoc-ref %build-inputs "suitesparse")
209 "USE_GPL_LIBS=1" ;proudly
210 "USE_SYSTEM_GRISU=1" ;for double-conversion
211 "USE_SYSTEM_UTF8PROC=1"
212 (string-append "UTF8PROC_INC="
213 (assoc-ref %build-inputs "utf8proc")
216 "USE_SYSTEM_LIBUNWIND=1"
218 (string-append "LIBUV="
219 (assoc-ref %build-inputs "libuv")
221 (string-append "LIBUV_INC="
222 (assoc-ref %build-inputs "libuv")
224 "USE_SYSTEM_PATCHELF=1"
226 "USE_SYSTEM_OPENLIBM=1"
229 "USE_SYSTEM_ARPACK=1"
230 "USE_SYSTEM_LIBGIT2=1"
231 "USE_SYSTEM_OPENSPECFUN=1")))
234 ("arpack-ng" ,arpack-ng)
235 ("coreutils" ,coreutils) ;for bindings to "mkdir" and the like
237 ("openblas" ,openblas) ;Julia does not build with Atlas
238 ("libunwind" ,libunwind)
239 ("openlibm" ,openlibm)
240 ("openspecfun" ,openspecfun)
241 ("double-conversion" ,double-conversion)
245 ("fortran" ,gfortran)
246 ("libuv" ,libuv-julia)
248 ("utf8proc" ,utf8proc)
255 ("patchelf" ,patchelf)
256 ("pkg-config" ,pkg-config)
257 ("python" ,python-2)))
258 ;; Julia is not officially released for ARM and MIPS.
259 ;; See https://github.com/JuliaLang/julia/issues/10639
260 (supported-systems '("i686-linux" "x86_64-linux"))
261 (home-page "http://julialang.org/")
262 (synopsis "High-performance dynamic language for technical computing")
264 "Julia is a high-level, high-performance dynamic programming language for
265 technical computing, with syntax that is familiar to users of other technical
266 computing environments. It provides a sophisticated compiler, distributed
267 parallel execution, numerical accuracy, and an extensive mathematical function
269 (license license:expat)))