projects/guix·blob python-team · refs

543 lines · 19.8 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2019, 2025, 2026 Andreas Enge <[email protected]>
3;;; Copyright © 2024, 2025 Vinicius Monego <[email protected]>
4;;; Copyright © 2025 Ricardo Wurmus <[email protected]>
5;;;
6;;; This file is part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (gnu packages sagemath)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix build-system copy)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix build-system pyproject)
26 #:use-module (guix download)
27 #:use-module (guix git-download)
28 #:use-module (guix gexp)
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 base)
35 #:use-module (gnu packages bdw-gc)
36 #:use-module (gnu packages boost)
37 #:use-module (gnu packages build-tools)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages compression)
40 #:use-module (gnu packages fontutils)
41 #:use-module (gnu packages gd)
42 #:use-module (gnu packages graph)
43 #:use-module (gnu packages image)
44 #:use-module (gnu packages jupyter)
45 #:use-module (gnu packages lisp)
46 #:use-module (gnu packages m4)
47 #:use-module (gnu packages maths)
48 #:use-module (gnu packages multiprecision)
49 #:use-module (gnu packages pkg-config)
50 #:use-module (gnu packages popt)
51 #:use-module (gnu packages python)
52 #:use-module (gnu packages python-build)
53 #:use-module (gnu packages python-science)
54 #:use-module (gnu packages python-xyz)
55 #:use-module (gnu packages sphinx))
56
57(define-public brial
58 (package
59 (name "brial")
60 (version "1.2.14")
61 (source
62 (origin
63 (method git-fetch)
64 (uri (git-reference
65 (url "https://github.com/BRiAl/BRiAl/")
66 (commit version)))
67 (file-name (git-file-name name version))
68 (sha256
69 (base32 "1bgbpid3xa41449v2mm08c25h3ipbn5viybx3iaqjvssaamfzrxx"))))
70 (build-system gnu-build-system)
71 (native-inputs
72 (list autoconf automake libtool pkg-config))
73 (inputs
74 (list boost libpng m4ri))
75 (arguments
76 ;; We are missing the boost unit test framework.
77 `(#:tests? #f
78 #:configure-flags (list "--without-boost-unit-test-framework")))
79 (synopsis "Arithmetic of polynomials over boolean rings")
80 (description "BRiAl is the successor to PolyBoRi maintained by the
81Sage community. Its core is a C++ library, which provides high-level data
82types for Boolean polynomials and monomials, exponent vectors, as well as
83for the underlying polynomial rings and subsets of the powerset of the
84Boolean variables. As a unique approach, binary decision diagrams are
85used as internal storage type for polynomial structures.")
86 (license license:gpl2+)
87 (home-page "https://github.com/BRiAl/BRiAl/")))
88
89(define-public lcalc
90 (package
91 (name "lcalc")
92 (version "2.1.1")
93 (source (origin
94 (method git-fetch)
95 (uri (git-reference
96 (url "https://gitlab.com/sagemath/lcalc")
97 (commit version)))
98 (file-name (git-file-name name version))
99 (sha256
100 (base32
101 "1p25lpr36xvs26sssdpc3p5g0y5nd07d3bm10lxhsqgrd522n9nh"))))
102 (build-system gnu-build-system)
103 (arguments
104 (list #:configure-flags '(list "--with-pari")))
105 (inputs (list pari-gp))
106 (native-inputs (list autoconf automake libtool pkg-config gengetopt))
107 (home-page "https://gitlab.com/sagemath/lcalc")
108 (synopsis "C++ library for computing with L-functions")
109 (description
110 "Lcalc computes L-functions, in particular the Riemann zeta function,
111Dirichlet L-functions and L-functions attached to elliptic curves and
112modular forms.")
113 (license license:gpl2+)))
114
115(define-public cliquer
116 (package
117 (name "cliquer")
118 (version "1.22")
119 (source (origin
120 (method git-fetch)
121 (uri (git-reference
122 (url "https://github.com/dimpase/autocliquer")
123 (commit (string-append "v" version))))
124 (file-name (git-file-name name version))
125 (sha256
126 (base32
127 "00gcmrhi2fjn8b246w5a3b0pl7p6haxy5wjvd9kcqib1xanz59z4"))))
128 (build-system gnu-build-system)
129 (native-inputs (list autoconf automake libtool))
130 (synopsis "C routines for finding cliques in weighted graphs")
131 (description "Cliquer is a set of reentrant C routines for finding
132cliques in a weighted or unweighted graph. It uses an exact
133branch-and-bound algorithm. It can search for maximum or maximum-weight
134cliques or cliques with size or weight within a given range, restrict the
135search to maximal cliques, store cliques in memory and call a user-defined
136function for every found clique.")
137 (license license:gpl2+)
138 (home-page "https://github.com/dimpase/autocliquer")))
139
140(define-public libbraiding
141 (package
142 (name "libbraiding")
143 (version "1.3.1")
144 (source
145 (origin
146 (method git-fetch)
147 (uri (git-reference
148 (url (string-append "https://github.com/miguelmarco/"
149 name))
150 (commit version)))
151 (file-name (git-file-name name version))
152 (sha256
153 (base32
154 "1d9vrn507phpzwwmmrxiig8s484rdi3gjghj75d4sdzbiqyyr9yp"))
155 (patches (search-patches "libbraiding-no-s.patch"))))
156 (build-system gnu-build-system)
157 (native-inputs
158 (list autoconf automake libtool pkg-config))
159 (synopsis "Computations with braid groups")
160 (description "libbraiding performs computations with braid groups,
161in particular it computes normal forms of group elements.")
162 (license license:gpl2+)
163 (home-page "https://github.com/miguelmarco/libbraiding")))
164
165(define-public libhomfly
166 (package
167 (name "libhomfly")
168 (version "1.02r6")
169 (source
170 (origin
171 (method git-fetch)
172 (uri (git-reference
173 (url (string-append "https://github.com/miguelmarco/"
174 name))
175 (commit version)))
176 (file-name (git-file-name name version))
177 (sha256
178 (base32
179 "0sv3cwrf9v9sb5a8wbhjmarxvya13ma3j8y8592f9ymxlk5y0ldk"))))
180 (build-system gnu-build-system)
181 (native-inputs
182 (list autoconf automake libtool))
183 (inputs
184 (list libgc))
185 (synopsis "Computation of homfly polynomials of links")
186 (description "libhomfly computes homfly polynomials of links,
187represented as strings.")
188 (license license:public-domain)
189 (home-page "https://github.com/miguelmarco/libhomfly")))
190
191(define-public python-cypari2
192 (package
193 (name "python-cypari2")
194 (version "2.2.2")
195 (source
196 (origin
197 (method url-fetch)
198 (uri (pypi-uri "cypari2" version))
199 (sha256
200 (base32
201 "080p17yn8wjl973jnw15hz3dhxzp3db1bi4giw3c28d2brrki8qk"))))
202 (build-system pyproject-build-system)
203 (native-inputs
204 (list python-cython python-pytest python-setuptools python-wheel))
205 (propagated-inputs
206 (list python-cysignals))
207 (inputs
208 (list gmp pari-gp))
209 (home-page "https://cypari2.readthedocs.io/")
210 (synopsis
211 "Python interface to the number theory library libpari")
212 (description
213 "Cypari2 provides a Python interface to the number theory library
214PARI/GP. It has been spun off from the SageMath mathematics software system,
215but it can be used independently.")
216 (license license:gpl2+)))
217
218(define-public python-gmpy2
219 (package
220 (name "python-gmpy2")
221 (version "2.2.1")
222 (source
223 (origin
224 (method url-fetch)
225 (uri (pypi-uri "gmpy2" version))
226 (sha256
227 (base32
228 "0ch4cnbgnxifcbvkxsc7m5ylxsagrjrhr4a4fnw8rds1fib0fgp8"))))
229 (build-system pyproject-build-system)
230 (native-inputs (list python-pytest python-setuptools python-wheel))
231 (inputs
232 (list gmp mpfr mpc))
233 (home-page "https://github.com/aleaxit/gmpy")
234 (synopsis
235 "GMP/MPIR, MPFR, and MPC interface to Python 2.6+ and 3.x")
236 (description
237 "This package provides a Python interface to the GNU multiprecision
238libraries GMO, MPFR and MPC.")
239 (license license:lgpl3+)))
240
241(define-public python-memory-allocator
242 (package
243 (name "python-memory-allocator")
244 (version "0.1.4")
245 (source
246 (origin
247 (method url-fetch)
248 (uri (pypi-uri "memory_allocator" version))
249 (sha256
250 (base32 "1r7g175ddbpn5kjgs6f09s7mfachzw94p02snki6f6830dmj22fn"))))
251 (build-system pyproject-build-system)
252 (arguments
253 (list #:tests? #f)) ;no tests in PyPI or Git
254 (native-inputs
255 (list python-cython python-setuptools))
256 (home-page "https://github.com/sagemath/memory_allocator")
257 (synopsis "Extension class to allocate memory easily with Cython")
258 (description "This package provides a single extension class
259 @code{MemoryAllocator} with @code{cdef} methods
260
261@itemize
262@item @code{malloc}
263@item @code{calloc}
264@item @code{allocarray}
265@item @code{realloc}
266@item @code{reallocarray}
267@item @code{aligned_malloc}
268@item @code{aligned_malloc}
269@item @code{aligned_calloc}
270@item @code{aligned_allocarray}
271@end itemize")
272 (license license:gpl3+)))
273
274(define-public python-pplpy
275 (package
276 (name "python-pplpy")
277 (version "0.8.10")
278 (source
279 (origin
280 (method url-fetch)
281 (uri (pypi-uri "pplpy" version))
282 (sha256
283 (base32 "1zggfj09zkfcabcsasq27vwbhdmkig4yn380gi6wykcih9n22anl"))))
284 (build-system pyproject-build-system)
285 (native-inputs
286 (list python-cython
287 python-pytest
288 python-setuptools
289 python-wheel))
290 (inputs (list gmp mpc mpfr pari-gp ppl))
291 (propagated-inputs (list python-cysignals python-gmpy2))
292 (home-page "https://github.com/sagemath/pplpy")
293 (synopsis "Python PPL wrapper")
294 (description "This Python package provides a wrapper to the C++ Parma
295Polyhedra Library (PPL).")
296 (license license:gpl3+)))
297
298(define conway-polynomials
299 (package
300 (name "conway-polynomials")
301 (version "0.10")
302 (source
303 (origin
304 (method url-fetch)
305 (uri (pypi-uri "conway_polynomials" version))
306 (sha256
307 (base32 "1wz03a08kwlswx1pcr5d99ppmhpfzs2a5i969rnb2ghsz1j9yqag"))))
308 (build-system pyproject-build-system)
309 (native-inputs (list python-pytest python-setuptools python-wheel))
310 (home-page "https://github.com/sagemath/conway-polynomials")
311 (synopsis "Python interface to Frank Lübeck's Conway polynomial database")
312 (description "This package provides a Python interface to Frank Lübeck's
313Conway polynomial database. These are used in several computer algebra
314systems such as GAP and SageMath to provide quick access to those Conway
315polynomials. The aim of this package is to make them available through a
316generic Python interface.")
317 (license license:gpl3+)))
318
319(define polytopes-db
320 (package
321 (name "polytopes-db")
322 (version "20170220")
323 (source (origin
324 (method url-fetch)
325 (uri (string-append
326 "https://mirrors.mit.edu/sage/spkg/upstream/polytopes_db"
327 "/polytopes_db-" version ".tar.bz2"))
328 (sha256
329 (base32
330 "1q0cd811ilhax4dsj9y5p7z8prlalqr7k9mzq178c03frbgqny6b"))))
331 (build-system copy-build-system)
332 (arguments '(#:install-plan '(("." "share/reflexive_polytopes"))))
333 (home-page "https://doc.sagemath.org/html/en/reference/spkg/polytopes_db.html")
334 (synopsis "Lists of 2- and 3-dimensional reflexive polytopes")
335 (description
336 "This package contains data for 2- and 3-dimensional reflexive polytopes
337to be used by SageMath.")
338 ;; Debian says GPLv2+.
339 (license license:gpl2+)))
340
341(define graphs
342 (package
343 (name "graphs")
344 (version "20210214")
345 (source (origin
346 (method url-fetch)
347 (uri (string-append
348 "https://mirrors.mit.edu/sage/spkg/upstream/"
349 "graphs/graphs-" version ".tar.bz2"))
350 (sha256
351 (base32
352 "0h9p5wrxips51x6vpfiiaqzp9j004nwppzc9qc2iaqakk06pq8q7"))))
353 (build-system copy-build-system)
354 (arguments
355 '(#:install-plan '(("." "share/graphs"))))
356 (home-page "https://www.sagemath.org")
357 (synopsis "Database of graphs")
358 (description
359 "This package contains databases of graphs. It also includes the
360@acronym{ISGCI, Information System on Graph Classes and their Inclusions}
361database.")
362 ;; Debian says GPLv2+.
363 (license license:gpl2+)))
364
365(define-public sage
366 (package
367 (name "sage")
368 (version "10.9")
369 (source (origin
370 (method git-fetch)
371 (uri (git-reference
372 (url "https://github.com/sagemath/sage")
373 (commit version)))
374 (file-name (git-file-name name version))
375 (sha256
376 (base32
377 "1rbwhhxj6iizfcgbzd63lf1g1dh24253mmmzgfkvcbv6hx0l507h"))))
378 (build-system pyproject-build-system)
379 (native-inputs
380 (list autoconf automake m4 pkg-config ; for ./bootstrap
381 python-cython
382 python-cysignals
383 python-memory-allocator
384 python-meson
385 python-pkgconfig
386 python-jinja2
387 python-sphinx
388 python-wheel))
389 (propagated-inputs
390 (list ;; required to make the sage script start
391 python-ipython
392 python-ipywidgets
393 python-traitlets
394 ;; required for the Jupyter notebook
395 python-jupyter-client
396 python-notebook))
397 (inputs
398 ;; FIXME: Add more standard inputs. They follow the list at
399 ;; https://doc.sagemath.org/html/en/reference/spkg/
400 ;; They are required to pass standard Sage tests (sage-runtests).
401 (list boost
402 brial
403 cliquer
404 conway-polynomials
405 coreutils
406 ecl
407 eclib
408 edge-addition-planarity-suite
409 fflas-ffpack
410 flint
411 fontconfig
412 freetype
413 gap
414 gd
415 givaro
416 glpk
417 gmp
418 gmp-ecm
419 graphs
420 gsl
421 ijg-libjpeg
422 iml
423 lcalc
424 libbraiding
425 libhomfly
426 linbox
427 libpng
428 m4ri
429 m4rie
430 maxima-ecl
431 mpc
432 mpfi
433 mpfr
434 ntl
435 openblas
436 pari-gp
437 polytopes-db
438 python
439 python-cvxopt
440 python-cypari2
441 python-fpylll
442 python-gmpy2
443 python-lrcalc
444 python-mpmath
445 python-networkx
446 python-numpy
447 python-pplpy
448 python-primecountpy
449 python-scipy
450 python-sympy
451 rw
452 sed
453 singular
454 symmetrica))
455 (arguments
456 (list
457 #:tests? #f ; Tests can be run using "make ptestlong", but it is
458 ; expected that some of them fail.
459 #:phases
460 #~(modify-phases %standard-phases
461 (add-after 'unpack 'patch-source
462 (lambda _
463 (let ((ecl #$(this-package-input "ecl"))
464 (ecm #$(this-package-input "gmp-ecm"))
465 (maxima #$(this-package-input "maxima-ecl"))
466 (maxima-version #$(package-version
467 (this-package-input "maxima-ecl")))
468 (singular #$(this-package-input "singular"))
469 (gap #$(this-package-input "gap"))
470 (pari-gp #$(this-package-input "pari-gp"))
471 (python #$(this-package-input "python"))
472 (coreutils #$(this-package-input "coreutils"))
473 (sed #$(this-package-input "sed"))
474 (graphs #$(this-package-input "graphs"))
475 (polytopes-db #$(this-package-input "polytopes-db")))
476 ;; Patch out meson checks for things that will work since we
477 ;; patch env.py below.
478 (substitute* "src/sage/libs/meson.build"
479 (("maxima_check.returncode\\(\\) == 0") "true"))
480 (substitute* (find-files "build/bin")
481 (("sage-bootstrap-python") "python"))
482 (substitute* "src/sage/env.py"
483 (("\"ecl-config\"")
484 (string-append "\"" ecl "/bin/ecl-config\""))
485 (("\"ecm\"")
486 (string-append "\"" ecm "/bin/ecm\""))
487 (("\"maxima\"")
488 (string-append "\"" maxima "/bin/maxima\""))
489 (("\"MAXIMA_FAS\"")
490 (string-append "\"MAXIMA_FAS\", \"" maxima
491 "/lib/maxima/" maxima-version
492 "/binary-ecl/maxima.fas\""))
493 (("\"Singular\"")
494 (string-append "\"" singular "/bin/Singular\""))
495 (("var\\('SAGE_GAP_COMMAND', None\\)")
496 (string-append "var('SAGE_GAP_COMMAND', \""
497 gap "/bin/gap\")"))
498 (("join\\(SAGE_LOCAL, \"lib\", \"gap\"\\)")
499 (string-append "\"" gap "/lib/gap\""))
500 (("join\\(SAGE_LOCAL, \"share\", \"gap\"\\)")
501 (string-append "\"" gap "/share/gap\""))
502 ;; definition of SAGE_VENV, which ends up in kernel.json
503 (("os.path.abspath\\(sys.prefix\\)")
504 (string-append "\"" #$output "\""))
505 ;; paths of the databases
506 (("GRAPHS_DATA_DIR\"")
507 (string-append
508 "GRAPHS_DATA_DIR\", "
509 "\"" graphs "/share/graphs\""))
510 (("POLYTOPE_DATA_DIR\"")
511 (string-append
512 "POLYTOPE_DATA_DIR\", "
513 "\"" polytopes-db "/share/reflexive_polytopes\"")))
514 (substitute* "src/sage/interfaces/gp.py"
515 (("command=f\"gp")
516 (string-append "command=f\"" pari-gp "/bin/gp")))
517 ;; Remove when updating to sage-10.8, python-3.12.
518 ;; See https://github.com/sagemath/sage/pull/41141
519 (substitute* "src/sage/repl/display/formatter.py"
520 (("from IPython.utils.py3compat import unicode_to_str") "")
521 (("unicode_to_str\\(self.newline\\)") "self.newline"))
522 (substitute* "src/bin/sage"
523 (("exec python3")
524 (string-append "exec " python "/bin/python3"))
525 (("mkdir")
526 (string-append coreutils "/bin/mkdir"))
527 ((" sed ")
528 (string-append " " sed "/bin/sed "))))))
529 (add-before 'build 'setup
530 (lambda _
531 (setenv "SAGE_NUM_THREADS"
532 (number->string (parallel-job-count)))
533 (invoke "./bootstrap")))
534 (delete 'sanity-check)))) ; does not reflect reality
535 (home-page "https://www.sagemath.org/")
536 (synopsis "SageMath computer algebra system")
537 (description
538 "SageMath is a mathematics software built on top of many existing
539packages such as NumPy, SciPy, Matplotlib, Sympy, Maxima, GAP, FLINT,
540R and others. Their combined power may be accessed through a common,
541Python-based language or directly via interfaces or wrappers.")
542 ;; Documentation under cc-by-sa3.0, see COPYING.txt in the distribution.
543 (license license:gpl3)))