diff mbox series

[bug#56729,RFC,v3,32/32] gnu: Add sagemath.

Message ID d12ccdbb7c73d83d72adfeb365ece8fd0dd4b59e.1685391448.git.guix@ikherbers.com
State New
Headers show
Series Add sagemath. | expand

Commit Message

vicvbcun May 29, 2023, 8:38 p.m. UTC
* gnu/packages/sagemath.scm (sagemath): New variable.
---

Notes:
    Higher timeout (default: 5 min.) or disable entirely?
    The `--timeout' flag needs to be immediately after `t'

 gnu/packages/sagemath.scm | 68 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/sagemath.scm b/gnu/packages/sagemath.scm
index 4f23a7b7a0..69a9af0528 100644
--- a/gnu/packages/sagemath.scm
+++ b/gnu/packages/sagemath.scm
@@ -39,6 +39,7 @@  (define-module (gnu packages sagemath)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages boost)
+  #:use-module (gnu packages commencement)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gd)
@@ -690,3 +691,70 @@  (define-public python-sagemath-standard
 combined power through a common, Python-based language or directly via
 interfaces or wrappers.")
     (license license:gpl3)))
+
+(define-public sagemath
+  (package
+    (inherit python-sagemath-standard)
+    (name "sagemath")
+    (arguments
+     (list #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'prepare
+                          (lambda _
+                            (setenv "HOME" (string-append (getenv "TMPDIR") "/home"))
+                            (mkdir-p (getenv "HOME"))
+                            (chdir "src")
+
+                            ;; prevent paging for `sage/repl/ipython_tests.py'
+                            (setenv "TERM" "dumb")
+
+                            ;; for `sage --sh' in `sage/tests/cmdline.py'
+                            (setenv "SHELL" (which "bash"))
+
+                            (for-each
+                             delete-file
+                             '("sage/repl/ipython_kernel/install.py" ; needs threejs
+
+                               ;; works in a container
+                               "sage/typeset/ascii_art.py"
+                               "sage/interfaces/gap_workspace.py"
+                               "sage/misc/sage_ostools.pyx" ; checks for /bin/sh
+                               "sage/repl/ipython_tests.py"
+
+                               ;; downgrade to 5.45 may fix this:
+                               ;; https://github.com/sagemath/sage/issues/33718
+                               ;; https://sourceforge.net/p/maxima/bugs/3964/
+                               "sage/calculus/calculus.py"
+                               "sage/interfaces/maxima_lib.py"
+                               "sage/functions/exp_integral.py" ; correct, but different form
+                               "sage/symbolic/integration/integral.py" ; correct, but exact not floating point
+                               "sage/symbolic/relation.py" ; order in minimum different
+
+                               "sage/repl/ipython_kernel/kernel.py" ; deprecation warnings triggered
+                                                                    ; by `python-pydevd'
+
+                               ;; TODO
+                               "sage/env.py" ; maybe try updating `python-pkgconfig'?
+                               "sage/interacts/test_jupyter.rst" ; maybe `python-ipywidgets' is too old?
+                               ))))
+                        (replace 'check
+                          (lambda* (#:key inputs tests? #:allow-other-keys)
+                            (when tests?
+                              (invoke (search-input-file inputs "/bin/sage")
+                                      "-t"
+                                      "--nthreads"
+                                      (number->string (parallel-job-count))
+                                      ;; the file / directory we want to test
+                                      "sage"))))
+                        (delete 'build)
+                        (replace 'install
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            (let
+                                ((target (string-append #$output "/bin"))
+                                 (source (search-input-file inputs "/bin/sage")))
+                              (mkdir-p target)
+                              (symlink source (string-append target "/sage"))))))))
+    (inputs (list python-sagemath-standard))
+    (native-inputs
+     (list python-sagemath-standard
+           gcc-toolchain
+           gfortran-toolchain))))