Subject: Re: [bug#76270] [PATCH 2/2] gnu: Add sage.

From: Nicolas Goaziou <[email-masked]>
Date: Thu, 13 Feb 2025 17:11:20 +0100

Hello,

Andreas Enge <[email-masked]> writes:

> * gnu/packages/sagemath.scm (sage): New variable.
> * gnu/packages/patches/sage-update-eclib.patch,
> gnu/packages/patches/sage-update-pari-gp.patch: New files.
> * gnu/local.mk (dist_patch_DATA): Register patches.

Thanks for that!

> +        #:phases
> +        #~(modify-phases %standard-phases
> +          (add-after 'unpack 'patch-source
> +            (lambda _
> +              (substitute* (find-files "build/bin")
> +                (("sage-bootstrap-python") "python"))
> +              (substitute* "src/sage/env.py"
> +                (("\"ecl-config\"")
> +                 (string-append "\"" #$ecl "/bin/ecl-config\""))
> +                (("\"ecm\"")
> +                 (string-append "\"" #$gmp-ecm "/bin/ecm\""))
> +                (("\"maxima\"")
> +                 (string-append "\"" #$maxima-ecl "/bin/maxima\""))
> +                (("\"MAXIMA_FAS\"")
> +                 (string-append "\"MAXIMA_FAS\", \"" #$maxima-ecl
> +                                "/lib/maxima/"
> +                                #$(package-version maxima-ecl)
> +                                "/binary-ecl/maxima.fas\""))
> +                (("\"Singular\"")
> +                 (string-append "\"" #$singular "/bin/Singular\""))
> +                (("var\\('SAGE_GAP_COMMAND', None\\)")
> +                 (string-append "var('SAGE_GAP_COMMAND', \""
> +                                #$gap "/bin/gap\")"))
> +                (("join\\(SAGE_LOCAL, \"lib\", \"gap\"\\)")
> +                 (string-append "\"" #$gap "/lib/gap\""))
> +                (("join\\(SAGE_LOCAL, \"share\", \"gap\"\\)")
> +                 (string-append "\"" #$gap "/share/gap\""))
> +                ;; definition of SAGE_VENV, which ends up in kernel.json
> +                (("os.path.abspath\\(sys.prefix\\)")
> +                 (string-append "\"" #$output "\"")))
> +              (substitute* "src/sage/interfaces/gp.py"
> +                (("command=f\"gp")
> +                 (string-append "command=f\"" #$pari-gp "/bin/gp")))
> +              (substitute* "src/bin/sage"
> +                (("exec python3")
> +                 (string-append "exec " #$python "/bin/python3"))
> +                (("mkdir")
> +                 (string-append #$coreutils "/bin/mkdir"))
> +                ((" sed ")
> +                 (string-append " " #$sed "/bin/sed ")))))

I suggest to use, for example,

  (search-input-file (or native-inputs inputs) "bin/sed")

or

  (string-append #$(this-package-input "sed") "/bin/sed")

instead of

  (string-append " " #$sed "/bin/sed ")

so as to not break package transformations.

> +          (add-before 'build 'setup
> +            (lambda _
> +              (setenv "SAGE_NUM_THREADS"
> +                      (number->string (parallel-job-count)))
> +              (invoke "./bootstrap")
> +              (chdir "src")))
> +          (delete 'sanity-check)))) ; does not reflect reality
> +    (synopsis "SageMath computer algebra system")
> +    (description
> +     "SageMath is a mathematics software built on top of many existing
> +packages such as NumPy, SciPy, matplotlib, Sympy, Maxima, GAP, FLINT,
> +R and others. Their combined power may be accessed through a common,
> +Python-based language or directly via interfaces or wrappers.")

Nitpick: matplotlib -> Matplotlib.

> +    ;; Documentation under cc-by-sa3.0, see COPYING.txt in the distribution.
> +    (license license:gpl3)
> +    (home-page "https://www.sagemath.org/")))

Nitpick: the fields in this package definition are in an unusual order.
You may want to reorder them.

FWIW, I also think it makes sense to replace current Maxima with
maxima-ecl.

Regards,
-- 
Nicolas Goaziou