gnu: Simplify package inputs.
[jackhill/guix/guix.git] / gnu / packages / sagemath.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2019 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
4 ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
6 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages sagemath)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix build-system gnu)
26 #:use-module (guix build-system python)
27 #:use-module (guix download)
28 #:use-module (guix git-download)
29 #:use-module (guix packages)
30 #:use-module (guix utils)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages algebra)
33 #:use-module (gnu packages autotools)
34 #:use-module (gnu packages bdw-gc)
35 #:use-module (gnu packages boost)
36 #:use-module (gnu packages compression)
37 #:use-module (gnu packages image)
38 #:use-module (gnu packages lisp)
39 #:use-module (gnu packages multiprecision)
40 #:use-module (gnu packages pkg-config)
41 #:use-module (gnu packages python)
42 #:use-module (gnu packages python-xyz))
43
44
45 (define-public python-cypari2
46 (package
47 (name "python-cypari2")
48 (version "2.1.2")
49 (source
50 (origin
51 (method url-fetch)
52 (uri (pypi-uri "cypari2" version))
53 (sha256
54 (base32
55 "0ymc4i9y60aazscc1blivirkr1rflzz6akkmvfzyn5l7mgnlbk83"))))
56 (build-system python-build-system)
57 (native-inputs
58 (list python-cython))
59 (propagated-inputs
60 (list python-cysignals))
61 (inputs
62 (list gmp pari-gp))
63 (home-page "https://cypari2.readthedocs.io/")
64 (synopsis
65 "Python interface to the number theory library libpari")
66 (description
67 "Cypari2 provides a Python interface to the number theory library
68 PARI/GP. It has been spun off from the SageMath mathematics software system,
69 but it can be used independently.")
70 (license license:gpl2+)))
71
72 (define-public python2-cypari2
73 (package-with-python2 python-cypari2))
74
75 ;; The stable version of the following package is not young enough to be
76 ;; used with Sage, since it does not support cython; so we use a beta
77 ;; release.
78 (define-public python-gmpy2
79 (package
80 (name "python-gmpy2")
81 (version "2.1.0b1")
82 (source (origin
83 (method git-fetch)
84 (uri (git-reference
85 (url "https://github.com/aleaxit/gmpy")
86 (commit (string-append "gmpy2-" version))))
87 (file-name (git-file-name name version))
88 (sha256
89 (base32
90 "0ljvnmhxqdfsp0yy4c2hynhk5sggm63kkqsq4iwq4k9vsnx2xm97"))))
91 (build-system python-build-system)
92 (native-inputs
93 (list unzip))
94 (inputs
95 (list gmp mpfr mpc))
96 (home-page "https://github.com/aleaxit/gmpy")
97 (synopsis
98 "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x")
99 (description
100 "This package provides a Python interface to the GNU multiprecision
101 libraries GMO, MPFR and MPC.")
102 (license license:lgpl3+)))
103
104 (define-public python2-gmpy2
105 (package-with-python2 python-gmpy2))
106
107 (define-public cliquer
108 (package
109 (name "cliquer")
110 (version "1.21")
111 ;; The original source package is available from the home page and
112 ;; has not seen any release since 2010; it comes with only a Makefile
113 ;; without an "install" target. Instead, there is an autotoolized
114 ;; tarball available from the Sage project.
115 (source
116 (origin
117 (method url-fetch)
118 (uri "http://users.ox.ac.uk/~coml0531/sage/cliquer-1.21.tar.gz")
119 (sha256
120 (base32
121 "1hdzrmrx0nvvj8kbwxrs8swqgkd284khzl623jizixcv28xb77aq"))))
122 (build-system gnu-build-system)
123 (synopsis "C routines for finding cliques in weighted graphs")
124 (description "Cliquer is a set of reentrant C routines for finding
125 cliques in a weighted or unweighted graph. It uses an exact
126 branch-and-bound algorithm. It can search for maximum or maximum-weight
127 cliques or cliques with size or weight within a given range, restrict the
128 search to maximal cliques, store cliques in memory and call a user-defined
129 function for every found clique.")
130 (license license:gpl2+)
131 (home-page "https://users.aalto.fi/~pat/cliquer.html")))
132
133 (define-public libbraiding
134 (package
135 (name "libbraiding")
136 (version "1.0")
137 (source
138 (origin
139 (method git-fetch)
140 (uri (git-reference
141 (url (string-append "https://github.com/miguelmarco/"
142 name))
143 (commit version)))
144 (file-name (git-file-name name version))
145 (sha256
146 (base32
147 "0l68rikfr7k2l547gb3pp3g8cj5zzxwipm79xrb5r8ffj466ydxg"))))
148 (build-system gnu-build-system)
149 (native-inputs
150 (list autoconf automake libtool))
151 (synopsis "Computations with braid groups")
152 (description "libbraiding performs computations with braid groups,
153 in particular it computes normal forms of group elements.")
154 (license license:gpl2+)
155 (home-page "https://github.com/miguelmarco/libbraiding")))
156
157 (define-public libhomfly
158 (package
159 (name "libhomfly")
160 (version "1.02r6")
161 (source
162 (origin
163 (method git-fetch)
164 (uri (git-reference
165 (url (string-append "https://github.com/miguelmarco/"
166 name))
167 (commit version)))
168 (file-name (git-file-name name version))
169 (sha256
170 (base32
171 "0sv3cwrf9v9sb5a8wbhjmarxvya13ma3j8y8592f9ymxlk5y0ldk"))))
172 (build-system gnu-build-system)
173 (native-inputs
174 (list autoconf automake libtool))
175 (inputs
176 (list libgc))
177 (synopsis "Computation of homfly polynomials of links")
178 (description "libhomfly computes homfly polynomials of links,
179 represented as strings.")
180 (license license:public-domain)
181 (home-page "https://github.com/miguelmarco/libhomfly")))
182
183 ;; Sage 9.1 doesn't build with ECL 20. This won't be necessary once 9.2 is
184 ;; released. See https://trac.sagemath.org/ticket/22191
185 (define-public ecl-16
186 (package
187 (inherit ecl)
188 (version "16.1.3")
189 (source
190 (origin
191 (method url-fetch)
192 (uri (string-append
193 "https://common-lisp.net/project/ecl/static/files/release/ecl"
194 "-" version ".tgz"))
195 (sha256
196 (base32 "0m0j24w5d5a9dwwqyrg0d35c0nys16ijb4r0nyk87yp82v38b9bn"))
197 (patches (search-patches
198 "ecl-16-libffi.patch"
199 "ecl-16-ignore-stderr-write-error.patch"
200 "ecl-16-format-directive-limit.patch"))))
201 ;; Current ECL uses LGPL 2.1+
202 (license license:lgpl2.0+)))
203
204 (define-public pynac
205 (package
206 (name "pynac")
207 (version "0.7.26")
208 (source
209 (origin
210 (method git-fetch)
211 (uri (git-reference
212 (url "https://github.com/pynac/pynac/")
213 (commit (string-append "pynac-" version))))
214 (file-name (git-file-name name version))
215 (sha256
216 (base32 "09d2p74x1arkydlxy6pw4p4byi7r8q7f29w373h4d8a215kadc6d"))))
217 (build-system gnu-build-system)
218 (native-inputs
219 (list autoconf automake libtool pkg-config))
220 (inputs
221 (list flint gmp python singular))
222 (synopsis "Sage fork of GiNaC")
223 (description "Pynac is a derivative of the C++ library GiNaC, which
224 allows manipulation of symbolic expressions. It currently provides the
225 backend for symbolic expressions in Sage. The main difference between
226 Pynac and GiNaC is that Pynac relies on Sage to provide the operations
227 on numerical types, while GiNaC depends on CLN for this purpose.")
228 (license license:gpl2+)
229 (home-page "http://pynac.org/")))
230
231 ;; Sage has become upstream of the following package.
232 (define-public zn-poly
233 (package
234 (name "zn-poly")
235 (version "0.9.2")
236 (source
237 (origin
238 (method git-fetch)
239 (uri (git-reference
240 (url (string-append "https://gitlab.com/sagemath/"
241 "zn_poly.git/"))
242 (commit version)))
243 (file-name (git-file-name "zn_poly" version))
244 (sha256
245 (base32 "1wbc3apxcldxfcw1dnwnn7fvlfb6bwvlr8glvgv6hf79p9r2s4j0"))))
246 (build-system gnu-build-system)
247 (native-inputs
248 `(("python" ,python-2)))
249 (inputs
250 (list gmp))
251 (arguments
252 `(#:phases
253 (modify-phases %standard-phases
254 (replace 'configure
255 ;; The configure script chokes on --enable-fast-install.
256 (lambda* (#:key inputs outputs #:allow-other-keys)
257 (invoke "./configure"
258 (string-append "--prefix=" (assoc-ref outputs "out"))
259 "--cflags=-O3 -fPIC")))
260 (add-before 'build 'prepare-build
261 (lambda _
262 (setenv "CC" "gcc")
263 #t))
264 (add-after 'build 'build-so
265 (lambda _
266 (invoke "make" "libzn_poly.so")))
267 (add-after 'install 'install-so
268 (lambda* (#:key outputs #:allow-other-keys)
269 (let* ((out (assoc-ref outputs "out"))
270 (lib (string-append out "/lib"))
271 (soname (string-append "libzn_poly-" ,version ".so"))
272 (target (string-append lib "/" soname)))
273 (install-file "libzn_poly.a" lib)
274 (install-file soname lib)
275 (symlink target
276 (string-append lib "/libzn_poly.so"))
277 (symlink target
278 (string-append lib "/libzn_poly-"
279 ,(version-major+minor version)
280 ".so")))
281 #t)))))
282 (synopsis "Arithmetic for polynomials over Z/NZ")
283 (description "zn_poly implements the arithmetic of polynomials the
284 coefficients of which are modular integers.")
285 (license (list license:gpl2 license:gpl3)) ; dual licensed
286 (home-page "https://gitlab.com/sagemath/zn_poly")))
287
288 (define-public brial
289 (package
290 (name "brial")
291 (version "1.2.8")
292 (source
293 (origin
294 (method git-fetch)
295 (uri (git-reference
296 (url "https://github.com/BRiAl/BRiAl/")
297 (commit version)))
298 (file-name (git-file-name name version))
299 (sha256
300 (base32 "0qhgckd4fvbs40jw14mvw89rccv94d3df27kipd27hxd4cx7y80y"))))
301 (build-system gnu-build-system)
302 (native-inputs
303 (list autoconf automake libtool pkg-config))
304 (inputs
305 (list boost libpng m4ri))
306 (arguments
307 ;; We are missing the boost unit test framework.
308 `(#:tests? #f
309 #:configure-flags (list "--without-boost-unit-test-framework")))
310 (synopsis "Arithmetic of polynomials over boolean rings")
311 (description "BRiAl is the successor to PolyBoRi maintained by the
312 Sage community. Its core is a C++ library, which provides high-level data
313 types for Boolean polynomials and monomials, exponent vectors, as well as
314 for the underlying polynomial rings and subsets of the powerset of the
315 Boolean variables. As a unique approach, binary decision diagrams are
316 used as internal storage type for polynomial structures.")
317 (license license:gpl2+)
318 (home-page "https://github.com/BRiAl/BRiAl/")))
319
320 (define-public lcalc
321 (package
322 (name "lcalc")
323 (version "1.23")
324 ;; The original home page of the project has disappeared, as well as
325 ;; code hosted by the original author on Google Code. The latter has
326 ;; been copied to gitlab.com/sagemath and purportedly contains patches
327 ;; for a never released version 1.3, that supposedly follows 1.23.
328 ;; We use the tarball as well as the patches hosted inside the sage
329 ;; package system distributed with the sage tarball.
330 (source
331 (origin
332 (method url-fetch)
333 (uri (string-append "ftp://ftp.fu-berlin.de/unix/misc/sage/spkg/"
334 "upstream/lcalc/lcalc-1.23.tar.bz2"))
335 (sha256
336 (base32
337 "1c6dsdshgxhqppjxvxhp8yhpxaqvnz3d1mlh26r571gkq8z2bm43"))
338 (patches (search-patches "lcalc-lcommon-h.patch"
339 "lcalc-default-parameters-1.patch"
340 "lcalc-default-parameters-2.patch"
341 "lcalc-using-namespace-std.patch"))))
342 (build-system gnu-build-system)
343 (arguments
344 `(#:tests? #f ;no tests
345 #:phases
346 (modify-phases %standard-phases
347 (delete 'configure)
348 (add-before 'build 'prepare-build
349 (lambda* (#:key outputs #:allow-other-keys)
350 (chdir "src")
351 (let ((out (assoc-ref outputs "out")))
352 (substitute* "Makefile"
353 (("^INSTALL_DIR= /usr/local")
354 (string-append "INSTALL_DIR=" out))))
355 #t))
356 (add-before 'install 'make-output-dirs
357 (lambda* (#:key outputs #:allow-other-keys)
358 (let* ((out (assoc-ref outputs "out"))
359 (bin (string-append out "/bin"))
360 (lib (string-append out "/lib"))
361 (include (string-append out "/include")))
362 (mkdir-p bin)
363 (mkdir-p lib)
364 (mkdir-p include))
365 #t)))))
366 ;; FIXME:
367 ;; We need to add pari-gp and probably pari related patches from the
368 ;; sage project, as well as uncomment the line setting PARI_DEFINE in
369 ;; the Makefile to get the full functionality of this package.
370 ;; For the time being, we hope that sage can be compiled without.
371 (synopsis "C++ library for L-functions")
372 (description "Lcalc computes L-functions, in particular the Riemann
373 zeta function and its twists by quadratic characters.")
374 (license license:gpl2+)
375 (home-page "https://gitlab.com/sagemath/sage")))
376
377 (define-public ratpoints
378 (package
379 (name "ratpoints")
380 (version "2.1.3")
381 (source (origin
382 (method url-fetch)
383 (uri (string-append
384 "http://www.mathe2.uni-bayreuth.de/stoll/programs/"
385 "ratpoints-" version ".tar.gz"))
386 (sha256
387 (base32
388 "0zhad84sfds7izyksbqjmwpfw4rvyqk63yzdjd3ysd32zss5bgf4"))
389 (patches
390 ;; Taken from
391 ;; <https://git.sagemath.org/sage.git/plain/build/pkgs/ratpoints/patches/>
392 (search-patches "ratpoints-sturm_and_rp_private.patch"))))
393 (build-system gnu-build-system)
394 (arguments
395 `(#:test-target "test"
396 #:make-flags
397 (list (string-append "INSTALL_DIR=" (assoc-ref %outputs "out"))
398 "CCFLAGS=-fPIC")
399 #:phases
400 (modify-phases %standard-phases
401 (delete 'configure) ;no configure script
402 (add-before 'install 'create-install-directories
403 (lambda* (#:key outputs #:allow-other-keys)
404 (let ((out (assoc-ref outputs "out")))
405 (mkdir-p out)
406 (with-directory-excursion out
407 (for-each (lambda (d) (mkdir-p d))
408 '("bin" "include" "lib"))))
409 #t)))))
410 (inputs
411 (list gmp))
412 (home-page "http://www.mathe2.uni-bayreuth.de/stoll/programs/")
413 (synopsis "Find rational points on hyperelliptic curves")
414 (description "Ratpoints tries to find all rational points within
415 a given height bound on a hyperelliptic curve in a very efficient way,
416 by using an optimized quadratic sieve algorithm.")
417 (license license:gpl2+)))