diff mbox series

[bug#56729,RFC,v2,27/29] gnu: Add sagemath-just-build.

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

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

vicvbcun Aug. 8, 2022, 3:46 p.m. UTC
* gnu/packages/sagemath.scm (sagemath-just-build): New variable.
---
 gnu/packages/sagemath.scm | 134 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 134 insertions(+)
diff mbox series

Patch

diff --git a/gnu/packages/sagemath.scm b/gnu/packages/sagemath.scm
index 5a3c893b61..cf48182047 100644
--- a/gnu/packages/sagemath.scm
+++ b/gnu/packages/sagemath.scm
@@ -39,6 +39,8 @@  (define-module (gnu packages sagemath)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages gd)
+  #:use-module (gnu packages graph)
   #:use-module (gnu packages image)
   #:use-module (gnu packages lisp)
   #:use-module (gnu packages maths)
@@ -46,6 +48,7 @@  (define-module (gnu packages sagemath)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages popt)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-build)
   #:use-module (gnu packages python-xyz))
 
 
@@ -772,3 +775,134 @@  (define-public pari-galdata
     (description synopsis)
     ;; see home-page
     (license license:gpl2+)))
+
+;;; This only builds sagemath, using the minimum set of dependencies
+(define-public sagemath-just-build
+  (package
+    (name "sagemath-just-build")
+    (version "9.6")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/sagemath/sage")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0k91l3aid09hy94ps2r6acg22bxgsprxnh1b92hma3z1mn0ii3s1"))))
+    (build-system python-build-system)
+    (arguments
+     (list #:tests? #f ; see sagemath-tests
+           #:use-setuptools? #f
+           #:modules '((guix build python-build-system)
+                       (guix build utils)
+                       (ice-9 ftw))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'prepare-build
+                          (lambda _
+                            (setenv "SAGE_NUM_THREADS"
+                                    (number->string (parallel-job-count)))
+                            (setenv "SAGE_VENV" #$output)
+                            (chdir "src")))
+                        (add-after 'install 'fix-logo-symlinks
+                          ;; these symlinks point to /tmp/guix-build-... so we
+                          ;; need to recreate them
+                          (lambda _
+                            (for-each
+                             (lambda (file)
+                               (let
+                                   ((source (string-append "sage/ext_data/notebook-ipython/" file))
+                                    (target (string-append #$output "/share/jupyter/kernels/sagemath/" file)))
+                                 (delete-file target)
+                                 (copy-file source target)))
+                             '("logo.svg" "logo-64x64.png"))))
+                        (add-after 'install 'delete-nbextensions
+                          ;; broken symlink to threejs-sage which we don't
+                          ;; even package
+                          (lambda _
+                            (delete-file-recursively (string-append #$output "/share/jupyter/nbextensions"))))
+                        (add-after 'install 'install-missing-files
+                          ;; not installed yet for some reason
+                          (lambda _
+                            (copy-recursively "sage/ext_data"
+                                              (string-append #$output "/lib/python3.9/site-packages/sage/ext_data"))
+                            (install-file "sage/libs/gap/sage.gaprc"
+                                          (string-append #$output "/lib/python3.9/site-packages/sage/libs/gap"))
+                            (install-file "sage/interfaces/sage-maxima.lisp"
+                                          (string-append #$output "/lib/python3.9/site-packages/sage/interfaces"))))
+                        (add-after 'install 'install-bin
+                          ;; so far, we have only installed the
+                          ;; library part of sage
+                          (lambda _
+                            (copy-recursively "bin" (string-append #$output "/bin"))
+                            ;; we don't need these
+                            (delete-file (string-append #$output "/bin/sage-env-config.in"))
+                            (delete-file (string-append #$output "/bin/sage-src-env-config.in"))))
+                        (add-after 'install-bin 'wrap-bin
+                          (lambda _
+                            (with-directory-excursion (string-append #$output "/bin")
+                              (for-each
+                               (lambda (file)
+                                 (wrap-program file
+                                   `("PATH" ":" suffix (,(string-append #$output "/bin")
+                                                        #$(file-append sed "/bin")
+                                                        #$(file-append coreutils "/bin")
+                                                        #$(file-append python "/bin")))))
+                               (scandir "."
+                                        ;; select only executables
+                                        (lambda (file)
+                                          (and (eq? 'regular (stat:type (stat file)))
+                                               (access? file X_OK)))))))))))
+    (inputs (list arb
+                  boost
+                  brial
+                  cliquer
+                  ecl
+                  eclib
+                  edge-addition-planarity-suite
+                  flint
+                  gap
+                  gd
+                  giac
+                  givaro
+                  glpk
+                  gmp
+                  gmp-ecm
+                  gsl
+                  iml
+                  lcalc
+                  libbraiding
+                  libhomfly
+                  linbox
+                  m4ri
+                  m4rie
+                  mpc
+                  mpfi
+                  ntl
+                  openblas
+                  pari-gp
+                  python-cypari2
+                  python-gmpy2
+                  python-jinja2
+                  python-jupyter-core
+                  python-memory-allocator
+                  python-numpy
+                  python-pkgconfig
+                  python-pplpy
+                  python-setuptools
+                  python-wheel
+                  rw
+                  singular
+                  symmetrica
+                  zlib
+                  zn-poly))
+    (native-inputs (list pkg-config python-cython))
+    (home-page "https://www.sagemath.org")
+    (synopsis "Python-based computer algebra system")
+    (description
+     "SageMath is a free open-source mathematics software system licensed under the
+GPL. It builds on top of many existing open-source packages: NumPy, SciPy,
+matplotlib, Sympy, Maxima, GAP, FLINT, R and many more. Access their combined
+power through a common, Python-based language or directly via interfaces or
+wrappers.")
+    (license license:gpl3)))