Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [RFC] maxima: add a subpkg maxima-ecl needed for sagemath
@ 2021-11-27 23:25 tornaria
  2021-11-28 12:51 ` tornaria
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: tornaria @ 2021-11-27 23:25 UTC (permalink / raw)
  To: ml

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

There is a new pull request by tornaria against master on the void-packages repository

https://github.com/tornaria/void-packages maxima
https://github.com/void-linux/void-packages/pull/34273

[RFC] 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.

#### Testing the changes
- I tested the changes in this PR: **briefly**

To compile sagemath using system maxima, two things are necessary:
 - the maxima-ecl package that this PR introduces
 - the (yet unmerged) changes for sagemath in https://trac.sagemath.org/ticket/32867
Using both I compiled and doctested sagemath, and it seems to be working ok.

#### RFC
My doubts are:
- where to place the library `maxima.fas` as discussed above
- whether to have a build_option for ecl or just hardcode it as enabled
- whether to split the `maxima-ecl` package or place the two files it contains in the package `maxima` itself

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-maxima-34273.patch --]
[-- Type: text/x-diff, Size: 8240 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] 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
+	}
+}

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-12-21 13:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-27 23:25 [PR PATCH] [RFC] maxima: add a subpkg maxima-ecl needed for sagemath tornaria
2021-11-28 12:51 ` tornaria
2021-11-28 13:01 ` tornaria
2021-11-28 20:28 ` dkwo
2021-12-01 21:24 ` knusbaum
2021-12-01 23:02 ` tornaria
2021-12-11 18:38 ` [PR PATCH] [Updated] " tornaria
2021-12-11 18:56 ` tornaria
2021-12-13 13:09 ` tornaria
2021-12-21 13:08 ` tornaria
2021-12-21 13:19 ` [PR PATCH] [Merged]: " leahneukirchen

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).