all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: vicvbcun <guix@ikherbers.com>
To: 56729@debbugs.gnu.org
Cc: Andreas Enge <andreas@enge.fr>
Subject: [bug#56729] [RFC PATCH v3 31/32] gnu: Add python-sagemath-standard.
Date: Mon, 29 May 2023 22:38:40 +0200	[thread overview]
Message-ID: <3cad701f74519f5e7562e45d7a938cf2d7d52ae9.1685391448.git.guix@ikherbers.com> (raw)
In-Reply-To: <cover.1658595756.git.guix@ikherbers.com>

* gnu/packages/sagemath.scm (python-sagemath-standard): New variable.
---

Notes:
    sage currently uses python's `sys.prefix' as
    `SAGE_VENV' (i.e. `/gnu/store/…-python-…' instead of
    `/gnu/store/…-sagemath-…'), causing a warning to be printed when running as
    notebook.
    
    `sage' unsets the `SAGE_VENV' environment variable and later tests if it is
    set and if this predictably is not the case uses `sage-venv-config' to
    determine `SAGE_VENV'.  `sage-venv-config' itself uses `sys.prefix'
    unconditionally as `SAGE_VENV'.
    
    Therefore, wrapping `sage' with a the appropriate value for `SAGE_VENV' does
    not work and would need patching.

 gnu/packages/sagemath.scm | 199 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 198 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/sagemath.scm b/gnu/packages/sagemath.scm
index dfe5874ed3..4f23a7b7a0 100644
--- a/gnu/packages/sagemath.scm
+++ b/gnu/packages/sagemath.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2023 vicvbcun <guix@ikherbers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -25,6 +26,7 @@ (define-module (gnu packages sagemath)
   #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system pyproject)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix gexp)
@@ -38,13 +40,22 @@ (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 freedesktop)
+  #:use-module (gnu packages gd)
+  #:use-module (gnu packages graph)
+  #:use-module (gnu packages graphics)
+  #:use-module (gnu packages guile)
   #:use-module (gnu packages image)
   #:use-module (gnu packages lisp)
+  #:use-module (gnu packages m4)
+  #:use-module (gnu packages maths)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages popt)
   #:use-module (gnu packages python)
-  #:use-module (gnu packages python-xyz))
+  #:use-module (gnu packages python-science)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages sqlite))
 
 
 (define-public python-cypari2
@@ -493,3 +504,189 @@ (define-public sagemath-data-polytopes-db
     (synopsis "Lists of 2- and 3-dimensional reflexive polytopes")
     (description synopsis)
     (license #f)))
+
+(define-public python-sagemath-standard
+  (package
+    (name "python-sagemath-standard")
+    (version "10.0")
+    (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
+                "01nfpp3zh43kil7pqyrdvxyawmny0sc656kbg833c2l1y6iwppyc"))))
+    (build-system pyproject-build-system)
+    (arguments
+     (list #:tests? #f               ; tests are run in the `sagemath' package
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'prepare-build
+                 (lambda _
+                   (setenv "SAGE_NUM_THREADS"
+                           (number->string (parallel-job-count)))
+                   (setenv "SAGE_VENV" #$output)
+
+                   (setenv "PYTHONPATH" (string-append (getcwd) "/pkgs/sage-setup"))
+
+                   ;; broken symlink we don't need
+                   (delete-file "pkgs/sage-conf/bin/sage-env-config")
+                   (delete-file "pkgs/sage-conf_pypi/sage_root/configure")
+
+                   ;; Run this before 'ensure-no-mtimes-pre-1980 so that there
+                   ;; are no broken symlinks
+                   (with-directory-excursion "build/pkgs/sagelib"
+                     (let
+                         ((original-path (getenv "PATH")))
+                       (setenv "PATH" (string-append original-path ":../../bin"))
+                       (invoke "sh" "./bootstrap")
+                       (setenv "PATH" original-path)))))
+               (add-before 'build 'cd-to-src
+                 (lambda _
+                   (chdir "pkgs/sagemath-standard")))
+               ;; `setuptools' replaces shebangs that match `#!.*python.*' by
+               ;; the intepreter running it.  Unfortunately this also matches
+               ;; `sage-python'.  But using `sage-python' prevents a weird bug
+               ;; where python's `multiprocessing.resource_tracker' would
+               ;; execute `sage-runtests' instead of `python'.
+               (add-after 'install 'fix-shebangs
+                 (lambda _
+                   (let*
+                       ((bin (string-append #$output "/bin"))
+                        (sage-python (string-append bin "/sage-python")))
+                     (substitute* (find-files bin
+                                              ;; don't touch these to prevent cycles
+                                              ;; sage-num-threads.py -> sage-env -> sage
+                                              ;; sage-venv-config -> sage-python -> sage
+                                              (negate
+                                               (file-name-predicate (string-join '("^sage-coverage$"
+                                                                                   "^sage-num-threads\\.py$"
+                                                                                   "^sage-venv-config$")
+                                                                                 "|"))))
+                       ;; be careful that we don't substitute the newline
+                       ;; character
+                       (("^#!.*python-toolchain[^\n]*") (string-append "#!" sage-python))))))
+               (add-after 'install 'remove-unnecessary-scripts
+                 (lambda _
+                   (for-each
+                    delete-file
+                    (find-files (string-append #$output "/bin") "^sage-rebase"))))
+               (replace 'wrap
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (let*
+                       ((python-path (search-path-as-string->list (getenv "GUIX_PYTHONPATH")))
+                        (python (dirname (search-input-file inputs "/bin/python3")))
+                        (coreutils (dirname (search-input-file inputs "/bin/readlink")))
+                        (sed (dirname (search-input-file inputs "/bin/sed")))
+                        (xdg-open (dirname (search-input-file inputs "/bin/xdg-open")))
+                        (maxima-version #$(package-version (this-package-input "maxima")))
+                        (maxima-fas (search-input-file inputs
+                                                       (string-append "/lib/maxima/"
+                                                                      maxima-version
+                                                                      "/binary-ecl/maxima.fas")))
+                        (combinatorial-design (search-input-directory inputs "/share/combinatorial_designs"))
+                        (conway-polynomials (search-input-directory inputs "/share/conway_polynomials"))
+                        (ellcurve (search-input-directory inputs "/share/ellcurves"))
+                        (cremona-mini (search-input-directory inputs "/share/cremona"))
+                        (graphs (search-input-directory inputs "/share/graphs"))
+                        (polytope (search-input-directory inputs "/share/reflexive_polytopes"))
+                        (gap-lib (search-input-directory inputs "/lib/gap"))
+                        (gap-share (search-input-directory inputs "/share/gap")))
+                     ;; wrap everything possible, all things with shebang
+                     ;; #!*/sage-* are still covered, as sage-* itself will be
+                     ;; wrapped
+                     (for-each
+                      (lambda (file)
+                        (false-if-exception
+                         (wrap-script file
+                           `("GUIX_PYTHONPATH" = ,python-path)
+                           `("PATH" prefix (,(string-append #$output "/bin") ,coreutils ,python ,sed ,xdg-open))
+                           `("MAXIMA_FAS" = (,maxima-fas))
+                           `("COMBINATORIAL_DESIGN_DATA_DIR" = (,combinatorial-design))
+                           `("CONWAY_POLYNOMIALS_DATA_DIR" = (,conway-polynomials))
+                           `("ELLCURVE_DATA_DIR" = (,ellcurve))
+                           `("CREMONA_MINI_DATA_DIR" = (,cremona-mini))
+                           `("GRAPHS_DATA_DIR" = (,graphs))
+                           `("POLYTOPE_DATA_DIR" = (,polytope))
+                           `("GAP_LIB_DIR" = (,gap-lib))
+                           `("GAP_SHARE_DIR" = (,gap-share)))))
+                      (find-files (string-append #$output "/bin")))))))))
+    (inputs (list arb
+                  boost
+                  brial
+                  cliquer
+                  coreutils
+                  edge-addition-planarity-suite
+                  gd
+                  givaro
+                  glpk
+                  gmp
+                  guile-3.0             ; for wrap-script
+                  iml
+                  libbraiding
+                  libhomfly
+                  linbox
+                  m4ri
+                  m4rie
+                  mpc
+                  mpfi
+                  python-cypari2
+                  python-gmpy2
+                  python-jinja2
+                  python-jupyter-core
+                  python-memory-allocator
+                  python-numpy
+                  python-pplpy
+                  rw
+                  sagemath-data-combinatorial-designs
+                  sagemath-data-conway-polynomials
+                  sagemath-data-elliptic-curves
+                  sagemath-data-graphs
+                  sagemath-data-polytopes-db
+                  sed
+                  symmetrica
+                  xdg-utils
+                  zlib))
+    (native-inputs (list m4 pkg-config python-cython))
+    (propagated-inputs (list cddlib
+                             ecl        ; also buildtime
+                             eclib      ; also buildtime
+                             flint      ; also buildtime
+                             gap        ; also buildtime
+                             gfan
+                             giac       ; also buildtime
+                             gmp-ecm    ; also buildtime
+                             gsl        ; also buildtime
+                             lcalc      ; also buildtime
+                             maxima
+                             mpfr
+                             nauty
+                             ntl        ; also buildtime
+                             openblas   ; also buildtime
+                             palp
+                             pari-gp    ; also buildtime
+                             pkg-config ; also buildtime (native)
+                             python-fpylll
+                             python-ipython
+                             python-ipywidgets
+                             python-lrcalc
+                             python-networkx
+                             python-pkgconfig
+                             python-primecountpy
+                             python-scipy
+                             python-sympy
+                             singular   ; also buildtime
+                             sqlite
+                             sympow
+                             tachyon))
+    (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)))
-- 
2.40.1





  parent reply	other threads:[~2023-05-29 20:43 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-23 19:59 [bug#56729] [RFC PATCH 00/10] Add sagemath vicvbcun
2022-07-23 20:51 ` [bug#56729] [RFC PATCH 01/10] gnu: edge-addition-planarity-suite: Update to 3.0.2.0 vicvbcun
2022-07-23 20:51 ` [bug#56729] [RFC PATCH 02/10] gnu: gap: Update to 4.11.1 vicvbcun
2022-08-03  9:25   ` [bug#56729] [RFC PATCH v2] " vicvbcun
2022-07-23 20:51 ` [bug#56729] [RFC PATCH 03/10] gnu: Remove ecl-16 vicvbcun
2022-07-23 20:51 ` [bug#56729] [RFC PATCH 04/10] gnu: cliquer: Update to 1.22 vicvbcun
2022-07-23 20:51 ` [bug#56729] [RFC PATCH 05/10] gnu: lcalc: Update to 2.0.5 vicvbcun
2022-07-23 20:52 ` [bug#56729] [RFC PATCH 06/10] gnu: ntl: Update to 11.5.1 vicvbcun
2022-07-23 20:52 ` [bug#56729] [RFC PATCH 07/10] gnu: eclib: Update to 20220621 vicvbcun
2022-07-23 20:52 ` [bug#56729] [RFC PATCH 08/10] gnu: Add python-memory-allocator vicvbcun
2022-07-23 20:52 ` [bug#56729] [RFC PATCH 09/10] gnu: Add python-pplpy vicvbcun
2022-07-23 20:52 ` [bug#56729] [RFC PATCH 10/10] gnu: Add sagemath vicvbcun
2022-08-01  9:24 ` [bug#56729] [RFC PATCH 00/10] " Ludovic Courtès
2022-08-03  9:21   ` guix
2022-08-11 18:05     ` Andreas Enge
2022-08-08 14:40   ` Andreas Enge
2022-08-08 16:20     ` guix
2022-08-09 10:47       ` Andreas Enge
2022-08-09 10:55         ` ( via Guix-patches via
2022-08-09 12:19         ` Andreas Enge
2022-08-09 13:40         ` vicvbcun
2022-08-12  8:50           ` Andreas Enge
2022-08-12  8:58           ` Andreas Enge
2022-08-09 21:32         ` Maxime Devos
2022-08-10  8:26           ` Andreas Enge
2022-08-10  9:03       ` Andreas Enge
2022-08-06  1:28 ` vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 00/29] " vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 01/29] gnu: Remove ecl-16 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 02/29] gnu: edge-addition-planarity-suite: Update to 3.0.2.0 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 03/29] gnu: gap: Update to 4.11.1 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 04/29] gnu: cliquer: Update to 1.22 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 05/29] gnu: lcalc: Update to 2.0.5 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 06/29] gnu: ntl: Update to 11.5.1 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 07/29] gnu: eclib: Update to 20220621 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 08/29] gnu: lrcalc: Update to 2.1 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 09/29] gnu: maxima: Update to 5.46.0 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 10/29] gnu: python-sympy: Update to 1.10.1 vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 11/29] gnu: cddlib: Update to 0.94m vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 12/29] gnu: Add python-memory-allocator vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 13/29] gnu: Add python-pplpy vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 14/29] gnu: Add primecount vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 15/29] gnu: Add python-primecountpy vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 16/29] gnu: Add python-lrcalc vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 17/29] gnu: Add palp vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 18/29] gnu: Add gfan vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 19/29] gnu: Add flintqs vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 20/29] gnu: Add tachyon vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 21/29] gnu: Add sagemath-data-conway-polynomials vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 22/29] gnu: Add sagemath-data-elliptic-curves vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 23/29] gnu: Add sagemath-data-combinatorial-designs vicvbcun
2022-08-08 15:45 ` [bug#56729] [RFC PATCH v2 24/29] gnu: Add sagemath-data-graphs vicvbcun
2022-08-08 15:46 ` [bug#56729] [RFC PATCH v2 25/29] gnu: Add sagemath-data-poytopes-db vicvbcun
2022-08-08 15:46 ` [bug#56729] [RFC PATCH v2 26/29] gnu: Add pari-galdata vicvbcun
2022-08-08 15:46 ` [bug#56729] [RFC PATCH v2 27/29] gnu: Add sagemath-just-build vicvbcun
2022-08-08 15:46 ` [bug#56729] [RFC PATCH v2 28/29] gnu: Add sagemath-with-dependencies vicvbcun
2022-08-08 15:46 ` [bug#56729] [RFC PATCH v2 29/29] gnu: Add sagemath-tests vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 00/32] Add sagemath vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 01/32] gnu: python-cysignals: Update to 1.11.2 vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 02/32] gnu: cliquer: Update to 1.22 vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 03/32] gnu: Add python-memory-allocator vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 04/32] gnu: python-gmpy2: Move to (gnu packages multiprecision) vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 05/32] gnu: Add python-pplpy vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 06/32] gnu: Add primecount vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 07/32] gnu: Add python-primecountpy vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 08/32] gnu: Add python-lrcalc vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 09/32] gnu: Add palp vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 10/32] gnu: Add gfan vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 11/32] gnu: Add sympow vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 12/32] download: Add SageMath mirrors vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 13/32] gnu: Add sagemath-data-combinatorial-designs vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 14/32] gnu: Add sagemath-data-conway-polynomials vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 15/32] gnu: Add sagemath-data-elliptic-curves vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 16/32] gnu: Add sagemath-data-graphs vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 17/32] gnu: Add sagemath-data-polytopes-db vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 18/32] gnu: pari-gp: Use G-expression vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 19/32] gnu: pari-gp: Install galdata vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 20/32] gnu: gap: Build reproducibly vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 21/32] gnu: gap: Compile atlasrep package vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 22/32] gnu: gap: Remove leftover source and build files vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 23/32] gnu: maxima: Build with ecl vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 24/32] gnu: maxima: Install maxima.fas vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 25/32] gnu: maxima: Apply matrix exponentiation patch vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 26/32] gnu: Add tachyon vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 27/32] gnu: singular: Update to 4.3.2 vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 28/32] gnu: singular: Don't compress info file vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 29/32] gnu: eclib: Update to 20230424 vicvbcun
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 30/32] gnu: python-pythran: Update to 0.13.1 vicvbcun
2023-05-29 20:38 ` vicvbcun [this message]
2023-05-29 20:38 ` [bug#56729] [RFC PATCH v3 32/32] gnu: Add sagemath vicvbcun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3cad701f74519f5e7562e45d7a938cf2d7d52ae9.1685391448.git.guix@ikherbers.com \
    --to=guix@ikherbers.com \
    --cc=56729@debbugs.gnu.org \
    --cc=andreas@enge.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.