sagemath.scm 16 KB

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