Github messages for voidlinux
 help / color / mirror / Atom feed
From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [WIP] New package: sagemath-9.5.beta7
Date: Mon, 29 Nov 2021 00:21:11 +0100	[thread overview]
Message-ID: <20211128232111.p_ctdCm6hGUi3PApmvtadLDE-g5nNSNtYic4AOxWk1s@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-34030@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 629 bytes --]

There is an updated pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages sagemath
https://github.com/void-linux/void-packages/pull/34030

[WIP] New package: sagemath-9.5.beta7
This is WIP, so I can get feedback.

Right now there is some issue with relocation, since `/builddir/sage-9.5.beta5` leaks all over the place. In particular starting sage complains this directory is missing... but it seems to work.

I'm unsure if the package name should be `sage` or `sagemath`.

A patch file from https://github.com/void-linux/void-packages/pull/34030.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-sagemath-34030.patch --]
[-- Type: text/x-diff, Size: 63519 bytes --]

From 0e548f6e328e538757467d2b98ca65614537cca4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 27 Nov 2021 19:38:48 -0300
Subject: [PATCH 01/10] maxima: add a subpkg maxima-ecl needed for sagemath

 - Added a build option 'ecl' (enabled by default)
 - The ecl binary and library will be in a subpkg maxima-ecl so this
   should not affect current users of maxima
 - new patches:
   - a0d7a43...: build a FASL library for ECL (this is merged upstream)
   - handle-multiple-ldflags.patch: otherwise compilation with multiple
     options in LDFLAGS fails (taken from debian)
   - matrixexp.patch: fixes an error in matrix exponentiation (taken
     from debian, this originates in sagemath)

A weak point is that the library maxima.fas is installed in
/usr/lib/ecl-${ecl_version} which is where ecl looks for them, but this
doesn't seem right.

Maybe an alternative would be to have the ecl package ship a symlink at
/usr/lib/ecl pointing to the versioned directory, then have the
maxima-ecl package place its library in the non-versioned directory.
---
 srcpkgs/maxima-ecl                            |  1 +
 ...a43e5234305bd6f1de5909d4ce5d7e1ea864.patch | 24 +++++++++++
 .../patches/handle-multiple-ldflags.patch     | 43 +++++++++++++++++++
 srcpkgs/maxima/patches/matrixexp.patch        | 23 ++++++++++
 srcpkgs/maxima/template                       | 34 ++++++++++++---
 5 files changed, 120 insertions(+), 5 deletions(-)
 create mode 120000 srcpkgs/maxima-ecl
 create mode 100644 srcpkgs/maxima/patches/a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864.patch
 create mode 100644 srcpkgs/maxima/patches/handle-multiple-ldflags.patch
 create mode 100644 srcpkgs/maxima/patches/matrixexp.patch

diff --git a/srcpkgs/maxima-ecl b/srcpkgs/maxima-ecl
new file mode 120000
index 000000000000..b8b0e8240fa4
--- /dev/null
+++ b/srcpkgs/maxima-ecl
@@ -0,0 +1 @@
+maxima
\ No newline at end of file
diff --git a/srcpkgs/maxima/patches/a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864.patch b/srcpkgs/maxima/patches/a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864.patch
new file mode 100644
index 000000000000..e1ac1e5f6086
--- /dev/null
+++ b/srcpkgs/maxima/patches/a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864.patch
@@ -0,0 +1,24 @@
+commit a0d7a43e5234305bd6f1de5909d4ce5d7e1ea864
+Author: Robert Dodier <robert_dodier@users.sourceforge.net>
+Date:   Mon Oct 11 22:40:13 2021 -0700
+
+    Apply patch #80: "Build a FASL library, needed by SageMath"
+    
+    This modifies maxima.system for ECL only.
+
+diff --git a/src/maxima.system b/src/maxima.system
+index d954bc2b9..525fb778e 100644
+--- a/src/maxima.system
++++ b/src/maxima.system
+@@ -75,6 +75,11 @@
+ 			     ;; Convert dir/foo.fas to dir/foo.o
+ 			     (make-pathname :type "o" :defaults p))
+ 			 files)))
++	(c::build-fasl "binary-ecl/maxima" :lisp-files obj
++			  :ld-flags
++			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
++							      (find-package "MAXIMA")))))
++			    (if (and x (not (string= x ""))) (list x))))
+ 	(c::build-program "binary-ecl/maxima" :lisp-files obj
+ 			  :ld-flags
+ 			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
diff --git a/srcpkgs/maxima/patches/handle-multiple-ldflags.patch b/srcpkgs/maxima/patches/handle-multiple-ldflags.patch
new file mode 100644
index 000000000000..799fc15f9185
--- /dev/null
+++ b/srcpkgs/maxima/patches/handle-multiple-ldflags.patch
@@ -0,0 +1,43 @@
+Description: Handle multiple LDFLAGS
+ Without this patch, building with LDFLAGS containing more than one flag results 
+ in flags being dropped.
+Author: Graham Inggs <ginggs@debian.org>
+Bug-Debian: http://bugs.debian.org/847925
+
+--- a/src/maxima.system
++++ b/src/maxima.system
+@@ -58,6 +58,19 @@
+     (and (apply #'compile-file file :output-file object-output args)
+ 	 (c:build-fasl output :lisp-files (list object-output)))))
+ 
++(defun split-string (string &key (item #\space) (test #'char=))
++  ;; Splits the string into substrings at spaces.
++  (let ((len (length string))
++	(index 0) result)
++    (dotimes (i len
++		(progn (unless (= index len)
++			 (push (subseq string index) result))
++		       (reverse result)))
++      (when (funcall test (char string i) item)
++	(unless (= index i);; two spaces in a row
++	  (push (subseq string index i) result))
++	(setf index (1+ i))))))
++
+ #+ecl
+ (defun build-maxima-lib ()
+   (labels ((list-all-objects (module)
+@@ -79,12 +92,12 @@
+ 			  :ld-flags
+ 			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
+ 							      (find-package "MAXIMA")))))
+-			    (if (and x (not (string= x ""))) (list x))))
++			    (if (and x (not (string= x ""))) (split-string x))))
+ 	(c::build-program "binary-ecl/maxima" :lisp-files obj
+ 			  :ld-flags
+ 			  (let ((x (symbol-value (find-symbol "*AUTOCONF-LD-FLAGS*"
+ 							      (find-package "MAXIMA")))))
+-			    (if (and x (not (string= x ""))) (list x)))
++			    (if (and x (not (string= x ""))) (split-string x)))
+ 			  :epilogue-code '(progn (cl-user::run)))))))
+ 
+ (defun maxima-binary-pathname ()
diff --git a/srcpkgs/maxima/patches/matrixexp.patch b/srcpkgs/maxima/patches/matrixexp.patch
new file mode 100644
index 000000000000..7cbd9ccac089
--- /dev/null
+++ b/srcpkgs/maxima/patches/matrixexp.patch
@@ -0,0 +1,23 @@
+Description: Fix error in matrix exponentiation
+ This patch was written by SageMath but not yet committed into Maxima releases.
+ However, it is needed for SageMath to work correctly:
+ .
+ https://git.sagemath.org/sage.git/tree/build/pkgs/maxima/patches/matrixexp.patch
+Author: Peter Bruin <P.J.Bruin@math.leidenuniv.nl>
+Bug-Sage: http://trac.sagemath.org/ticket/13973
+Bug: https://sourceforge.net/p/maxima/bugs/2596/
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/share/linearalgebra/matrixexp.lisp
++++ b/share/linearalgebra/matrixexp.lisp
+@@ -138,8 +138,8 @@
+ 	   (print `(ratvars = ,$ratvars gcd = '$gcd algebraic = ,$algebraic))
+ 	   (print `(ratfac = ,$ratfac))
+ 	   (merror "Unable to find the spectrum")))
+-   
+-    (setq res ($fullratsimp (ncpower (sub (mult z ($ident n)) mat) -1) z))
++
++    (setq res ($fullratsimp ($invert_by_lu (sub (mult z ($ident n)) mat) '$crering) z))
+     (setq m (length sp))
+     (dotimes (i m)
+       (setq zi (nth i sp))
diff --git a/srcpkgs/maxima/template b/srcpkgs/maxima/template
index 3a95e3706447..798b4f9f00de 100644
--- a/srcpkgs/maxima/template
+++ b/srcpkgs/maxima/template
@@ -1,11 +1,11 @@
 # Template file for 'maxima'
 pkgname=maxima
 version=5.45.1
-revision=1
+revision=2
 build_style=gnu-configure
-configure_args="$(vopt_enable clisp) $(vopt_enable sbcl sbcl-exec)"
+configure_args="$(vopt_enable clisp) $(vopt_enable sbcl sbcl-exec) $(vopt_enable ecl)"
 hostmakedepends="python3 perl emacs texinfo"
-makedepends="$(vopt_if clisp clisp) $(vopt_if sbcl sbcl)"
+makedepends="$(vopt_if clisp clisp) $(vopt_if sbcl sbcl) $(vopt_if ecl ecl)"
 depends="$(vopt_if clisp clisp) rlwrap"
 checkdepends="gnuplot"
 short_desc="Computer Algebra System"
@@ -17,10 +17,11 @@ checksum=fe9016276970bef214a1a244348558644514d7fdfaa4fc8b9d0e87afcbb4e7dc
 
 nostrip=yes
 nopie=yes
-build_options="clisp sbcl"
+build_options="clisp sbcl ecl"
 desc_option_clisp="Build with CLISP"
 desc_option_sbcl="Build with SBCL"
-build_options_default="sbcl"
+desc_option_ecl="Build with ECL"
+build_options_default="sbcl ecl"
 vopt_conflict clisp sbcl
 
 post_install() {
@@ -66,3 +67,26 @@ xmaxima_package() {
 			${PKGDESTDIR}/usr/share/pixmaps/maxima
 	}
 }
+
+subpackages="maxima-src maxima-emacs xmaxima"
+
+if [ "$build_option_ecl" ]; then
+	subpackages+=" maxima-ecl"
+fi
+
+maxima-ecl_package() {
+	short_desc+=" - compiled with ECL"
+	depends="${sourcepkg}-${version}_${revision}"
+	pkg_install() {
+		# this is /usr/lib/ecl-${ecl_version}
+		# ideally we would just place it in /usr/lib/ecl but this
+		# doesn't just work
+		# Maybe we can have the ecl package ship a symlink:
+		#     /usr/lib/ecl -> /usr/lib/ecl-${ecl_version}
+		# and have this package just install in /usr/lib/ecl
+		ECLDIR=$(ecl -eval "(princ (SI:GET-LIBRARY-PATHNAME))" -eval "(quit)")
+		vmkdir $ECLDIR
+		vinstall src/binary-ecl/maxima.fas 755 $ECLDIR
+		vmove usr/lib/maxima/${version}/binary-ecl
+	}
+}

From 64d2d52ce7735a14a90d11109a4dbe995012a86e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 11 Nov 2021 10:36:03 -0300
Subject: [PATCH 02/10] New package: sage-9.5.beta5

---
 srcpkgs/sage/template | 74 +++++++++++++++++++++++++++++++++++++++++++
 srcpkgs/sage/update   |  3 ++
 2 files changed, 77 insertions(+)
 create mode 100644 srcpkgs/sage/template
 create mode 100644 srcpkgs/sage/update

diff --git a/srcpkgs/sage/template b/srcpkgs/sage/template
new file mode 100644
index 000000000000..2ef437238cb5
--- /dev/null
+++ b/srcpkgs/sage/template
@@ -0,0 +1,74 @@
+# Template file for 'sage'
+pkgname=sage
+version=9.5.beta5
+revision=1
+build_style=configure
+configure_args=--prefix=/usr/lib/sage-${version}
+make_check_target=ptest
+short_desc="Open source mathematics software"
+maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
+license="GPL-3.0-or-later"
+homepage="http://sagemath.org/"
+distfiles="http://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
+checksum=3b78ee848450d6881902bf68f4f3af17e1647e72c51e5fcdcb412c938ecbce57
+
+case ${version} in
+	# url for devel is different
+	*.beta*|*.rc*)
+		distfiles=${distfiles/sage\/src/sage\/devel}
+		;;
+esac
+
+# first we try to build native; we'll worry about cross later
+# besides, some dependencies are nocross
+nocross=yes
+
+# for now, to make install faster
+nostrip=yes
+
+# don't rewrite python shebang as sage uses its own python (for now)
+_no_python_shebang=yes
+
+do_install() {
+	vcopy /usr/lib/sage-${version} usr/lib/
+	vmkdir usr/bin
+	ln -s /usr/lib/sage-${version}/bin/sage ${DESTDIR}/usr/bin/
+}
+
+### copied from sage-deps, to keep in sync
+
+# hard dependencies
+makedepends+=" gcc make m4 perl binutils git tar libgomp-devel"
+
+# recommended dependencies
+makedepends+=" gcc-fortran openssl-devel"
+
+# bootstrap dependencies
+makedepends+=" automake gettext gettext-devel"
+
+# other host dependencies
+makedepends+=" cmake curl git ninja pandoc patch pkg-config python3 tox"
+
+# already in void
+makedepends+="
+ CoinMP-devel R arb-devel boost-devel bzip2-devel ecl eclib-devel
+ ecm-devel flintlib-devel freetype-devel gc-devel gd-devel giac-devel
+ glpk-devel gmp-devel gmpxx-devel gp2c graphviz gsl-devel isl-devel
+ libatomic_ops-devel libcurl-devel libffi-devel libmpc-devel
+ libpng-devel libxml2-devel mpfr-devel ncurses-devel openblas-devel
+ pari-devel pari-elldata-small pari-galdata pari-galpol-small
+ pari-seadata pcre-devel perl-File-Slurp perl-JSON perl-Term-ReadKey
+ perl-Term-ReadLine-Gnu perl-XML-LibXML perl-XML-LibXSLT
+ perl-XML-Writer ppl-devel python3-devel readline-devel sqlite-devel
+ zeromq-devel zlib-devel
+ FlintQS SuiteSparse-devel cddlib-devel fflas-ffpack fplll-devel gf2x-devel
+ givaro-devel igraph-devel iml-devel lcalc-devel linbox-devel
+ m4ri-devel m4rie-devel mpfi-devel ntl-devel perl-SVG rankwidth-devel
+ singular sympow zn_poly symmetrica-devel planarity-devel qhull libqhull-devel
+"
+
+# TODO: standard
+# brial cliquer gfan libbraiding libhomfly lrcalc nauty palp tachyon
+
+# TODO: optional
+# 4ti2 coxeter3 libnauty libsemigroups lrslib perl_mongodb
diff --git a/srcpkgs/sage/update b/srcpkgs/sage/update
new file mode 100644
index 000000000000..f797813dcde6
--- /dev/null
+++ b/srcpkgs/sage/update
@@ -0,0 +1,3 @@
+# for now, check both stable and devel releases
+site="http://mirrors.mit.edu/sage/src/
+http://mirrors.mit.edu/sage/devel/"

From c5b3a150ee792f28baa86a1b216328e44d21d4cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 13 Nov 2021 00:08:27 -0300
Subject: [PATCH 03/10] sagemath: update to sage-9.5.beta6

Also:
 - rename pkg from sage to sagemath
 - now it will build sage in-place at /usr/lib/sage-$version
 - the resulting pkg contains a lot of useless stuff that comes with the
   distribution; we'll have to clean up. E.g. SAGE_ROOT/upstream is
   definitely unnecessary (1.2G); possibly SAGE_ROOT/pkgs or at least
   SAGE_ROOT/pkgs/sagemath-standard/build (2.6G).
---
 srcpkgs/{sage => sagemath}/template | 46 +++++++++++++++++++++--------
 srcpkgs/{sage => sagemath}/update   |  1 +
 2 files changed, 35 insertions(+), 12 deletions(-)
 rename srcpkgs/{sage => sagemath}/template (67%)
 rename srcpkgs/{sage => sagemath}/update (90%)

diff --git a/srcpkgs/sage/template b/srcpkgs/sagemath/template
similarity index 67%
rename from srcpkgs/sage/template
rename to srcpkgs/sagemath/template
index 2ef437238cb5..fa5189ad259e 100644
--- a/srcpkgs/sage/template
+++ b/srcpkgs/sagemath/template
@@ -1,41 +1,63 @@
-# Template file for 'sage'
-pkgname=sage
-version=9.5.beta5
+# Template file for 'sagemath'
+pkgname=sagemath
+version=9.5.beta6
 revision=1
+wrksrc=sage-$version
 build_style=configure
-configure_args=--prefix=/usr/lib/sage-${version}
+configure_args="--enable-build-as-root"
 make_check_target=ptest
+# for now skip building docs
+make_build_target=build
 short_desc="Open source mathematics software"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="http://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
-checksum=3b78ee848450d6881902bf68f4f3af17e1647e72c51e5fcdcb412c938ecbce57
+checksum=7bae8cbb4db73147bd698261497102524bfadeb71ca66b1c68e96827bd5a8975
+
+# path where sage will be installed
+_SAGE_ROOT=/usr/lib/sage-${version}
 
 case ${version} in
 	# url for devel is different
-	*.beta*|*.rc*)
-		distfiles=${distfiles/sage\/src/sage\/devel}
-		;;
+	*.beta*|*.rc*) distfiles=${distfiles/sage\/src/sage\/devel} ;;
 esac
 
-# first we try to build native; we'll worry about cross later
-# besides, some dependencies are nocross
+# for now, skip check in ci, since we still have a few tests failing
+make_check=ci-skip
+
+# for now, just build native; we'll worry about cross later
+# besides, some dependencies are nocross (e.g. ntl)
 nocross=yes
 
 # for now, to make install faster
 nostrip=yes
 
+# don't shlib_provide anything
+noshlibprovides=yes
+
 # don't rewrite python shebang as sage uses its own python (for now)
 _no_python_shebang=yes
 
+post_extract() {
+	# sage wants to be built in place so let $wrksrc be a symlink
+	mv -T $wrksrc $_SAGE_ROOT
+	ln -sfT $_SAGE_ROOT $wrksrc
+}
+
+do_clean() {
+	# undo post_extract()
+	rm $wrksrc
+	mv $_SAGE_ROOT $wrksrc
+}
+
 do_install() {
 	vcopy /usr/lib/sage-${version} usr/lib/
 	vmkdir usr/bin
-	ln -s /usr/lib/sage-${version}/bin/sage ${DESTDIR}/usr/bin/
+	ln -s $_SAGE_ROOT/sage ${DESTDIR}/usr/bin/
 }
 
-### copied from sage-deps, to keep in sync
+### copied from sage-deps, to be kept in sync
 
 # hard dependencies
 makedepends+=" gcc make m4 perl binutils git tar libgomp-devel"
diff --git a/srcpkgs/sage/update b/srcpkgs/sagemath/update
similarity index 90%
rename from srcpkgs/sage/update
rename to srcpkgs/sagemath/update
index f797813dcde6..c33aba4e6df2 100644
--- a/srcpkgs/sage/update
+++ b/srcpkgs/sagemath/update
@@ -1,3 +1,4 @@
+pkgname=sage
 # for now, check both stable and devel releases
 site="http://mirrors.mit.edu/sage/src/
 http://mirrors.mit.edu/sage/devel/"

From 33be922b813689246a067d155440ca3f20ba7613 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 13 Nov 2021 07:40:55 -0300
Subject: [PATCH 04/10] sagemath: revbump for changes

 - include patch fixing build of pyzmq on musl
 - add gengetopts and texinfo to makedepends
 - first attempt at cleanup: remove upstream sources and build artifacts
---
 srcpkgs/sagemath/patches/fix-pyzmq-musl.patch | 15 +++++++++++++++
 srcpkgs/sagemath/template                     |  9 +++++++--
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/fix-pyzmq-musl.patch

diff --git a/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch b/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch
new file mode 100644
index 000000000000..9190830d835e
--- /dev/null
+++ b/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch
@@ -0,0 +1,15 @@
+diff --git a/build/pkgs/pyzmq/spkg-install.in b/build/pkgs/pyzmq/spkg-install.in
+index 0ce404ee5a..b7260c6d27 100644
+--- a/build/pkgs/pyzmq/spkg-install.in
++++ b/build/pkgs/pyzmq/spkg-install.in
+@@ -1,6 +1,9 @@
+ # Since we use environment vars we have to generate setup.cfg
+ 
+-echo "[build_ext]" > src/setup.cfg
++echo "[global]" > src/setup.cfg
++echo "skip_check_zmq = True" >> src/setup.cfg
++
++echo "[build_ext]" >> src/setup.cfg
+ 
+ # (I tried putting quotes around $SAGE_LOCAL to allow for spaces in
+ # the path---which is never used but is a good habit to support---but
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index fa5189ad259e..56166cd44272 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
 version=9.5.beta6
-revision=1
+revision=2
 wrksrc=sage-$version
 build_style=configure
 configure_args="--enable-build-as-root"
@@ -52,7 +52,11 @@ do_clean() {
 }
 
 do_install() {
-	vcopy /usr/lib/sage-${version} usr/lib/
+	vcopy $_SAGE_ROOT usr/lib/
+	# cleanup: upstream sources and build artifacts
+	rm -rf ${DESTDIR}/$_SAGE_ROOT/upstream
+	rm -rf ${DESTDIR}/$_SAGE_ROOT/pkgs/*/build
+	# symlink main binary
 	vmkdir usr/bin
 	ln -s $_SAGE_ROOT/sage ${DESTDIR}/usr/bin/
 }
@@ -87,6 +91,7 @@ makedepends+="
  givaro-devel igraph-devel iml-devel lcalc-devel linbox-devel
  m4ri-devel m4rie-devel mpfi-devel ntl-devel perl-SVG rankwidth-devel
  singular sympow zn_poly symmetrica-devel planarity-devel qhull libqhull-devel
+ gengetopt texinfo
 "
 
 # TODO: standard

From 83deef4c801299951748469e63ff807b104c98ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 14 Nov 2021 18:23:29 -0300
Subject: [PATCH 05/10] sagemath: revbump to 9.5.beta6_3 for changes

 - add depends needed for runtime and for testing
 - add python_version=3
 - disable skipping 03-rewrite-python-shebang as it seems to be harmless
   after adding python_version=3
 - fix cleaning up of $wrksrc and $_SAGE_ROOT
 - use sage-${version}_${revision} for the binary symlink; this way it
   won't override whatever sage is installed in the system so I can test
   on a live system.
---
 srcpkgs/sagemath/template | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 56166cd44272..cfe97e039974 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,19 +1,24 @@
 # Template file for 'sagemath'
 pkgname=sagemath
 version=9.5.beta6
-revision=2
+revision=3
 wrksrc=sage-$version
 build_style=configure
 configure_args="--enable-build-as-root"
 make_check_target=ptest
 # for now skip building docs
 make_build_target=build
+depends="giac git FlintQS zn_poly sympow
+ pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small
+ flintlib-devel gsl-devel ntl-devel eclib-devel pari-devel mpfr-devel
+ m4ri-devel gd-devel libpng-devel fflas-ffpack pkg-config gcc-fortran"
 short_desc="Open source mathematics software"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="http://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
 checksum=7bae8cbb4db73147bd698261497102524bfadeb71ca66b1c68e96827bd5a8975
+python_version=3
 
 # path where sage will be installed
 _SAGE_ROOT=/usr/lib/sage-${version}
@@ -37,7 +42,8 @@ nostrip=yes
 noshlibprovides=yes
 
 # don't rewrite python shebang as sage uses its own python (for now)
-_no_python_shebang=yes
+# after python_version=3, this seems harmless... strange...
+#_no_python_shebang=yes
 
 post_extract() {
 	# sage wants to be built in place so let $wrksrc be a symlink
@@ -46,9 +52,12 @@ post_extract() {
 }
 
 do_clean() {
-	# undo post_extract()
-	rm $wrksrc
-	mv $_SAGE_ROOT $wrksrc
+	rm -rf $wrksrc $_SAGE_ROOT
+}
+
+post_build() {
+	# install pytest for more tests
+	./sage -i pytest
 }
 
 do_install() {
@@ -58,7 +67,9 @@ do_install() {
 	rm -rf ${DESTDIR}/$_SAGE_ROOT/pkgs/*/build
 	# symlink main binary
 	vmkdir usr/bin
-	ln -s $_SAGE_ROOT/sage ${DESTDIR}/usr/bin/
+	# for now use sage-${version}_${revision} so it doesn't override
+	# other sage installed in the system
+	ln -sfT $_SAGE_ROOT/sage ${DESTDIR}/usr/bin/sage-${version}_${revision}
 }
 
 ### copied from sage-deps, to be kept in sync

From 752a1e1a1cf470fcbf64f37426d7a4908133f225 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sat, 20 Nov 2021 19:01:21 -0300
Subject: [PATCH 06/10] sagemath: update to 9.5.beta7.

---
 srcpkgs/sagemath/template | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index cfe97e039974..3f9a3e9e077f 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -1,7 +1,7 @@
 # Template file for 'sagemath'
 pkgname=sagemath
-version=9.5.beta6
-revision=3
+version=9.5.beta7
+revision=1
 wrksrc=sage-$version
 build_style=configure
 configure_args="--enable-build-as-root"
@@ -17,7 +17,7 @@ maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
 homepage="http://sagemath.org/"
 distfiles="http://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
-checksum=7bae8cbb4db73147bd698261497102524bfadeb71ca66b1c68e96827bd5a8975
+checksum=b81e1fe22d1b990bf1230260241ead016470da1f2f7b260f562d50f74c2904c7
 python_version=3
 
 # path where sage will be installed

From b2aa4d0f446cc5a257d8d0b55cb82607f38b05a6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 22 Nov 2021 10:23:03 -0300
Subject: [PATCH 07/10] sagemath: add more dependencies

Also:
 - add patches so more doctests pass
 - add do_check() to skip building docs
 - use https for distfiles
---
 ...08fd9d56d022ed28592f93f07ec8dce530ef.patch |  49 ++++++
 ...b99e0270f80cf03b80418372f45274f46051.patch | 163 ++++++++++++++++++
 ...a86908daf60b25e66e6a189c51ada7e0a732.patch |  25 +++
 .../patches/skip-optional-dochtml.patch       |  13 ++
 srcpkgs/sagemath/template                     |  15 +-
 5 files changed, 260 insertions(+), 5 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
 create mode 100644 srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch
 create mode 100644 srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
 create mode 100644 srcpkgs/sagemath/patches/skip-optional-dochtml.patch

diff --git a/srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch b/srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
new file mode 100644
index 000000000000..e295bb91af5b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
@@ -0,0 +1,49 @@
+From 17e308fd9d56d022ed28592f93f07ec8dce530ef Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Mon, 15 Nov 2021 23:37:15 -0500
+Subject: Trac #32880: use GAP instead of Singular to test
+ _get_shared_lib_path().
+
+We still have a doctest for _get_shared_lib_path() that tries to find
+the path to libSingular; however, we no longer actually need it to
+find libSingular because the path to libSingular is contained in
+LIBSINGULAR_PATH.
+
+Since _get_shared_lib_path() is a bit fragile, this commit replaces
+that test case with one for libgap, which is still always installed
+via SPKG and for which we still need _get_shared_lib_path() to be able
+to find the path.
+---
+ src/sage/env.py | 12 ++----------
+ 1 file changed, 2 insertions(+), 10 deletions(-)
+
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 40ace13..3bd4826 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -267,20 +267,12 @@ def _get_shared_lib_path(*libnames: str) -> Optional[str]:
+ 
+     EXAMPLES::
+ 
+-        sage: import sys
+-        sage: from fnmatch import fnmatch
+         sage: from sage.env import _get_shared_lib_path
+-        sage: lib_filename = _get_shared_lib_path("Singular", "singular-Singular")
+-        sage: if sys.platform == 'cygwin':
+-        ....:     pattern = "*/cygSingular-*.dll"
+-        ....: elif sys.platform == 'darwin':
+-        ....:     pattern = "*/libSingular-*.dylib"
+-        ....: else:
+-        ....:     pattern = "*/lib*Singular-*.so"
+-        sage: fnmatch(str(lib_filename), pattern)
++        sage: "gap" in _get_shared_lib_path("gap")
+         True
+         sage: _get_shared_lib_path("an_absurd_lib") is None
+         True
++
+     """
+ 
+     for libname in libnames:
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch b/srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch
new file mode 100644
index 000000000000..32e641edb3aa
--- /dev/null
+++ b/srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch
@@ -0,0 +1,163 @@
+From 2ee7b99e0270f80cf03b80418372f45274f46051 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Samuel=20Leli=C3=A8vre?= <samuel.lelievre@gmail.com>
+Date: Sat, 20 Nov 2021 13:34:16 +0100
+Subject: 32905: abs tol for some CBF and RBF doctests
+
+---
+ src/sage/functions/gamma.py    |  2 +-
+ src/sage/rings/complex_arb.pyx |  6 +++---
+ src/sage/rings/real_arb.pyx    | 24 ++++++++++++------------
+ src/sage/symbolic/function.pyx |  2 +-
+ 4 files changed, 17 insertions(+), 17 deletions(-)
+
+diff --git a/src/sage/functions/gamma.py b/src/sage/functions/gamma.py
+index 3a4deef..307deb1 100644
+--- a/src/sage/functions/gamma.py
++++ b/src/sage/functions/gamma.py
+@@ -1049,7 +1049,7 @@ class Function_beta(GinacFunction):
+         r"""
+         TESTS::
+ 
+-            sage: RBF(beta(sin(3),sqrt(RBF(2).add_error(1e-8)/3)))
++            sage: RBF(beta(sin(3),sqrt(RBF(2).add_error(1e-8)/3)))  # abs tol 6e-7
+             [7.407662 +/- 6.17e-7]
+         """
+         return [x, y]
+diff --git a/src/sage/rings/complex_arb.pyx b/src/sage/rings/complex_arb.pyx
+index ce9b1b1..7e10ec9 100644
+--- a/src/sage/rings/complex_arb.pyx
++++ b/src/sage/rings/complex_arb.pyx
+@@ -4189,7 +4189,7 @@ cdef class ComplexBall(RingElement):
+ 
+         TESTS:
+ 
+-            sage: CBF(Ei(I))
++            sage: CBF(Ei(I))  # abs tol 1e-16
+             [0.337403922900968 +/- 3.76e-16] + [2.51687939716208 +/- 2.01e-15]*I
+         """
+         cdef ComplexBall result = self._new()
+@@ -4239,7 +4239,7 @@ cdef class ComplexBall(RingElement):
+ 
+         TESTS:
+ 
+-            sage: CBF(Ci(I))
++            sage: CBF(Ci(I))  # abs tol 1e-17
+             [0.837866940980208 +/- 4.72e-16] + [1.570796326794897 +/- 5.54e-16]*I
+         """
+         cdef ComplexBall result = self._new()
+@@ -4291,7 +4291,7 @@ cdef class ComplexBall(RingElement):
+ 
+         TESTS:
+ 
+-            sage: CBF(Chi(I))
++            sage: CBF(Chi(I))  # abs tol 1e-16
+             [0.337403922900968 +/- 3.25e-16] + [1.570796326794897 +/- 5.54e-16]*I
+         """
+         cdef ComplexBall result = self._new()
+diff --git a/src/sage/rings/real_arb.pyx b/src/sage/rings/real_arb.pyx
+index 80a840e..49caa63 100644
+--- a/src/sage/rings/real_arb.pyx
++++ b/src/sage/rings/real_arb.pyx
+@@ -3489,12 +3489,12 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(1).Ei()
++            sage: RBF(1).Ei()  # abs tol 5e-16
+             [1.89511781635594 +/- 4.94e-15]
+ 
+         TESTS::
+ 
+-            sage: RBF(Ei(1))
++            sage: RBF(Ei(1))  # abs tol 5e-16
+             [1.89511781635594 +/- 4.94e-15]
+         """
+         cdef RealBall res = self._new()
+@@ -3531,12 +3531,12 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(1).Ci()
++            sage: RBF(1).Ci()  # abs tol 1e-16
+             [0.337403922900968 +/- 3.25e-16]
+ 
+         TESTS::
+ 
+-            sage: RBF(Ci(1))
++            sage: RBF(Ci(1))  # abs tol 1e-16
+             [0.337403922900968 +/- 3.25e-16]
+         """
+         cdef RealBall res = self._new()
+@@ -3575,12 +3575,12 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(1).Chi()
++            sage: RBF(1).Chi()  # abs tol 1e-17
+             [0.837866940980208 +/- 4.72e-16]
+ 
+         TESTS::
+ 
+-            sage: RBF(Chi(1))
++            sage: RBF(Chi(1))  # abs tol 1e-17
+             [0.837866940980208 +/- 4.72e-16]
+         """
+         cdef RealBall res = self._new()
+@@ -3597,7 +3597,7 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(3).li()
++            sage: RBF(3).li()  # abs tol 1e-15
+             [2.16358859466719 +/- 4.72e-15]
+ 
+         TESTS::
+@@ -3621,7 +3621,7 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(3).Li()
++            sage: RBF(3).Li()  # abs tol 1e-15
+             [1.11842481454970 +/- 7.61e-15]
+         """
+         cdef RealBall res = self._new()
+@@ -3648,9 +3648,9 @@ cdef class RealBall(RingElement):
+ 
+         EXAMPLES::
+ 
+-            sage: RBF(sin(3)).beta(RBF(2/3).sqrt())
++            sage: RBF(sin(3)).beta(RBF(2/3).sqrt())  # abs tol 1e-13
+             [7.407661629415 +/- 1.07e-13]
+-            sage: RealBallField(100)(7/2).beta(1)
++            sage: RealBallField(100)(7/2).beta(1)  # abs tol 1e-30
+             [0.28571428571428571428571428571 +/- 5.23e-30]
+             sage: RealBallField(100)(7/2).beta(1, 1/2)
+             [0.025253813613805268728601584361 +/- 2.53e-31]
+@@ -3685,9 +3685,9 @@ cdef class RealBall(RingElement):
+ 
+             sage: RBF(1/2).gamma()
+             [1.772453850905516 +/- ...e-16]
+-            sage: RBF(gamma(3/2, RBF(2).sqrt()))
++            sage: RBF(gamma(3/2, RBF(2).sqrt()))  # abs tol 2e-17
+             [0.37118875695353 +/- 3.00e-15]
+-            sage: RBF(3/2).gamma_inc(RBF(2).sqrt())
++            sage: RBF(3/2).gamma_inc(RBF(2).sqrt())  # abs tol 2e-17
+             [0.37118875695353 +/- 3.00e-15]
+ 
+         .. SEEALSO::
+diff --git a/src/sage/symbolic/function.pyx b/src/sage/symbolic/function.pyx
+index 89cdce5..480a601 100644
+--- a/src/sage/symbolic/function.pyx
++++ b/src/sage/symbolic/function.pyx
+@@ -626,7 +626,7 @@ cdef class Function(SageObject):
+             sage: b = RBF(3/2, 1e-10)
+             sage: airy_ai(b)
+             airy_ai([1.500000000 +/- 1.01e-10])
+-            sage: gamma(b, 1)
++            sage: gamma(b, 1)  # abs tol 4.5e-9
+             [0.50728223 +/- 4.67e-9]
+             sage: hurwitz_zeta(b, b)
+             hurwitz_zeta([1.500000000 +/- 1.01e-10], [1.500000000 +/- 1.01e-10])
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch b/srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
new file mode 100644
index 000000000000..ec0467757ee7
--- /dev/null
+++ b/srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
@@ -0,0 +1,25 @@
+From f5f7a86908daf60b25e66e6a189c51ada7e0a732 Mon Sep 17 00:00:00 2001
+From: Antonio Rojas <arojas@archlinux.org>
+Date: Sat, 30 Oct 2021 10:21:52 +0200
+Subject: Fix test failure caused by new warning
+
+---
+ src/sage/lfunctions/pari.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sage/lfunctions/pari.py b/src/sage/lfunctions/pari.py
+index 0aaf91c..33d5266 100644
+--- a/src/sage/lfunctions/pari.py
++++ b/src/sage/lfunctions/pari.py
+@@ -316,7 +316,7 @@ def lfun_number_field(K):
+         sage: L(3)
+         1.15202784126080
+         sage: L(0)
+-        0.000000000000000
++        ...0.000000000000000
+     """
+     return pari.lfuncreate(K)
+ 
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/skip-optional-dochtml.patch b/srcpkgs/sagemath/patches/skip-optional-dochtml.patch
new file mode 100644
index 000000000000..e49b18a52fbc
--- /dev/null
+++ b/srcpkgs/sagemath/patches/skip-optional-dochtml.patch
@@ -0,0 +1,13 @@
+diff --git a/src/bin/sage-runtests b/src/bin/sage-runtests
+index 288c889bd1..b9a4d3038a 100755
+--- a/src/bin/sage-runtests
++++ b/src/bin/sage-runtests
+@@ -15,7 +15,7 @@ os.environ['SAGE_STARTUP_FILE'] = os.path.join(DOT_SAGE, 'init-doctests.sage')
+ 
+ def _get_optional_defaults():
+     """Return the default value for the --optional flag."""
+-    optional = ['sage', 'dochtml', 'optional']
++    optional = ['sage', 'optional']
+ 
+     # This should be good-enough to determine if we are in a sage source
+     # repository working tree
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 3f9a3e9e077f..d4130be12a7a 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -16,7 +16,7 @@ short_desc="Open source mathematics software"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
 homepage="http://sagemath.org/"
-distfiles="http://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
+distfiles="https://mirrors.mit.edu/sage/src/sage-$version.tar.gz"
 checksum=b81e1fe22d1b990bf1230260241ead016470da1f2f7b260f562d50f74c2904c7
 python_version=3
 
@@ -47,6 +47,7 @@ noshlibprovides=yes
 
 post_extract() {
 	# sage wants to be built in place so let $wrksrc be a symlink
+	rm -rf $_SAGE_ROOT
 	mv -T $wrksrc $_SAGE_ROOT
 	ln -sfT $_SAGE_ROOT $wrksrc
 }
@@ -72,6 +73,11 @@ do_install() {
 	ln -sfT $_SAGE_ROOT/sage ${DESTDIR}/usr/bin/sage-${version}_${revision}
 }
 
+do_check() {
+	# since make check will build the docs, run test like this instead
+	./sage -tp ${XBPS_MAKEJOBS} --all
+}
+
 ### copied from sage-deps, to be kept in sync
 
 # hard dependencies
@@ -103,10 +109,9 @@ makedepends+="
  m4ri-devel m4rie-devel mpfi-devel ntl-devel perl-SVG rankwidth-devel
  singular sympow zn_poly symmetrica-devel planarity-devel qhull libqhull-devel
  gengetopt texinfo
+ brial-devel cliquer-devel gfan libbraiding-devel libhomfly-devel
+ lrcalc-devel nauty-devel palp tachyon
 "
 
-# TODO: standard
-# brial cliquer gfan libbraiding libhomfly lrcalc nauty palp tachyon
-
 # TODO: optional
-# 4ti2 coxeter3 libnauty libsemigroups lrslib perl_mongodb
+# 4ti2 coxeter3 libsemigroups lrslib pdf2svg perl_mongodb polymake

From f694705d9ed2a6afa657c94fcd629dc3649bdf90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Mon, 22 Nov 2021 15:16:23 -0300
Subject: [PATCH 08/10] sagemath: more changes

 - do not install pytest, which is still broken (pending trac 31924)
 - add patch from sagemath trac 32892
 - replace the patch to fix the build of pyzmq on musl by a different
   one from sagemath trac 32828 which is what will be merged upstream
 - patch to fix doctest failure on musl (src/sage/misc/gperftools.py)
 - rebase on latest sympow rev to fix doctest failure on musl
   (src/sage/lfunctions/sympow.py)
 - enable check on CI to see what happens...
---
 ...hat-fixes-ctypes.util.find_library-c.patch |  64 +++++++++
 ...754ad30c6a1bd1fdbd6d62011055bf13b24a.patch |  27 ++++
 srcpkgs/sagemath/patches/fix-pyzmq-musl.patch |  15 --
 .../patches/trac-32828-fix-pyzmq.patch        | 134 ++++++++++++++++++
 srcpkgs/sagemath/template                     |  15 +-
 5 files changed, 235 insertions(+), 20 deletions(-)
 create mode 100644 srcpkgs/sagemath/patches/0001-Add-a-patch-that-fixes-ctypes.util.find_library-c.patch
 create mode 100644 srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
 delete mode 100644 srcpkgs/sagemath/patches/fix-pyzmq-musl.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-32828-fix-pyzmq.patch

diff --git a/srcpkgs/sagemath/patches/0001-Add-a-patch-that-fixes-ctypes.util.find_library-c.patch b/srcpkgs/sagemath/patches/0001-Add-a-patch-that-fixes-ctypes.util.find_library-c.patch
new file mode 100644
index 000000000000..4f89c2bd8fbc
--- /dev/null
+++ b/srcpkgs/sagemath/patches/0001-Add-a-patch-that-fixes-ctypes.util.find_library-c.patch
@@ -0,0 +1,64 @@
+From dc1a0e8168a9ffb4fbf07dd03c0846b4933a6dbe Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Mon, 22 Nov 2021 23:57:37 -0300
+Subject: [PATCH] Add a patch that fixes ctypes.util.find_library('c')
+
+The issue causes a failure doctesting src/sage/misc/gperftools.py
+---
+ .../python3/patches/musl-find_library.patch   | 44 +++++++++++++++++++
+ 1 file changed, 44 insertions(+)
+ create mode 100644 build/pkgs/python3/patches/musl-find_library.patch
+
+diff --git a/build/pkgs/python3/patches/musl-find_library.patch b/build/pkgs/python3/patches/musl-find_library.patch
+new file mode 100644
+index 0000000000..82f436b407
+--- /dev/null
++++ b/build/pkgs/python3/patches/musl-find_library.patch
+@@ -0,0 +1,44 @@
++--- a/Lib/ctypes/util.py
+++++ b/Lib/ctypes/util.py
++@@ -204,6 +204,41 @@
++         def find_library(name, is64 = False):
++             return _get_soname(_findLib_crle(name, is64) or _findLib_gcc(name))
++ 
+++    elif True:
+++
+++        # Patched for Alpine Linux / musl - search manually system paths
+++        def _is_elf(filepath):
+++            try:
+++                with open(filepath, 'rb') as fh:
+++                    return fh.read(4) == b'\x7fELF'
+++            except:
+++                return False
+++
+++        def find_library(name):
+++            from glob import glob
+++            # absolute name?
+++            if os.path.isabs(name):
+++                return name
+++            # special case for libm, libcrypt and libpthread and musl
+++            if name in ['m', 'crypt', 'pthread']:
+++                name = 'c'
+++            elif name in ['libm.so', 'libcrypt.so', 'libpthread.so']:
+++                name = 'libc.so'
+++            # search in standard locations (musl order)
+++            paths = ['/lib', '/usr/local/lib', '/usr/lib']
+++            if 'LD_LIBRARY_PATH' in os.environ:
+++                paths = os.environ['LD_LIBRARY_PATH'].split(':') + paths
+++            for d in paths:
+++                f = os.path.join(d, name)
+++                if _is_elf(f):
+++                    return os.path.basename(f)
+++
+++                prefix = os.path.join(d, 'lib'+name)
+++                for suffix in ['.so', '.so.*']:
+++                    for f in glob('{0}{1}'.format(prefix, suffix)):
+++                        if _is_elf(f):
+++                            return os.path.basename(f)
+++
++     else:
++ 
++         def _findSoname_ldconfig(name):
+-- 
+2.34.0
+
diff --git a/srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch b/srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
new file mode 100644
index 000000000000..ea05b2b6a524
--- /dev/null
+++ b/srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
@@ -0,0 +1,27 @@
+From 89b8754ad30c6a1bd1fdbd6d62011055bf13b24a Mon Sep 17 00:00:00 2001
+From: Tobias Diez <code@tobiasdiez.com>
+Date: Wed, 17 Nov 2021 22:24:32 +0100
+Subject: Fix exit code for pytest in case of no matched files
+
+---
+ src/bin/sage-runtests | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/bin/sage-runtests b/src/bin/sage-runtests
+index 882456d..8b362ca 100755
+--- a/src/bin/sage-runtests
++++ b/src/bin/sage-runtests
+@@ -157,6 +157,10 @@ if __name__ == "__main__":
+         if args.verbose:
+             pytest_options.append("-v")
+         exit_code_pytest = pytest.main(pytest_options + args.filenames)
++        if exit_code_pytest == 5:
++            # Exit code 5 means there were no test files, pass in this case
++            exit_code_pytest = 0
++
+     except ModuleNotFoundError:
+         print("Pytest is not installed, skip checking tests that rely on it.")
+ 
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch b/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch
deleted file mode 100644
index 9190830d835e..000000000000
--- a/srcpkgs/sagemath/patches/fix-pyzmq-musl.patch
+++ /dev/null
@@ -1,15 +0,0 @@
-diff --git a/build/pkgs/pyzmq/spkg-install.in b/build/pkgs/pyzmq/spkg-install.in
-index 0ce404ee5a..b7260c6d27 100644
---- a/build/pkgs/pyzmq/spkg-install.in
-+++ b/build/pkgs/pyzmq/spkg-install.in
-@@ -1,6 +1,9 @@
- # Since we use environment vars we have to generate setup.cfg
- 
--echo "[build_ext]" > src/setup.cfg
-+echo "[global]" > src/setup.cfg
-+echo "skip_check_zmq = True" >> src/setup.cfg
-+
-+echo "[build_ext]" >> src/setup.cfg
- 
- # (I tried putting quotes around $SAGE_LOCAL to allow for spaces in
- # the path---which is never used but is a good habit to support---but
diff --git a/srcpkgs/sagemath/patches/trac-32828-fix-pyzmq.patch b/srcpkgs/sagemath/patches/trac-32828-fix-pyzmq.patch
new file mode 100644
index 000000000000..426932c95c9b
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-32828-fix-pyzmq.patch
@@ -0,0 +1,134 @@
+diff --git a/build/pkgs/pyzmq/checksums.ini b/build/pkgs/pyzmq/checksums.ini
+index 3824fd2ce9..20509db618 100644
+--- a/build/pkgs/pyzmq/checksums.ini
++++ b/build/pkgs/pyzmq/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=pyzmq-VERSION.tar.gz
+-sha1=50abf6482a6395f15dce0b2774021e12c9f4faad
+-md5=f261acf884460e93d30f7113c8e9242e
+-cksum=1661206741
++sha1=d8bb8cb345c0bfd9e67a95ac796bf4b10354dde6
++md5=ecf13c72fbea05ba5ddc771295409d48
++cksum=1680251717
+ upstream_url=https://pypi.io/packages/source/p/pyzmq/pyzmq-VERSION.tar.gz
+diff --git a/build/pkgs/pyzmq/package-version.txt b/build/pkgs/pyzmq/package-version.txt
+index 0398faf11c..8326e27f9b 100644
+--- a/build/pkgs/pyzmq/package-version.txt
++++ b/build/pkgs/pyzmq/package-version.txt
+@@ -1 +1 @@
+-22.2.1
++22.3.0
+diff --git a/build/pkgs/pyzmq/spkg-install.in b/build/pkgs/pyzmq/spkg-install.in
+index 0ce404ee5a..069d87767f 100644
+--- a/build/pkgs/pyzmq/spkg-install.in
++++ b/build/pkgs/pyzmq/spkg-install.in
+@@ -1,17 +1,11 @@
+-# Since we use environment vars we have to generate setup.cfg
+-
+-echo "[build_ext]" > src/setup.cfg
+-
+-# (I tried putting quotes around $SAGE_LOCAL to allow for spaces in
+-# the path---which is never used but is a good habit to support---but
+-# that simply does not work. Sorry.)
+-
+-echo "library_dirs = $SAGE_LOCAL/lib/" >> src/setup.cfg
+-echo "include_dirs = $SAGE_LOCAL/include/" >> src/setup.cfg
+-
+-echo "[configure]" >> src/setup.cfg
+-
+ cd src
+ 
++# Generate setup.cfg
++cat > setup.cfg <<EOF
++[global]
++zmq_prefix = $SAGE_LOCAL
++no_libzmq_extension = True
++EOF
++
+ # Configure and install
+ sdh_pip_install .
+diff --git a/build/pkgs/setuptools/checksums.ini b/build/pkgs/setuptools/checksums.ini
+index 6a280871e7..d9290d04ff 100644
+--- a/build/pkgs/setuptools/checksums.ini
++++ b/build/pkgs/setuptools/checksums.ini
+@@ -1,5 +1,5 @@
+ tarball=setuptools-VERSION.tar.gz
+-sha1=5d97de0e774b2269c85685a4aa8fd5956bcfd2bb
+-md5=ff20ab7e0d51c5ad0a9438c50e598c06
+-cksum=3564252314
++sha1=cd4e5d1f7c47f86354fc89d040d869cde244da3b
++md5=79b36f59270a6f2e45d6a9a0c6dc68c1
++cksum=430889097
+ upstream_url=https://pypi.io/packages/source/s/setuptools/setuptools-VERSION.tar.gz
+diff --git a/build/pkgs/setuptools/package-version.txt b/build/pkgs/setuptools/package-version.txt
+index e6ea636051..aec1257e4c 100644
+--- a/build/pkgs/setuptools/package-version.txt
++++ b/build/pkgs/setuptools/package-version.txt
+@@ -1 +1 @@
+-58.2.0
++59.2.0
+diff --git a/build/pkgs/zeromq/checksums.ini b/build/pkgs/zeromq/checksums.ini
+index ea8c36bce5..dc802612dd 100644
+--- a/build/pkgs/zeromq/checksums.ini
++++ b/build/pkgs/zeromq/checksums.ini
+@@ -1,4 +1,5 @@
+ tarball=zeromq-VERSION.tar.gz
+-sha1=1132f839d703486c4ee1cf22f056585dfbb329c2
+-md5=a1c95b34384257e986842f4d006957b8
+-cksum=136261411
++sha1=47277a64749049123d1401600e8cfbab10a3ae28
++md5=c897d4005a3f0b8276b00b7921412379
++cksum=1500782345
++upstream_url=https://github.com/zeromq/libzmq/releases/download/vVERSION/zeromq-VERSION.tar.gz
+diff --git a/build/pkgs/zeromq/package-version.txt b/build/pkgs/zeromq/package-version.txt
+index df0228dfae..eda862a98c 100644
+--- a/build/pkgs/zeromq/package-version.txt
++++ b/build/pkgs/zeromq/package-version.txt
+@@ -1 +1 @@
+-4.2.5
++4.3.4
+diff --git a/build/pkgs/zeromq/patches/getrandom.patch b/build/pkgs/zeromq/patches/getrandom.patch
+deleted file mode 100644
+index e665114e1c..0000000000
+--- a/build/pkgs/zeromq/patches/getrandom.patch
++++ /dev/null
+@@ -1,39 +0,0 @@
+-Patch taken from upstream git repo
+-and after running aclocal && autoconf
+-and removing changes to autotools input files
+-
+-commit 4ff814f204ee38177a392526cf12c8c0019b480f
+-Author: Luca Boccassi <luca.boccassi@gmail.com>
+-Date:   Wed May 9 10:41:20 2018 +0100
+-
+-    Problem: getrandom test does not check if it's working
+-
+-    Solution: check return value in autoconf and CMake. On some platforms
+-    the function is available but not implemented (eg: GNU/Hurd).
+-
+-diff -ru zeromq-4.2.5//builds/cmake/Modules/ZMQSourceRunChecks.cmake b/builds/cmake/Modules/ZMQSourceRunChecks.cmake
+---- zeromq-4.2.5//builds/cmake/Modules/ZMQSourceRunChecks.cmake	2018-03-23 20:33:36.000000000 +0100
+-+++ b/builds/cmake/Modules/ZMQSourceRunChecks.cmake	2018-07-24 12:39:23.340035053 +0200
+-@@ -287,7 +287,8 @@
+- int main (int argc, char *argv [])
+- {
+-     char buf[4];
+--    getrandom(buf, 4, 0);
+-+    int rc = getrandom(buf, 4, 0);
+-+    return rc == -1 ? 1 : 0;
+- }
+- "
+-     ZMQ_HAVE_GETRANDOM)
+-diff -ru zeromq-4.2.5//configure b/configure
+---- zeromq-4.2.5//configure	2018-03-23 20:34:18.000000000 +0100
+-+++ b/configure	2018-07-24 12:39:49.018035120 +0200
+-@@ -23315,7 +23315,8 @@
+- int main (int argc, char *argv [])
+- {
+-     char buf[4];
+--    getrandom(buf, 4, 0);
+-+    int rc = getrandom(buf, 4, 0);
+-+    return rc == -1 ? 1 : 0;
+- }
+- 
+- _ACEOF
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index d4130be12a7a..622ee06d85b8 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -29,7 +29,7 @@ case ${version} in
 esac
 
 # for now, skip check in ci, since we still have a few tests failing
-make_check=ci-skip
+#make_check=ci-skip
 
 # for now, just build native; we'll worry about cross later
 # besides, some dependencies are nocross (e.g. ntl)
@@ -56,10 +56,15 @@ do_clean() {
 	rm -rf $wrksrc $_SAGE_ROOT
 }
 
-post_build() {
-	# install pytest for more tests
-	./sage -i pytest
-}
+# DISABLED pytest since it brings more harm than good
+# it seems currently all it does is to look for files matching
+# *_test.py and run pytest on those, but I don't think these are meant
+# to be run on pytest (and one even gives a failure...)
+#
+# post_build() {
+# 	# install pytest for more tests
+# 	./sage -i pytest
+# }
 
 do_install() {
 	vcopy $_SAGE_ROOT usr/lib/

From 481c143c2524d8456aa3349ec36faa4aee782593 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Thu, 25 Nov 2021 22:47:35 -0300
Subject: [PATCH 09/10] sagemath: more changes

 - skip a doctest which fails due to giac 1.7.0
 - rename patches to include trac ticket #
 - add a patch to use system linbox (needs to run ./bootstrap)
 - look for an optional file ${XBPS_DISTDIR}/sagemath-check ; if that
   file exists, its contents are used as arguments for sage check
   Intended usage: place the names of files that you want to doctest
   instead of all files (useful when you have a few failing doctests you
   are trying to fix)
---
 ...p-doctest-giac-1.7.0--see-trac-31563.patch | 14 +++++++++
 ...119d27d091b3894860547673c2f6b224f61a.patch | 31 +++++++++++++++++++
 ...86908daf60b25e66e6a189c51ada7e0a732.patch} |  0
 ...8fd9d56d022ed28592f93f07ec8dce530ef.patch} |  0
 ...54ad30c6a1bd1fdbd6d62011055bf13b24a.patch} |  0
 ...99e0270f80cf03b80418372f45274f46051.patch} |  0
 srcpkgs/sagemath/template                     | 10 +++++-
 7 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/sagemath/patches/skip-doctest-giac-1.7.0--see-trac-31563.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-29631-7072119d27d091b3894860547673c2f6b224f61a.patch
 rename srcpkgs/sagemath/patches/{f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch => trac-32797-f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch} (100%)
 rename srcpkgs/sagemath/patches/{17e308fd9d56d022ed28592f93f07ec8dce530ef.patch => trac-32880-17e308fd9d56d022ed28592f93f07ec8dce530ef.patch} (100%)
 rename srcpkgs/sagemath/patches/{89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch => trac-32892-89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch} (100%)
 rename srcpkgs/sagemath/patches/{2ee7b99e0270f80cf03b80418372f45274f46051.patch => trac-32905-2ee7b99e0270f80cf03b80418372f45274f46051.patch} (100%)

diff --git a/srcpkgs/sagemath/patches/skip-doctest-giac-1.7.0--see-trac-31563.patch b/srcpkgs/sagemath/patches/skip-doctest-giac-1.7.0--see-trac-31563.patch
new file mode 100644
index 000000000000..563bb8526788
--- /dev/null
+++ b/srcpkgs/sagemath/patches/skip-doctest-giac-1.7.0--see-trac-31563.patch
@@ -0,0 +1,14 @@
+--- a/src/sage/functions/min_max.py
++++ b/src/sage/functions/min_max.py
+@@ -233,9 +233,9 @@ class MaxSymbolic(MinMax_base):
+             sage: f = max_symbolic(sin(x), cos(x))
+             sage: r = integral(f, x, 0, 1)
+             ...
+-            sage: r
++            sage: r             # not tested -- broken with giac 1.7.0
+             sqrt(2) - cos(1)
+-            sage: r.n()
++            sage: r.n()         # not tested -- broken with giac 1.7.0
+             0.873911256504955
+         """
+         return max_symbolic(args)
diff --git a/srcpkgs/sagemath/patches/trac-29631-7072119d27d091b3894860547673c2f6b224f61a.patch b/srcpkgs/sagemath/patches/trac-29631-7072119d27d091b3894860547673c2f6b224f61a.patch
new file mode 100644
index 000000000000..8154c2453c15
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-29631-7072119d27d091b3894860547673c2f6b224f61a.patch
@@ -0,0 +1,31 @@
+From 7072119d27d091b3894860547673c2f6b224f61a Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <michael@orlitzky.com>
+Date: Fri, 12 Nov 2021 10:07:44 -0500
+Subject: Trac #29631: new spkg-configure.m4 for linbox.
+
+This is essentially the file posted as an attachment on Trac 29631 by
+Thierry Thomas. I've chosen to leave the lower bound at the latest
+v1.6.3, since in the intervening months most distributions appear to
+have updated.
+---
+ build/pkgs/linbox/spkg-configure.m4 | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+ create mode 100644 build/pkgs/linbox/spkg-configure.m4
+
+diff --git a/build/pkgs/linbox/spkg-configure.m4 b/build/pkgs/linbox/spkg-configure.m4
+new file mode 100644
+index 00000000..fbf405c
+--- /dev/null
++++ b/build/pkgs/linbox/spkg-configure.m4
+@@ -0,0 +1,8 @@
++SAGE_SPKG_CONFIGURE([linbox], [
++  SAGE_SPKG_DEPCHECK([fflas-ffpack flint fplll givaro gmp iml m4ri m4rie mpfr ntl], [
++    PKG_CHECK_MODULES([LINBOX],
++                      [linbox >= 1.6.3],
++                      [],
++                      [sage_spkg_install_linbox=yes])
++  ])
++])
+-- 
+cgit v1.0-1-gd88e
+
diff --git a/srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch b/srcpkgs/sagemath/patches/trac-32797-f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
rename to srcpkgs/sagemath/patches/trac-32797-f5f7a86908daf60b25e66e6a189c51ada7e0a732.patch
diff --git a/srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch b/srcpkgs/sagemath/patches/trac-32880-17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
rename to srcpkgs/sagemath/patches/trac-32880-17e308fd9d56d022ed28592f93f07ec8dce530ef.patch
diff --git a/srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch b/srcpkgs/sagemath/patches/trac-32892-89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
rename to srcpkgs/sagemath/patches/trac-32892-89b8754ad30c6a1bd1fdbd6d62011055bf13b24a.patch
diff --git a/srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch b/srcpkgs/sagemath/patches/trac-32905-2ee7b99e0270f80cf03b80418372f45274f46051.patch
similarity index 100%
rename from srcpkgs/sagemath/patches/2ee7b99e0270f80cf03b80418372f45274f46051.patch
rename to srcpkgs/sagemath/patches/trac-32905-2ee7b99e0270f80cf03b80418372f45274f46051.patch
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 622ee06d85b8..1ab0e9f7d65c 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -56,6 +56,10 @@ do_clean() {
 	rm -rf $wrksrc $_SAGE_ROOT
 }
 
+pre_configure() {
+	./bootstrap
+}
+
 # DISABLED pytest since it brings more harm than good
 # it seems currently all it does is to look for files matching
 # *_test.py and run pytest on those, but I don't think these are meant
@@ -79,8 +83,12 @@ do_install() {
 }
 
 do_check() {
+	TEST=--all
+	if [ -f ${XBPS_DISTDIR}/sagemath-check ] ; then
+		TEST="$(grep -v "^#" ${XBPS_DISTDIR}/sagemath-check)"
+	fi
 	# since make check will build the docs, run test like this instead
-	./sage -tp ${XBPS_MAKEJOBS} --all
+	./sage -tp ${XBPS_MAKEJOBS} ${TEST}
 }
 
 ### copied from sage-deps, to be kept in sync

From 371430a3eecd0419d34135ceba540a12a92c4bc8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Sun, 28 Nov 2021 00:32:26 -0300
Subject: [PATCH 10/10] sagemath: use system maxima

Also: add patch to use relative symlinks in gap where absolute symlinks
are now used -- otherwise xbps-create gets confused
---
 ...-spkg-install-make-symlinks-relative.patch |  27 +++
 .../patches/trac-32867-system-maxima.patch    | 174 ++++++++++++++++++
 srcpkgs/sagemath/template                     |   4 +-
 3 files changed, 204 insertions(+), 1 deletion(-)
 create mode 100644 srcpkgs/sagemath/patches/0001-build-pkgs-gap-spkg-install-make-symlinks-relative.patch
 create mode 100644 srcpkgs/sagemath/patches/trac-32867-system-maxima.patch

diff --git a/srcpkgs/sagemath/patches/0001-build-pkgs-gap-spkg-install-make-symlinks-relative.patch b/srcpkgs/sagemath/patches/0001-build-pkgs-gap-spkg-install-make-symlinks-relative.patch
new file mode 100644
index 000000000000..c9feb870f2be
--- /dev/null
+++ b/srcpkgs/sagemath/patches/0001-build-pkgs-gap-spkg-install-make-symlinks-relative.patch
@@ -0,0 +1,27 @@
+From 521a9ec8d447be5bbd3a4260e7a5e0e4653e0c34 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
+Date: Sun, 28 Nov 2021 18:57:34 -0300
+Subject: [PATCH] build/pkgs/gap/spkg-install: make symlinks relative
+
+---
+ build/pkgs/gap/spkg-install.in | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/build/pkgs/gap/spkg-install.in b/build/pkgs/gap/spkg-install.in
+index 32d1fb982c..2ceadf99db 100644
+--- a/build/pkgs/gap/spkg-install.in
++++ b/build/pkgs/gap/spkg-install.in
+@@ -80,8 +80,8 @@ chmod +x "$SAGE_DESTDIR$SAGE_BIN/gap"
+ 
+ # Create symlinks under $GAP_ROOT for these executables, as they are expected
+ # (especially when building kernel packages) to exist
+-ln -sf "$SAGE_BIN/gap-bin" "$DESTDIR_GAP_ROOT/gap"
+-ln -sf "$SAGE_BIN/gac" "$DESTDIR_GAP_ROOT/gac"
++ln -sf "../../bin/gap-bin" "$DESTDIR_GAP_ROOT/gap"
++ln -sf "../../bin/gac" "$DESTDIR_GAP_ROOT/gac"
+ 
+ # Fix the $GAP_ROOT/bin/<arch>/src symlink to be relative (otherwise it links
+ # to the actual path of the sources GAP was compiled from)
+-- 
+2.34.1
+
diff --git a/srcpkgs/sagemath/patches/trac-32867-system-maxima.patch b/srcpkgs/sagemath/patches/trac-32867-system-maxima.patch
new file mode 100644
index 000000000000..cb6517a388d8
--- /dev/null
+++ b/srcpkgs/sagemath/patches/trac-32867-system-maxima.patch
@@ -0,0 +1,174 @@
+diff --git a/build/pkgs/ecl/spkg-configure.m4 b/build/pkgs/ecl/spkg-configure.m4
+index ae1e0ac5e1..7dbcfa6377 100644
+--- a/build/pkgs/ecl/spkg-configure.m4
++++ b/build/pkgs/ecl/spkg-configure.m4
+@@ -35,10 +35,7 @@ SAGE_SPKG_CONFIGURE([ecl], [
+     AC_SUBST(SAGE_ECL_CONFIG, [$ECL_CONFIG])
+   fi
+ 
+-  # Maxima cannot yet be provided by the system, so we always use
++  # Kenzo cannot yet be provided by the system, so we always use
+   # the SAGE_LOCAL path for now.
+-  AC_SUBST(SAGE_MAXIMA_FAS, ['${prefix}'/lib/ecl/maxima.fas])
+-
+-  # Likewise for the optional Kenzo SPKG
+   AC_SUBST(SAGE_KENZO_FAS, ['${prefix}'/lib/ecl/kenzo.fas])
+ ])
+diff --git a/build/pkgs/maxima/spkg-configure.m4 b/build/pkgs/maxima/spkg-configure.m4
+new file mode 100644
+index 0000000000..df625fecc4
+--- /dev/null
++++ b/build/pkgs/maxima/spkg-configure.m4
+@@ -0,0 +1,35 @@
++SAGE_SPKG_CONFIGURE([maxima], [
++  SAGE_SPKG_DEPCHECK([ecl], [
++    dnl First check for the "maxima" executable in the user's PATH, because
++    dnl we still use pexpect to communicate with it in a few places. We pass
++    dnl the "-l ecl" flag here to ensure that the standalone executable also
++    dnl supports ECL.
++    AC_MSG_CHECKING(if "maxima -l ecl" works)
++    AS_IF([! maxima -l ecl -q -r 'quit();' \
++             >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD], [
++      AC_MSG_RESULT(no)
++      sage_spkg_install_maxima=yes
++    ], [
++      AC_MSG_RESULT(yes)
++      dnl If we have the executable, check also for the ECL library.
++      AC_MSG_CHECKING([if ECL can "require" the maxima module])
++      AS_IF([ecl --eval "(require 'maxima)" --eval "(quit)" \
++               >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD], [
++        AC_MSG_RESULT(yes)
++      ], [
++	AC_MSG_RESULT(no)
++	sage_spkg_install_maxima=yes
++      ])
++    ])
++  ])
++],[],[],[
++  # post-check
++  AS_IF([test x$sage_spkg_install_maxima = xyes], [
++    dnl Leaving this variable empty will tell sagelib to load
++    dnl the maxima library (within ECL) by name instead of by
++    dnl absolute path.
++    SAGE_MAXIMA_FAS='${prefix}'/lib/ecl/maxima.fas
++  ])
++  AC_SUBST(SAGE_MAXIMA_FAS, "${SAGE_MAXIMA_FAS}")
++])
++
+diff --git a/pkgs/sage-conf/sage_conf.py.in b/pkgs/sage-conf/sage_conf.py.in
+index fbce6947de..8cda3ebfac 100644
+--- a/pkgs/sage-conf/sage_conf.py.in
++++ b/pkgs/sage-conf/sage_conf.py.in
+@@ -9,9 +9,8 @@ VERSION = "@PACKAGE_VERSION@"
+ SAGE_LOCAL = "@prefix@"
+ SAGE_ROOT = "@SAGE_ROOT@"
+ 
+-MAXIMA = "@prefix@/bin/maxima"
+-
+-# Delete this line if your ECL can load maxima without further prodding.
++# Set this to the empty string if your ECL can load maxima without
++# further prodding.
+ MAXIMA_FAS = "@SAGE_MAXIMA_FAS@".replace('${prefix}', SAGE_LOCAL)
+ 
+ # Delete this line if your ECL can load Kenzo without further prodding.
+diff --git a/src/bin/sage b/src/bin/sage
+index fcd263029d..54b69a1043 100755
+--- a/src/bin/sage
++++ b/src/bin/sage
+@@ -684,11 +684,7 @@ fi
+ 
+ if [ "$1" = '-maxima' -o "$1" = '--maxima' ]; then
+     shift
+-    maxima_cmd=$(sage-config MAXIMA 2>/dev/null)
+-    if [ -z "${maxima_cmd}" ]; then
+-        maxima_cmd="maxima -l ecl"
+-    fi
+-    exec $maxima_cmd "$@"
++    exec maxima -l ecl "$@"
+ fi
+ 
+ if [ "$1" = '-mwrank' -o "$1" = '--mwrank' ]; then
+diff --git a/src/bin/sage-env b/src/bin/sage-env
+index a0426df523..f0866b4b1b 100644
+--- a/src/bin/sage-env
++++ b/src/bin/sage-env
+@@ -482,9 +482,6 @@ if [ -d "$DOT_SAGE" ] ; then
+     fi
+ fi
+ 
+-if [ -n "$SAGE_LOCAL" ]; then
+-    export MAXIMA_PREFIX="$SAGE_LOCAL"
+-fi
+ export MAXIMA_USERDIR="$DOT_SAGE/maxima"
+ 
+ if [ -n "$SAGE_LOCAL" ]; then
+diff --git a/src/sage/env.py b/src/sage/env.py
+index 40ace135f0..95edc16081 100644
+--- a/src/sage/env.py
++++ b/src/sage/env.py
+@@ -207,7 +207,6 @@ MATHJAX_DIR = var("MATHJAX_DIR", join(SAGE_SHARE, "mathjax"))
+ MTXLIB = var("MTXLIB", join(SAGE_SHARE, "meataxe"))
+ THREEJS_DIR = var("THREEJS_DIR", join(SAGE_SHARE, "threejs-sage"))
+ PPLPY_DOCS = var("PPLPY_DOCS", join(SAGE_SHARE, "doc", "pplpy"))
+-MAXIMA = var("MAXIMA", "maxima")
+ MAXIMA_FAS = var("MAXIMA_FAS")
+ KENZO_FAS = var("KENZO_FAS")
+ SAGE_NAUTY_BINS_PREFIX = var("SAGE_NAUTY_BINS_PREFIX", "")
+diff --git a/src/sage/interfaces/maxima.py b/src/sage/interfaces/maxima.py
+index fc7f48bc05..7313c7d0d3 100644
+--- a/src/sage/interfaces/maxima.py
++++ b/src/sage/interfaces/maxima.py
+@@ -484,7 +484,6 @@ import shlex
+ 
+ from random import randrange
+ 
+-from sage.env import MAXIMA
+ from sage.misc.misc import ECL_TMP
+ 
+ from .expect import (Expect, ExpectElement, gc_disabled)
+@@ -558,7 +557,7 @@ class Maxima(MaximaAbstract, Expect):
+         Expect.__init__(self,
+                         name = 'maxima',
+                         prompt = r'\(\%i[0-9]+\) ',
+-                        command = '{0} -p {1}'.format(MAXIMA, shlex.quote(STARTUP)),
++                        command = 'maxima -l ecl -p {0}'.format(shlex.quote(STARTUP)),
+                         env = {'TMPDIR': str(ECL_TMP)},
+                         script_subdirectory = script_subdirectory,
+                         restart_on_ctrlc = False,
+diff --git a/src/sage/interfaces/maxima_abstract.py b/src/sage/interfaces/maxima_abstract.py
+index 917059de0a..c966a3c9a0 100644
+--- a/src/sage/interfaces/maxima_abstract.py
++++ b/src/sage/interfaces/maxima_abstract.py
+@@ -54,7 +54,7 @@ import re
+ import sys
+ import subprocess
+ 
+-from sage.env import DOT_SAGE, MAXIMA
++from sage.env import DOT_SAGE
+ COMMANDS_CACHE = '%s/maxima_commandlist_cache.sobj' % DOT_SAGE
+ 
+ from sage.cpython.string import bytes_to_str
+@@ -164,7 +164,7 @@ class MaximaAbstract(ExtraTabCompletion, Interface):
+             -- Function: gcd (<p_1>, <p_2>, <x_1>, ...)
+             ...
+         """
+-        cmd = '{} --very-quiet --batch-string="{}({});" '.format(MAXIMA, command, s)
++        cmd = 'maxima -l ecl --very-quiet --batch-string="{}({});" '.format(command, s)
+         env = os.environ.copy()
+         env['TMPDIR'] = str(ECL_TMP)
+ 
+@@ -2214,7 +2214,7 @@ def maxima_version():
+         sage: maxima_version()  # random
+         '5.41.0'
+     """
+-    with os.popen('{} --version'.format(MAXIMA)) as p:
++    with os.popen('maxima -l ecl --version') as p:
+         return p.read().split()[-1]
+ 
+ 
+@@ -2232,4 +2232,4 @@ def maxima_console():
+     from sage.repl.rich_output.display_manager import get_display_manager
+     if not get_display_manager().is_in_terminal():
+         raise RuntimeError('Can use the console only in the terminal. Try %%maxima magics instead.')
+-    os.system('{}'.format(MAXIMA))
++    os.system('maxima -l ecl')
diff --git a/srcpkgs/sagemath/template b/srcpkgs/sagemath/template
index 1ab0e9f7d65c..7917e78cbdc6 100644
--- a/srcpkgs/sagemath/template
+++ b/srcpkgs/sagemath/template
@@ -11,7 +11,8 @@ make_build_target=build
 depends="giac git FlintQS zn_poly sympow
  pari-elldata-small pari-galdata pari-galpol-small pari-seadata-small
  flintlib-devel gsl-devel ntl-devel eclib-devel pari-devel mpfr-devel
- m4ri-devel gd-devel libpng-devel fflas-ffpack pkg-config gcc-fortran"
+ m4ri-devel gd-devel libpng-devel fflas-ffpack pkg-config gcc-fortran
+ maxima-ecl"
 short_desc="Open source mathematics software"
 maintainer="Gonzalo Tornaría <tornaria@cmat.edu.uy>"
 license="GPL-3.0-or-later"
@@ -124,6 +125,7 @@ makedepends+="
  gengetopt texinfo
  brial-devel cliquer-devel gfan libbraiding-devel libhomfly-devel
  lrcalc-devel nauty-devel palp tachyon
+ maxima-ecl
 "
 
 # TODO: optional

  parent reply	other threads:[~2021-11-28 23:21 UTC|newest]

Thread overview: 250+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 14:12 [PR PATCH] [WIP] New package: sagemath-9.5.beta5 tornaria
2021-11-11 16:08 ` dkwo
2021-11-12  7:27 ` fosslinux
2021-11-12 20:16 ` dkwo
2021-11-12 20:22 ` dkwo
2021-11-12 20:28 ` dkwo
2021-11-12 20:37 ` dkwo
2021-11-12 22:06 ` fosslinux
2021-11-12 22:12 ` [PR REVIEW] " Duncaen
2021-11-13  1:27 ` tornaria
2021-11-13  1:30 ` tornaria
2021-11-13  1:33 ` tornaria
2021-11-13  3:14 ` [PR PATCH] [Updated] " tornaria
2021-11-13  3:18 ` tornaria
2021-11-13  8:59 ` dkwo
2021-11-13  9:02 ` dkwo
2021-11-13  9:28 ` dkwo
2021-11-13  9:36 ` dkwo
2021-11-13 10:22 ` dkwo
2021-11-13 10:48 ` dkwo
2021-11-13 10:50 ` [PR PATCH] [Updated] " tornaria
2021-11-13 10:59 ` tornaria
2021-11-13 11:05 ` tornaria
2021-11-13 11:42 ` tornaria
2021-11-13 12:30 ` dkwo
2021-11-13 13:48 ` dkwo
2021-11-13 13:50 ` dkwo
2021-11-13 13:53 ` leahneukirchen
2021-11-13 14:20 ` leahneukirchen
2021-11-13 14:22 ` leahneukirchen
2021-11-13 14:55 ` leahneukirchen
2021-11-13 14:58 ` leahneukirchen
2021-11-13 15:00 ` dkwo
2021-11-13 15:07 ` leahneukirchen
2021-11-13 15:11 ` leahneukirchen
2021-11-13 15:28 ` dkwo
2021-11-13 15:34 ` leahneukirchen
2021-11-14  4:42 ` ericonr
2021-11-14  4:43 ` ericonr
2021-11-14 14:27 ` leahneukirchen
2021-11-14 15:20 ` tornaria
2021-11-14 16:31 ` leahneukirchen
2021-11-14 21:28 ` [PR PATCH] [Updated] " tornaria
2021-11-14 21:47 ` tornaria
2021-11-15 15:58 ` leahneukirchen
2021-11-15 16:16 ` tornaria
2021-11-17  9:20 ` dkwo
2021-11-20 22:12 ` [PR PATCH] [Updated] " tornaria
2021-11-21  9:37 ` dkwo
2021-11-21 14:00 ` tornaria
2021-11-21 19:44 ` dkwo
2021-11-22 12:51 ` tornaria
2021-11-22 13:17 ` [WIP] New package: sagemath-9.5.beta7 dkwo
2021-11-22 14:30 ` [PR PATCH] [Updated] " tornaria
2021-11-22 14:35 ` tornaria
2021-11-22 14:55 ` tornaria
2021-11-22 15:22 ` tornaria
2021-11-22 15:30 ` dkwo
2021-11-22 15:30 ` dkwo
2021-11-22 15:41 ` dkwo
2021-11-22 16:30 ` dkwo
2021-11-22 16:35 ` tornaria
2021-11-22 17:09 ` dkwo
2021-11-22 17:28 ` tornaria
2021-11-22 17:52 ` dkwo
2021-11-22 23:41 ` tornaria
2021-11-23  3:22 ` [PR PATCH] [Updated] " tornaria
2021-11-23  3:25 ` tornaria
2021-11-23  9:22 ` dkwo
2021-11-23 12:16 ` tornaria
2021-11-24 19:28 ` tornaria
2021-11-25 22:41 ` tornaria
2021-11-26  3:04 ` [PR PATCH] [Updated] " tornaria
2021-11-26  3:12 ` tornaria
2021-11-26  9:30 ` dkwo
2021-11-26  9:31 ` dkwo
2021-11-26  9:33 ` dkwo
2021-11-26 13:10 ` tornaria
2021-11-27 14:08 ` dkwo
2021-11-28 12:32 ` tornaria
2021-11-28 13:42 ` tornaria
2021-11-28 13:52 ` tornaria
2021-11-28 23:21 ` tornaria [this message]
2021-11-28 23:27 ` tornaria
2021-11-28 23:32 ` tornaria
2021-12-02 16:38 ` dkwo
2021-12-02 16:44 ` leahneukirchen
2021-12-02 17:04 ` dkwo
2021-12-02 17:12 ` leahneukirchen
2021-12-04 15:37 ` [PR PATCH] [Updated] " tornaria
2021-12-04 15:38 ` tornaria
2021-12-04 15:47 ` tornaria
2021-12-05 10:22 ` dkwo
2021-12-10 21:28 ` dkwo
2021-12-10 21:31 ` dkwo
2021-12-11  2:29 ` ericonr
2021-12-11 17:58 ` dkwo
2021-12-13  3:13 ` [PR PATCH] [Updated] " tornaria
2021-12-13  9:25 ` dkwo
2021-12-13 13:17 ` tornaria
2021-12-13 13:28 ` dkwo
2021-12-13 15:25 ` dkwo
2021-12-13 17:10 ` tornaria
2021-12-13 17:48 ` tornaria
2021-12-13 20:34 ` dkwo
2021-12-13 21:00 ` dkwo
2021-12-13 21:13 ` dkwo
2021-12-14 17:36 ` ericonr
2021-12-15 10:41 ` dkwo
2021-12-15 14:57 ` tornaria
2021-12-15 14:59 ` tornaria
2021-12-15 15:04 ` dkwo
2021-12-15 15:19 ` dkwo
2021-12-16 23:11 ` tornaria
2021-12-17 20:08 ` dkwo
2021-12-20  2:23 ` tornaria
2021-12-20  2:35 ` [PR PATCH] [Updated] " tornaria
2021-12-23 17:18 ` [WIP] New package: sagemath-9.5.beta8 dkwo
2021-12-23 17:47 ` dkwo
2021-12-23 18:28 ` tornaria
2021-12-23 19:20 ` dkwo
2021-12-23 19:39 ` tornaria
2021-12-23 19:50 ` tornaria
2021-12-23 20:41 ` dkwo
2021-12-23 22:08 ` tornaria
2021-12-24  9:08 ` dkwo
2021-12-24 11:36 ` tornaria
2021-12-24 11:53 ` dkwo
2021-12-24 12:15 ` tornaria
2021-12-24 16:10 ` tornaria
2021-12-24 16:35 ` tornaria
2021-12-24 17:39 ` tornaria
2021-12-25  8:44 ` dkwo
2021-12-25 13:33 ` tornaria
2021-12-25 15:29 ` tornaria
2021-12-25 15:59 ` ericonr
2021-12-25 15:59 ` ericonr
2021-12-25 16:21 ` tornaria
2021-12-26  2:11 ` ericonr
2021-12-26  9:28 ` dkwo
2021-12-26 10:33 ` dkwo
2021-12-26 10:34 ` dkwo
2021-12-26 10:36 ` dkwo
2021-12-27  0:08 ` [PR PATCH] [Updated] " tornaria
2021-12-27  4:12 ` tornaria
2021-12-27 16:28 ` dkwo
2021-12-27 16:29 ` dkwo
2021-12-27 16:37 ` tornaria
2021-12-27 17:15 ` tornaria
2021-12-27 21:52 ` ericonr
2021-12-27 23:21 ` [PR PATCH] [Updated] " tornaria
2021-12-28 15:50 ` [WIP] New package: sagemath-9.5.beta9 dkwo
2021-12-28 17:37 ` tornaria
2021-12-28 18:31 ` dkwo
2021-12-28 18:55 ` dkwo
2021-12-28 21:23 ` tornaria
2021-12-28 22:08 ` tornaria
2021-12-28 22:12 ` tornaria
2021-12-28 22:15 ` tornaria
2021-12-28 23:22 ` tornaria
2021-12-29 12:37 ` dkwo
2022-01-03 20:02 ` [PR PATCH] [Updated] " tornaria
2022-01-03 20:50 ` tornaria
2022-01-04 17:52 ` dkwo
2022-01-04 17:57 ` dkwo
2022-01-04 18:14 ` tornaria
2022-01-04 18:14 ` [PR PATCH] [Closed]: " tornaria
2022-01-04 18:17 ` tornaria
2022-01-04 18:17 ` tornaria
2022-01-04 18:28 ` tornaria
2022-01-04 18:48 ` tornaria
2022-01-05  9:56 ` dkwo
2022-01-07 10:55 ` dkwo
2022-01-07 10:57 ` dkwo
2022-01-07 10:59 ` dkwo
2022-01-07 15:04 ` tornaria
2022-01-07 15:13 ` tornaria
2022-01-08 16:51 ` [PR PATCH] [Updated] " tornaria
2022-01-10  3:22 ` tornaria
2022-01-11 13:00 ` [WIP] New package: sagemath-9.5.rc0 dkwo
2022-01-11 13:39 ` tornaria
2022-01-11 14:39 ` tornaria
2022-01-12 23:43 ` [PR PATCH] [Updated] " tornaria
2022-01-12 23:47 ` tornaria
2022-01-13  2:34 ` tornaria
2022-01-13 18:50 ` [PR PATCH] [Updated] " tornaria
2022-01-13 19:11 ` tornaria
2022-01-14 14:34 ` [PR PATCH] [Updated] " tornaria
2022-01-14 14:36 ` tornaria
2022-01-14 14:48 ` tornaria
2022-01-14 15:21 ` [PR PATCH] [Updated] [WIP] New package: sagemath-9.5.rc1 tornaria
2022-01-14 15:24 ` tornaria
2022-01-14 15:27 ` leahneukirchen
2022-01-14 15:31 ` tornaria
2022-01-14 16:35 ` leahneukirchen
2022-01-14 16:57 ` tornaria
2022-01-14 17:04 ` leahneukirchen
2022-01-14 17:39 ` leahneukirchen
2022-01-15  2:13 ` [PR PATCH] [Updated] " tornaria
2022-01-15  4:48 ` tornaria
2022-01-15 13:35 ` tornaria
2022-01-15 13:57 ` tornaria
2022-01-15 17:55 ` dkwo
2022-01-15 18:23 ` tornaria
2022-01-15 18:24 ` tornaria
2022-01-15 18:27 ` [PR PATCH] [Updated] " tornaria
2022-01-15 18:31 ` tornaria
2022-01-17  5:10 ` [PR PATCH] [Updated] " tornaria
2022-01-17  5:17 ` [WIP] New package: sagemath-9.5.rc2 tornaria
2022-01-17  5:31 ` tornaria
2022-01-17  5:54 ` [PR PATCH] [Updated] " tornaria
2022-01-17  5:55 ` tornaria
2022-01-17  9:37 ` dkwo
2022-01-17 10:42 ` tornaria
2022-01-17 10:50 ` dkwo
2022-01-17 13:07 ` [PR PATCH] [Updated] " tornaria
2022-01-17 16:20 ` dkwo
2022-01-17 17:05 ` dkwo
2022-01-17 17:17 ` tornaria
2022-01-17 17:24 ` dkwo
2022-01-18  1:46 ` [PR PATCH] [Updated] " tornaria
2022-01-18  1:47 ` tornaria
2022-01-18  9:05 ` dkwo
2022-01-18  9:56 ` [PR PATCH] [Updated] " tornaria
2022-01-18 21:55 ` tornaria
2022-01-19 11:01 ` tornaria
2022-01-19 11:09 ` tornaria
2022-01-19 13:37 ` tornaria
2022-01-19 16:51 ` [PR PATCH] [Updated] " tornaria
2022-01-19 17:08 ` tornaria
2022-01-19 17:22 ` dkwo
2022-01-20 13:17 ` [WIP] New package: sagemath-9.5.rc3 dkwo
2022-01-20 15:41 ` tornaria
2022-01-20 15:53 ` dkwo
2022-01-20 16:04 ` dkwo
2022-01-20 16:04 ` dkwo
2022-01-25 20:37 ` [PR PATCH] [Updated] " tornaria
2022-01-25 21:27 ` [WIP] New package: sagemath-9.5.rc4 leahneukirchen
2022-01-25 23:19 ` tornaria
2022-01-26 13:07 ` [PR PATCH] [Updated] " tornaria
2022-01-30 22:13 ` tornaria
2022-01-30 22:41 ` [WIP] New package: sagemath-9.5 tornaria
2022-01-31  9:01 ` dkwo
2022-01-31  9:40 ` dkwo
2022-02-02 21:03 ` [PR PATCH] [Updated] " tornaria
2022-02-02 21:41 ` tornaria
2022-02-03  0:31 ` tornaria
2022-02-03  2:48 ` tornaria
2022-02-03 13:31 ` [PR PATCH] [Merged]: " leahneukirchen
2022-02-03 15:41 ` Vindaar

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=20211128232111.p_ctdCm6hGUi3PApmvtadLDE-g5nNSNtYic4AOxWk1s@z \
    --to=tornaria@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).