summary refs log tree commit diff
path: root/pkgs/applications/science/math
diff options
context:
space:
mode:
author7c6f434c <7c6f434c@mail.ru>2022-01-31 13:24:26 +0000
committerGitHub <noreply@github.com>2022-01-31 13:24:26 +0000
commit9b76122d71deb28ed6273fe84705e0cdda03b0ee (patch)
tree4a980ba93a86faa3cc5693d08dd4dc73c3c4241f /pkgs/applications/science/math
parent4971c8caa8ecc0d2a69b682d8f16b56c372671a5 (diff)
parent8ec9a32829f9510922481a99e67182478558cfb9 (diff)
downloadnixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar.gz
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar.bz2
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar.lz
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar.xz
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.tar.zst
nixpkgs-9b76122d71deb28ed6273fe84705e0cdda03b0ee.zip
Merge pull request #140889 from collares/sage-9.5
sage: 9.4 -> 9.5
Diffstat (limited to 'pkgs/applications/science/math')
-rw-r--r--pkgs/applications/science/math/sage/default.nix19
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch46
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch26
-rw-r--r--pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch21
-rw-r--r--pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch58
-rw-r--r--pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch12
-rw-r--r--pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix28
-rw-r--r--pkgs/applications/science/math/sage/python-modules/sage-setup.nix28
-rw-r--r--pkgs/applications/science/math/sage/sage-env.nix11
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix64
-rw-r--r--pkgs/applications/science/math/sage/sage-with-env.nix6
-rw-r--r--pkgs/applications/science/math/sage/sage.nix3
-rw-r--r--pkgs/applications/science/math/sage/sage_docbuild.nix20
-rw-r--r--pkgs/applications/science/math/sage/sagedoc.nix4
-rw-r--r--pkgs/applications/science/math/sage/sagelib.nix52
-rw-r--r--pkgs/applications/science/math/singular/default.nix77
-rw-r--r--pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch112
-rw-r--r--pkgs/applications/science/math/singular/redhat-aarch64.patch38
-rw-r--r--pkgs/applications/science/math/singular/use-older-ax-prog-cc-for-build.patch194
-rw-r--r--pkgs/applications/science/math/singular/vspace-MAX_PROCESS.patch35
20 files changed, 273 insertions, 581 deletions
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index e9dae55fbae..2066087692a 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -14,13 +14,17 @@ let
       # `sagelib`, i.e. all of sage except some wrappers and runtime dependencies
       sagelib = self.callPackage ./sagelib.nix {
         inherit flint arb;
-        inherit sage-src env-locations pynac singular;
+        inherit sage-src env-locations singular;
         inherit (maxima) lisp-compiler;
         linbox = pkgs.linbox.override { withSage = true; };
         pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
       };
 
-      sage_docbuild = self.callPackage ./sage_docbuild.nix {
+      sage-docbuild = self.callPackage ./python-modules/sage-docbuild.nix {
+        inherit sage-src;
+      };
+
+      sage-setup = self.callPackage ./python-modules/sage-setup.nix {
         inherit sage-src;
       };
     };
@@ -58,9 +62,9 @@ let
   # the env-locations file.
   sage-env = callPackage ./sage-env.nix {
     sagelib = python3.pkgs.sagelib;
-    sage_docbuild = python3.pkgs.sage_docbuild;
+    sage-docbuild = python3.pkgs.sage-docbuild;
     inherit env-locations;
-    inherit python3 singular palp flint pynac pythonEnv maxima;
+    inherit python3 singular palp flint pythonEnv maxima;
     pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
   };
 
@@ -74,7 +78,7 @@ let
   sage-with-env = callPackage ./sage-with-env.nix {
     inherit python3 pythonEnv;
     inherit sage-env;
-    inherit pynac singular maxima;
+    inherit singular maxima;
     inherit three;
     pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
   };
@@ -91,7 +95,7 @@ let
 
   pythonRuntimeDeps = with python3.pkgs; [
     sagelib
-    sage_docbuild
+    sage-docbuild
     cvxopt
     networkx
     service-identity
@@ -132,9 +136,6 @@ let
     };
   };
 
-  # *not* to confuse with the python package "pynac"
-  pynac = pkgs.pynac.override { inherit singular flint; };
-
   # With openblas (64 bit), the tests fail the same way as when sage is build with
   # openblas instead of openblasCompat. Apparently other packages somehow use flints
   # blas when it is available. Alternative would be to override flint to use
diff --git a/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch b/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
new file mode 100644
index 00000000000..a478f50d92e
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/Only-test-external-software-when-all-of-sage-is.patch
@@ -0,0 +1,46 @@
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index 01f32fb8e4..4d83dc7b47 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -1253,6 +1253,7 @@ class DocTestController(SageObject):
+ 
+             self.log("Using --optional=" + self._optional_tags_string())
+             available_software._allow_external = self.options.optional is True or 'external' in self.options.optional
++            available_software._autodetect_safe = self.options.optional is True or 'sage' in self.options.optional
+             self.log("Features to be detected: " + ','.join(available_software.detectable()))
+             self.add_files()
+             self.expand_files_into_sources()
+diff --git a/src/sage/doctest/external.py b/src/sage/doctest/external.py
+index 84dae19ea5..badc61466e 100644
+--- a/src/sage/doctest/external.py
++++ b/src/sage/doctest/external.py
+@@ -409,6 +409,7 @@ class AvailableSoftware(object):
+             []
+         """
+         self._allow_external = True
++        self._autodetect_safe = True
+         # For multiprocessing of doctests, the data self._seen should be
+         # shared among subprocesses. Thus we use Array class from the
+         # multiprocessing module.
+@@ -430,6 +431,8 @@ class AvailableSoftware(object):
+             sage: 'internet' in available_software # random, optional - internet
+             True
+         """
++        if not self._autodetect_safe:
++            return False
+         try:
+             idx = self._indices[item]
+         except KeyError:
+diff --git a/src/sage/features/sagemath.py b/src/sage/features/sagemath.py
+index 433338766d..233623b14a 100644
+--- a/src/sage/features/sagemath.py
++++ b/src/sage/features/sagemath.py
+@@ -12,7 +12,7 @@ class sagemath_doc_html(StaticFile):
+ 
+     EXAMPLES::
+ 
+-        sage: from sage.features.sagemath import sagemath_doc_html
++        sage: from sage.features.sagemath import sagemath_doc_html  # optional - sagemath_doc_html
+         sage: sagemath_doc_html().is_present()  # optional - sagemath_doc_html
+         FeatureTestResult('sagemath_doc_html', True)
+     """
diff --git a/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch b/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
deleted file mode 100644
index d5c19a54fd9..00000000000
--- a/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
+++ /dev/null
@@ -1,26 +0,0 @@
-From f5ea42a7aaed7611fb55b65897b9fcf2b7bcf97e Mon Sep 17 00:00:00 2001
-From: Timo Kaufmann <timokau@zoho.com>
-Date: Sun, 21 Oct 2018 17:52:40 +0200
-Subject: [PATCH] Only test py2/py3 optional tests when all of sage is tested
-
----
- src/sage/doctest/control.py | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
-diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
-index 2d93841e50..6d156e29a1 100644
---- a/src/sage/doctest/control.py
-+++ b/src/sage/doctest/control.py
-@@ -375,7 +375,8 @@ class DocTestController(SageObject):
-                     if not optionaltag_regex.search(o):
-                         raise ValueError('invalid optional tag {!r}'.format(o))
- 
--                options.optional |= auto_optional_tags
-+                if "sage" in options.optional:
-+                    options.optional |= auto_optional_tags
- 
-         self.options = options
- 
--- 
-2.28.0
-
diff --git a/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch b/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
index 178cef3e54e..90a23f94cb5 100644
--- a/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
+++ b/pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch
@@ -1,8 +1,8 @@
 diff --git a/src/sage/env.py b/src/sage/env.py
-index 95980cc2df..37107a30e1 100644
+index c4953cfa65..47b880f9ad 100644
 --- a/src/sage/env.py
 +++ b/src/sage/env.py
-@@ -227,93 +227,12 @@ OPENMP_CXXFLAGS = var("OPENMP_CXXFLAGS", "")
+@@ -244,81 +244,8 @@ os.environ['MPMATH_SAGE'] = '1'
  SAGE_BANNER = var("SAGE_BANNER", "")
  SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes")
  
@@ -29,20 +29,12 @@ index 95980cc2df..37107a30e1 100644
 -
 -    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:
@@ -87,11 +79,6 @@ index 95980cc2df..37107a30e1 100644
 -    # Just return None if no files were found
 -    return None
 -
- # locate singular shared object
- # On Debian it's libsingular-Singular so try that as well
--SINGULAR_SO = var("SINGULAR_SO", _get_shared_lib_path("Singular", "singular-Singular"))
-+SINGULAR_SO = var("SINGULAR_SO", '/default')
- 
  # locate libgap shared object
 -GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
 +GAP_SO = var("GAP_SO", '/default')
diff --git a/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch b/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch
new file mode 100644
index 00000000000..91e080aa294
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/linbox-1.7-upgrade.patch
@@ -0,0 +1,58 @@
+diff --git a/src/sage/libs/linbox/conversion.pxd b/src/sage/libs/linbox/conversion.pxd
+index 7794c9edc3..1753277b1f 100644
+--- a/src/sage/libs/linbox/conversion.pxd
++++ b/src/sage/libs/linbox/conversion.pxd
+@@ -177,9 +177,8 @@ cdef inline Vector_integer_dense new_sage_vector_integer_dense(P, DenseVector_in
+     - v -- linbox vector
+     """
+     cdef Vector_integer_dense res = P()
+-    cdef cppvector[Integer] * vec = &v.refRep()
+     cdef size_t i
+     for i in range(<size_t> res._degree):
+-        mpz_set(res._entries[i], vec[0][i].get_mpz_const())
++        mpz_set(res._entries[i], v.getEntry(i).get_mpz_const())
+ 
+     return res
+diff --git a/src/sage/libs/linbox/linbox.pxd b/src/sage/libs/linbox/linbox.pxd
+index 9112d151f8..dcc482960c 100644
+--- a/src/sage/libs/linbox/linbox.pxd
++++ b/src/sage/libs/linbox/linbox.pxd
+@@ -32,7 +32,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
+         ctypedef Modular_double Field
+         ctypedef double Element
+         DenseMatrix_Modular_double(Field F, size_t m, size_t n)
+-        DenseMatrix_Modular_double(Field F, Element*, size_t m, size_t n)
++        DenseMatrix_Modular_double(Field F, size_t m, size_t n, Element*)
+         void setEntry(size_t i, size_t j, Element& a)
+         Element &getEntry(size_t i, size_t j)
+ 
+@@ -42,7 +42,7 @@ cdef extern from "linbox/matrix/dense-matrix.h":
+         ctypedef Modular_float Field
+         ctypedef float Element
+         DenseMatrix_Modular_float(Field F, size_t m, size_t n)
+-        DenseMatrix_Modular_float(Field F, Element*, size_t m, size_t n)
++        DenseMatrix_Modular_float(Field F, size_t m, size_t n, Element*)
+         void setEntry(size_t i, size_t j, Element& a)
+         Element &getEntry(size_t i, size_t j)
+ 
+@@ -101,7 +101,6 @@ cdef extern from "linbox/vector/vector.h":
+         DenseVector_integer (Field &F)
+         DenseVector_integer (Field &F, long& m)
+         DenseVector_integer (Field &F, cppvector[Integer]&)
+-        cppvector[Element]& refRep()
+         size_t size()
+         void resize(size_t)
+         void resize(size_t n, const Element&)
+diff --git a/src/sage/matrix/matrix_modn_dense_template.pxi b/src/sage/matrix/matrix_modn_dense_template.pxi
+index 010365d76f..3d60726ff9 100644
+--- a/src/sage/matrix/matrix_modn_dense_template.pxi
++++ b/src/sage/matrix/matrix_modn_dense_template.pxi
+@@ -219,7 +219,7 @@ cdef inline linbox_echelonize_efd(celement modulus, celement* entries, Py_ssize_
+         return 0,[]
+ 
+     cdef ModField *F = new ModField(<long>modulus)
+-    cdef DenseMatrix *A = new DenseMatrix(F[0], <ModField.Element*>entries,<Py_ssize_t>nrows, <Py_ssize_t>ncols)
++    cdef DenseMatrix *A = new DenseMatrix(F[0], <Py_ssize_t>nrows, <Py_ssize_t>ncols, <ModField.Element*>entries)
+     cdef Py_ssize_t r = reducedRowEchelonize(A[0])
+     cdef Py_ssize_t i,j
+     for i in range(nrows):
diff --git a/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch b/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
index 3c64be100d2..1ff081b25e0 100644
--- a/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
+++ b/pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
@@ -1,8 +1,8 @@
 diff --git a/src/sage_docbuild/__init__.py b/src/sage_docbuild/__init__.py
-index 79005b903a..fbe6fe2595 100644
+index 8a5c1a19d2..21fd192642 100644
 --- a/src/sage_docbuild/__init__.py
 +++ b/src/sage_docbuild/__init__.py
-@@ -85,27 +85,6 @@ def builder_helper(type):
+@@ -89,27 +89,6 @@ def builder_helper(type):
      """
      Returns a function which builds the documentation for
      output type ``type``.
@@ -12,7 +12,7 @@ index 79005b903a..fbe6fe2595 100644
 -    Check that :trac:`25161` has been resolved::
 -
 -        sage: from sage_docbuild import DocBuilder, setup_parser
--        sage: DocBuilder._options = setup_parser().parse_args([])[0] # builder_helper needs _options to be set
+-        sage: DocBuilder._options = setup_parser().parse_args([]) # builder_helper needs _options to be set
 -
 -        sage: import sage_docbuild.sphinxbuild
 -        sage: def raiseBaseException():
@@ -30,7 +30,7 @@ index 79005b903a..fbe6fe2595 100644
      """
      def f(self, *args, **kwds):
          output_dir = self._output_dir(type)
-@@ -127,10 +106,9 @@ def builder_helper(type):
+@@ -131,10 +110,9 @@ def builder_helper(type):
          logger.debug(build_command)
  
          # Run Sphinx with Sage's special logger
@@ -44,10 +44,10 @@ index 79005b903a..fbe6fe2595 100644
              if ABORT_ON_ERROR:
                  raise
 diff --git a/src/sage_docbuild/sphinxbuild.py b/src/sage_docbuild/sphinxbuild.py
-index f58f6c61d7..ef51a55411 100644
+index d917c3e9d4..551cc8028a 100644
 --- a/src/sage_docbuild/sphinxbuild.py
 +++ b/src/sage_docbuild/sphinxbuild.py
-@@ -326,3 +326,8 @@ def runsphinx():
+@@ -327,3 +327,8 @@ def runsphinx():
          sys.stderr = saved_stderr
          sys.stdout.flush()
          sys.stderr.flush()
diff --git a/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
new file mode 100644
index 00000000000..1766cec3e35
--- /dev/null
+++ b/pkgs/applications/science/math/sage/python-modules/sage-docbuild.nix
@@ -0,0 +1,28 @@
+{ lib
+, buildPythonPackage
+, sage-src
+, sphinx
+}:
+
+buildPythonPackage rec {
+  version = src.version;
+  pname = "sage-docbuild";
+  src = sage-src;
+
+  propagatedBuildInputs = [
+    sphinx
+  ];
+
+  preBuild = ''
+    cd pkgs/sage-docbuild
+  '';
+
+  doCheck = false; # we will run tests in sagedoc.nix
+
+  meta = with lib; {
+    description = "Build system of the Sage documentation";
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+  };
+}
diff --git a/pkgs/applications/science/math/sage/python-modules/sage-setup.nix b/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
new file mode 100644
index 00000000000..50346153123
--- /dev/null
+++ b/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
@@ -0,0 +1,28 @@
+{ lib
+, buildPythonPackage
+, sage-src
+, pkgconfig # the python module, not the pkg-config alias
+}:
+
+buildPythonPackage rec {
+  version = src.version;
+  pname = "sage-setup";
+  src = sage-src;
+
+  buildInputs = [
+    pkgconfig
+  ];
+
+  preBuild = ''
+    cd pkgs/sage-setup
+  '';
+
+  doCheck = false; # sagelib depends on sage-setup, but sage-setup's tests depend on sagelib
+
+  meta = with lib; {
+    description = "Build system of the Sage library";
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
+    maintainers = teams.sage.members;
+  };
+}
diff --git a/pkgs/applications/science/math/sage/sage-env.nix b/pkgs/applications/science/math/sage/sage-env.nix
index ae0b9f7453b..e680c0c3b22 100644
--- a/pkgs/applications/science/math/sage/sage-env.nix
+++ b/pkgs/applications/science/math/sage/sage-env.nix
@@ -2,7 +2,7 @@
 , lib
 , writeTextFile
 , sagelib
-, sage_docbuild
+, sage-docbuild
 , env-locations
 , gfortran
 , bash
@@ -45,11 +45,10 @@
 , flint
 , gmp
 , mpfr
-, pynac
 , zlib
 , gsl
 , ntl
-, jdk8
+, jdk
 , less
 }:
 
@@ -60,8 +59,6 @@ assert (!blas.isILP64) && (!lapack.isILP64);
 # dependencies.
 
 let
-  jdk = jdk8; # TODO: remove override https://github.com/NixOS/nixpkgs/pull/89731
-
   runtimepath = (lib.makeBinPath ([
     "@sage-local@"
     "@sage-local@/build"
@@ -163,7 +160,6 @@ writeTextFile rec {
         gmp
         mpfr
         pari
-        pynac
         zlib
         eclib
         gsl
@@ -179,7 +175,6 @@ writeTextFile rec {
         glpk
         flint
         gap
-        pynac
         mpfr.dev
       ])
     }'
@@ -193,5 +188,5 @@ writeTextFile rec {
   '';
 } // { # equivalent of `passthru`, which `writeTextFile` doesn't support
   lib = sagelib;
-  docbuild = sage_docbuild;
+  docbuild = sage-docbuild;
 }
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index eb07434b4cc..a51e92cde52 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -57,24 +57,29 @@ let
   );
 in
 stdenv.mkDerivation rec {
-  version = "9.4";
+  version = "9.5";
   pname = "sage-src";
 
   src = fetchFromGitHub {
     owner = "sagemath";
     repo = "sage";
     rev = version;
-    sha256 = "sha256-jqkr4meG02KbTCMsGvyr1UbosS4ZuUJhPXU/InuS+9A=";
+    sha256 = "sha256-uOsLpsGpcIGs8Xr82X82MElnTB2E908gytyNJ8WVD5w=";
   };
 
   # Patches needed because of particularities of nix or the way this is packaged.
   # The goal is to upstream all of them and get rid of this list.
   nixPatches = [
-    # Make sure py2/py3 tests are only run when their expected context (all "sage"
-    # tests) are also run. That is necessary to test dochtml individually. See
-    # https://trac.sagemath.org/ticket/26110 for an upstream discussion.
-    # TODO: Determine if it is still necessary.
-    ./patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
+    # Since https://trac.sagemath.org/ticket/32174, some external features are
+    # marked as "safe" and get auto-detected, in which case the corresponding
+    # optional tests are executed. We disable auto-detection of safe features if
+    # we are doctesting with an "--optional" argument which does not include
+    # "sage", because tests from autodetected features expect context provided
+    # by running basic sage tests. This is necessary to test sagemath_doc_html
+    # separately. See https://trac.sagemath.org/ticket/26110 for a related
+    # upstream discussion (from the time when Sage still had optional py2/py3
+    # tags).
+    ./patches/Only-test-external-software-when-all-of-sage-is.patch
 
     # Fixes a potential race condition which can lead to transient doctest failures.
     ./patches/fix-ecl-race.patch
@@ -117,46 +122,6 @@ stdenv.mkDerivation rec {
     # Let's just assume warnings are expected until we update to 4.27.0.
     ./patches/fonttools-deprecation-warnings.patch
 
-    # https://trac.sagemath.org/ticket/32305
-    (fetchSageDiff {
-      base = "9.4";
-      name = "networkx-2.6-upgrade.patch";
-      rev = "9808325853ba9eb035115e5b056305a1c9d362a0";
-      sha256 = "sha256-gJSqycCtbAVr5qnVEbHFUvIuTOvaxFIeffpzd6nH4DE=";
-    })
-
-    # https://trac.sagemath.org/ticket/32420
-    (fetchSageDiff {
-      base = "9.5.beta2";
-      name = "sympy-1.9-update.patch";
-      rev = "beed4e16aff32e47d0c3b1c58cb1e2f4c38590f8";
-      sha256 = "sha256-3eJPfWfCrCAQ5filIn7FbzjRQeO9QyTIVl/HyRuqFtE=";
-    })
-
-    # https://trac.sagemath.org/ticket/32567
-    (fetchSageDiff {
-      base = "9.5.beta2";
-      name = "arb-2.21.0-update.patch";
-      rev = "eb3304dd521a3d5a9334e747a08e234bbf16b4eb";
-      sha256 = "sha256-XDkaY4VQGyESXI6zuD7nCNzyQOl/fmBFvAESH9+RRvk=";
-    })
-
-    # https://trac.sagemath.org/ticket/32797
-    (fetchSageDiff {
-      base = "9.5.beta7";
-      name = "pari-2.13.3-update.patch";
-      rev = "f5f7a86908daf60b25e66e6a189c51ada7e0a732";
-      sha256 = "sha256-H/caGx3q4KcdsyGe+ojV9bUTQ5y0siqM+QHgDbeEnbw=";
-    })
-
-    # https://trac.sagemath.org/ticket/32909
-    (fetchSageDiff {
-      base = "9.5.beta7";
-      name = "matplotlib-3.5-deprecation-warnings.patch";
-      rev = "a5127dc56fdf5c2e82f6bc781cfe78dbd04e97b7";
-      sha256 = "sha256-p23qUu9mgEUbdbX6cy7ArxZAtpcFjCKbgyxN4jWvj1o=";
-    })
-
     # https://trac.sagemath.org/ticket/32968
     (fetchSageDiff {
       base = "9.5.beta8";
@@ -164,6 +129,11 @@ stdenv.mkDerivation rec {
       rev = "fc84f82f52b6f05f512cb359ec7c100f93cf8841";
       sha256 = "sha256-bBbfdcnw/9LUOlY8rHJRbFJEdMXK4shosqTNaobTS1Q=";
     })
+
+    # Upstream has not upgraded to linbox 1.7 yet because it conflicts with
+    # pre-4.2.1p3 versions of Singular, but we don't have this problem.
+    # https://trac.sagemath.org/ticket/32959
+    ./patches/linbox-1.7-upgrade.patch
   ];
 
   patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
diff --git a/pkgs/applications/science/math/sage/sage-with-env.nix b/pkgs/applications/science/math/sage/sage-with-env.nix
index b74ec4007e6..df3a1467d53 100644
--- a/pkgs/applications/science/math/sage/sage-with-env.nix
+++ b/pkgs/applications/science/math/sage/sage-with-env.nix
@@ -18,7 +18,6 @@
 , eclib
 , ntl
 , ecm
-, pynac
 , pythonEnv
 }:
 
@@ -36,7 +35,6 @@ let
     blas lapack
     singular
     three
-    pynac
     giac
     gap
     pari
@@ -126,6 +124,10 @@ stdenv.mkDerivation rec {
     cp -r src/bin "$out/bin"
     cp -r build/bin "$out/build/bin"
 
+    # sage assumes the existence of sage-src-env-config.in means it's being executed in-tree. in this case, it
+    # adds SAGE_SRC/bin to PATH, breaking our wrappers
+    rm "$out/bin"/*.in "$out/build/bin"/*.in
+
     cp -f '${sage-env}/sage-env' "$out/bin/sage-env"
     substituteInPlace "$out/bin/sage-env" \
       --subst-var-by sage-local "$out"
diff --git a/pkgs/applications/science/math/sage/sage.nix b/pkgs/applications/science/math/sage/sage.nix
index 106f9eea309..5805a5c7b0c 100644
--- a/pkgs/applications/science/math/sage/sage.nix
+++ b/pkgs/applications/science/math/sage/sage.nix
@@ -62,7 +62,8 @@ stdenv.mkDerivation rec {
 
   meta = with lib; {
     description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
-    license = licenses.gpl2;
+    homepage = "https://www.sagemath.org";
+    license = licenses.gpl2Plus;
     maintainers = teams.sage.members;
   };
 }
diff --git a/pkgs/applications/science/math/sage/sage_docbuild.nix b/pkgs/applications/science/math/sage/sage_docbuild.nix
deleted file mode 100644
index ed78d46b445..00000000000
--- a/pkgs/applications/science/math/sage/sage_docbuild.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ buildPythonPackage
-, sage-src
-, sphinx
-}:
-
-buildPythonPackage rec {
-  version = src.version;
-  pname = "sage_docbuild";
-  src = sage-src;
-
-  propagatedBuildInputs = [
-    sphinx
-  ];
-
-  preBuild = ''
-    cd build/pkgs/sage_docbuild/src
-  '';
-
-  doCheck = false; # we will run tests in sagedoc.nix
-}
diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix
index 6016b3baeb4..489fc2edfe5 100644
--- a/pkgs/applications/science/math/sage/sagedoc.nix
+++ b/pkgs/applications/science/math/sage/sagedoc.nix
@@ -23,7 +23,7 @@ stdenv.mkDerivation rec {
     jmol
     cddlib
   ] ++ (with python3.pkgs; [
-    sage_docbuild
+    sage-docbuild
     psutil
     future
     sphinx
@@ -83,6 +83,6 @@ stdenv.mkDerivation rec {
 
   doCheck = true;
   checkPhase = ''
-    ${sage-with-env}/bin/sage -t --optional=dochtml --all
+    ${sage-with-env}/bin/sage -t --optional=sagemath_doc_html --all
   '';
 }
diff --git a/pkgs/applications/science/math/sage/sagelib.nix b/pkgs/applications/science/math/sage/sagelib.nix
index a884ad8899d..8d685c8da60 100644
--- a/pkgs/applications/science/math/sage/sagelib.nix
+++ b/pkgs/applications/science/math/sage/sagelib.nix
@@ -2,6 +2,7 @@
 , env-locations
 , perl
 , buildPythonPackage
+, m4
 , arb
 , blas
 , lapack
@@ -37,7 +38,7 @@
 , pkg-config
 , planarity
 , ppl
-, pynac
+, primecountpy
 , python
 , ratpoints
 , readline
@@ -49,11 +50,24 @@
 , singular
 , pip
 , jupyter_core
+, sage-setup
 , libhomfly
 , libbraiding
 , gmpy2
 , pplpy
 , sqlite
+, jupyter-client
+, ipywidgets
+, mpmath
+, rpy2
+, fpylll
+, scipy
+, sympy
+, matplotlib
+, pillow
+, ipykernel
+, networkx
+, sphinx # TODO: this is in setup.cfg, bug should we override it?
 }:
 
 assert (!blas.isILP64) && (!lapack.isILP64);
@@ -73,8 +87,10 @@ buildPythonPackage rec {
     perl
     jupyter_core
     pkg-config
+    sage-setup
     pip # needed to query installed packages
     lisp-compiler
+    m4
   ];
 
   buildInputs = [
@@ -116,7 +132,7 @@ buildPythonPackage rec {
     pari
     planarity
     ppl
-    pynac
+    primecountpy
     rankwidth
     ratpoints
     singular
@@ -130,6 +146,18 @@ buildPythonPackage rec {
     gmpy2
     pplpy
     sqlite
+    mpmath
+    rpy2
+    scipy
+    sympy
+    matplotlib
+    pillow
+    ipykernel
+    fpylll
+    networkx
+    jupyter-client
+    ipywidgets
+    sphinx
   ];
 
   preBuild = ''
@@ -148,8 +176,24 @@ buildPythonPackage rec {
     mkdir -p "$SAGE_SHARE/sage/ext/notebook-ipython"
     mkdir -p "var/lib/sage/installed"
 
-    # src/setup.py should not be used, see https://trac.sagemath.org/ticket/31377#comment:124
-    cd build/pkgs/sagelib/src
+    cd build/pkgs/sagelib
+
+    # some files, like Pipfile, pyproject.toml, requirements.txt and setup.cfg
+    # are generated by the bootstrap script using m4. these can fetch data from
+    # build/pkgs, either directly or via sage-get-system-packages.
+    sed -i 's/==2.1.0rc1/>=2.1.1/' ../gmpy2/install-requires.txt
+    sed -i 's/, <3.4//' ../rpy2/install-requires.txt
+    sed -i 's/, <4.3//' ../sphinx/install-requires.txt
+    sed -i '/sage_conf/d' src/setup.cfg.m4
+    sed -i '/sage_conf/d' src/requirements.txt.m4
+    for infile in src/*.m4; do
+        if [ -f "$infile" ]; then
+            outfile="src/$(basename $infile .m4)"
+            m4 "$infile" > "$outfile"
+        fi
+    done
+
+    cd src
   '';
 
   postInstall = ''
diff --git a/pkgs/applications/science/math/singular/default.nix b/pkgs/applications/science/math/singular/default.nix
index b543252e871..23712061160 100644
--- a/pkgs/applications/science/math/singular/default.nix
+++ b/pkgs/applications/science/math/singular/default.nix
@@ -1,7 +1,7 @@
 { stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
 , lib
-, fetchpatch
 , autoreconfHook
+, buildPackages
 , sharutils
 , file
 , flint
@@ -11,6 +11,7 @@
 , lrcalc
 , doxygen
 , graphviz
+, latex2html
 # upstream generates docs with texinfo 4. later versions of texinfo
 # use letters instead of numbers for post-appendix chapters, and we
 # want it to match the upstream format because sage depends on it.
@@ -22,66 +23,25 @@
 
 stdenv.mkDerivation rec {
   pname = "singular";
-  version = "4.2.0p2";
+  version = "4.3.0";
 
-  # since the tarball does not contain tests or documentation (and
-  # there is no separate tests tarball for 4.2.0), we fetch from
-  # GitHub.
+  # since the tarball does not contain tests, we fetch from GitHub.
   src = fetchFromGitHub {
     owner = "Singular";
     repo = "Singular";
 
-    # 4.2.0p2 is not tagged, but the tarball matches the commit below.
-    rev = "6f68939ddf612d96e3caaaaa8275f77613ac1da8";
-    sha256 = "sha256-BJNzYylzDqD/5YjzjxPRb/c96tYiuGy9Y+A7qf3ZSG8=";
-
-    # if a release is tagged it will be in the format below.
-    # rev = "Release${lib.replaceStrings ["."] ["-"] version}";
+    # if a release is tagged (which sometimes does not happen), it will
+    # be in the format below.
+    # rev = "Release-${lib.replaceStrings ["."] ["-"] version}";
+    rev = "d895b0f1f543c61eb03adddad20f08655a419d4e";
+    sha256 = "sha256-c5Qr6VUuPKjfw8fowjJJz3oGAyUwo/K0WeMvU5djzVA=";
 
     # the repository's .gitattributes file contains the lines "/Tst/
     # export-ignore" and "/doc/ export-ignore" so some directories are
-    # not included in the tarball downloaded by fetchzip. setting
-    # fetchSubmodules works around this by using fetchgit instead of
-    # fetchzip.
-    fetchSubmodules = true;
+    # not included in the tarball downloaded by fetchzip.
+    forceFetchGit = true;
   };
 
-  patches = [
-    # fix timeouts when docbuilding with >= 64 cpus
-    # https://github.com/Singular/Singular/issues/1117
-    ./vspace-MAX_PROCESS.patch
-
-    # add aarch64 support to cpu-check.m4. copied from redhat.
-    ./redhat-aarch64.patch
-
-    # the newest version of ax-prog-cc-for-build.m4 seems to trigger
-    # linker errors. see
-    # https://github.com/alsa-project/alsa-firmware/issues/3 for a
-    # related issue.
-    ./use-older-ax-prog-cc-for-build.patch
-
-    # https://github.com/Singular/Singular/issues/1086
-    (fetchpatch {
-      name = "schubert-lib-fails-with-too-many-cpus.patch";
-      url = "https://github.com/Singular/Singular/commit/3cda50c00a849455efa2502e56596955491a353a.patch";
-      sha256 = "sha256-fgYd+2vT32w5Ki8kKx6PfZn2e4QSJcYWOwEFXtc+lSA=";
-    })
-  ] ++ lib.optionals enableDocs [
-    # singular supports building without 4ti2, bertini, normaliz or
-    # topcom just fine, but the docbuilding does not skip manual pages
-    # tagged as depending on those binaries (probably a bug in
-    # doc2tex.pl::HandleLib, since it seems to ignore "-exclude"
-    # argumens). skip them manually.
-    ./disable-docs-for-optional-unpackaged-deps.patch
-
-    # fix some non-ascii characters in doc/decodegb.doc
-    (fetchpatch {
-      name = "decodegb-ascii.patch";
-      url = "https://github.com/Singular/Singular/commit/36966d9009de572ee4dbc487f3e5744098fe91be.patch";
-      sha256 = "sha256-9WcEov/oOQRC584ag6WVHFwY2aCjbM75HWyvZoEwppw=";
-    })
-  ];
-
   configureFlags = [
     "--with-ntl=${ntl}"
     "--disable-pyobject-module"
@@ -114,6 +74,7 @@ stdenv.mkDerivation rec {
   ] ++ lib.optionals enableGfanlib [
     cddlib
   ];
+
   nativeBuildInputs = [
     bison
     perl
@@ -123,9 +84,11 @@ stdenv.mkDerivation rec {
   ] ++ lib.optionals enableDocs [
     doxygen
     graphviz
+    latex2html
     texinfo4
     texlive.combined.scheme-small
   ];
+  depsBuildBuild = [ buildPackages.stdenv.cc ];
 
   preAutoreconf = ''
     find . -type f -readable -writable -exec sed \
@@ -137,21 +100,14 @@ stdenv.mkDerivation rec {
 
   hardeningDisable = lib.optional stdenv.isi686 "stackprotector";
 
-  # The Makefile actually defaults to `make install` anyway
-  buildPhase = ''
-    # do nothing
-  '';
-
   doCheck = true; # very basic checks, does not test any libraries
 
   installPhase = ''
-    mkdir -p "$out"
-    cp -r Singular/LIB "$out/lib"
     make install
   '' + lib.optionalString enableDocs ''
-    # Sage uses singular.hlp (which is not in the tarball)
+    # Sage uses singular.info, which is not installed by default
     mkdir -p $out/share/info
-    cp doc/singular.hlp $out/share/info
+    cp doc/singular.info $out/share/info
   '' + ''
     # Make sure patchelf picks up the right libraries
     rm -rf libpolys factory resources omalloc Singular
@@ -211,5 +167,6 @@ stdenv.mkDerivation rec {
     license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
     homepage = "http://www.singular.uni-kl.de";
     downloadPage = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/";
+    mainProgram = "Singular";
   };
 }
diff --git a/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch b/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch
deleted file mode 100644
index 46d92922f3c..00000000000
--- a/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch
+++ /dev/null
@@ -1,112 +0,0 @@
-commit 9e8b044d982e132cf35a106a1cc0cf7e77b27f7c
-Author: Mauricio Collares <mauricio@collares.org>
-Date:   Thu Apr 15 20:33:21 2021 -0300
-
-    Disable manual sections using optional packages not yet in Nixpkgs
-
-        * normaliz.lib depends on normaliz.
-        * polymake.lib depends on topcom.
-        * recover.lib depends on bertini.
-        * sing4ti2.lib depends on 4ti2.
-        * tateProdCplxNegGrad.lib uses multigrading.lib, which depends on 4ti2.
-
-diff --git a/doc/singular.doc b/doc/singular.doc
-index 64b969d39..e704f95f0 100644
---- a/doc/singular.doc
-+++ b/doc/singular.doc
-@@ -407,7 +407,6 @@ LIB "all.lib";
- * nfmodsyz_lib:: Syzygy modules of submodules of free modules over algebraic number fields
- * noether_lib:: Noether normalization of an ideal
- * normal_lib:: procedure for normalization
--* normaliz_lib:: integral closure, normalization for monomial ideals, toric ideals
- * pointid_lib:: factorized lex GB of the vanishing ideal of a set of points
- * primdec_lib:: procedures for primary decomposition
- * primdecint_lib:: primary decomposition over the integers
-@@ -416,7 +415,6 @@ LIB "all.lib";
- * reesclos_lib:: Rees Algebra and integral closure of an ideal
- * rstandard_lib:: Janet bases and border bases for ideals
- * sagbi_lib:: Subalgebras bases Analogous to Groebner bases for ideals
--* sing4ti2_lib:: interface to program 4ti2
- * symodstd_lib:: Groebner bases for symmetric ideals
- * toric_lib:: toric ideals
- @end menu
-@@ -521,10 +519,6 @@ LIB "all.lib";
- @node normal_lib
- @subsection normal_lib
- @c lib normal.lib
--@c ---------------------------------------------------------
--@node normaliz_lib
--@subsection normaliz_lib
--@c lib normaliz.lib tag:normaliz
- @c ----------------------------------------------------------
- @node pointid_lib
- @subsection pointid_lib
-@@ -558,10 +552,6 @@ LIB "all.lib";
- @subsection sagbi_lib
- @c lib sagbi.lib
- @c ---------------------------------------------------------
--@node sing4ti2_lib
--@subsection sing4ti2_lib
--@c lib sing4ti2.lib tag:sing4ti2
--@c ----------------------------------------------------------
- @node symodstd_lib
- @subsection symodstd_lib
- @c lib symodstd.lib
-@@ -873,7 +863,6 @@ iniD, reslist, sumlist, dividelist, createlist
- * solve_lib:: procedures to solve polynomial systems
- * triang_lib:: procedures for decomposing zero-dimensional ideals
- * ntsolve_lib:: one real solution of polynomial systems (Newton iteration)
--* recover_lib:: Hybrid numerical/symbolical algorithms
- * rootisolation_lib:: real root isolation with intervals
- * signcond_lib:: computing realizable sign conditions
- * zeroset_lib:: procedures for roots and factorization
-@@ -904,10 +893,6 @@ iniD, reslist, sumlist, dividelist, createlist
- @subsection ntsolve_lib
- @c lib ntsolve.lib
- @c ---------------------------------------------------------
--@node recover_lib
--@subsection recover_lib
--@c lib recover.lib tag:bertini
--@c ----------------------------------------------------------
- @node rootisolation_lib
- @subsection rootisolation_lib
- @c lib rootisolation.lib
-@@ -1108,7 +1093,6 @@ but not for serious computations.
- * cimonom_lib:: complete intersection for toric ideals
- * gfan_lib:: A gfanlib interface for Singular
- * gitfan_lib:: Compute GIT-fans
--* polymake_lib:: interface to TOPCOM
- * realizationMatroids_lib:: Realizability for Tropical Fan Curves
- * tropical_lib:: interface to gfan
- * tropicalNewton_lib:: Newton polygons in tropical geometry
-@@ -1125,10 +1109,7 @@ but not for serious computations.
- @node gitfan_lib
- @subsection gitfan_lib
- @c lib gitfan.lib
--@c ----------------------------------------------------------
--@node polymake_lib
--@subsection polymake_lib
--@c lib polymake.lib tag:topcom
-+
- @c ----------------------------------------------------------
- @node realizationMatroids_lib
- @subsection realizationMatroids_lib
-@@ -1219,7 +1200,6 @@ Comments should be send to the author of the library directly.
- * stanleyreisner_lib:: T1 and T2 for a general Stanley-Reiser ring
- * swalk_lib:: Sagbi Walk Conversion Algorithm
- * systhreads_lib:: multi-threaded objects
--* tateProdCplxNegGrad_lib:: sheaf cohomology on product of projective spaces
- * VecField_lib:: vector fields
- @end menu
- @c ----------------------------------------------------------
-@@ -1310,10 +1290,6 @@ Todos/Issues:
- @subsection systhreads_lib
- @c lib systhreads.lib
- @c ---------------------------------------------------------
--@node tateProdCplxNegGrad_lib
--@subsection tateProdCplxNegGrad_lib
--@c lib tateProdCplxNegGrad.lib
--@c ---------------------------------------------------------
- @node VecField_lib
- @subsection VecField_lib
- @c lib VecField.lib
diff --git a/pkgs/applications/science/math/singular/redhat-aarch64.patch b/pkgs/applications/science/math/singular/redhat-aarch64.patch
deleted file mode 100644
index e0db6e87f99..00000000000
--- a/pkgs/applications/science/math/singular/redhat-aarch64.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-diff --git a/m4/cpu-check.m4 b/m4/cpu-check.m4
-index 3cf0a7f08..12bb926ac 100644
---- a/m4/cpu-check.m4
-+++ b/m4/cpu-check.m4
-@@ -37,6 +37,18 @@ if test "$ac_cv_singcpuname" = ppc; then
-   AC_DEFINE(SI_CPU_PPC,1,"PPC")
-   AC_SUBST(SI_CPU_PPC)
- fi
-+if test "$ac_cv_singcpuname" = arm -o "$ac_cv_singcpuname" = armel; then
-+  AC_DEFINE(SI_CPU_ARM,1,"ARM")
-+  AC_SUBST(SI_CPU_ARM)
-+fi
-+if test "$ac_cv_singcpuname" = aarch64; then
-+  AC_DEFINE(SI_CPU_AARCH64,1,"AARCH64")
-+  AC_SUBST(SI_CPU_AARCH64)
-+fi
-+if test "$ac_cv_singcpuname" = s390; then
-+  AC_DEFINE(SI_CPU_S390,1,"S390")
-+  AC_SUBST(SI_CPU_S390)
-+fi
- 
- # UNAME and PATH
- AC_MSG_CHECKING(uname for Singular)
-@@ -65,6 +77,14 @@ dnl testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache
-   [powerpc*|ppc*], [AC_DEFINE(HAVE_GENERIC_MULT,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)],
- dnl the following settings seems to be better on arm processors
-   [arm*], [],
-+dnl FIXME: need to run some tests
-+  [aarch64*], [
-+            AC_DEFINE(HAVE_MULT_MOD,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)
-+            AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)
-+            AC_DEFINE(HAVE_DIV_MOD,1,division using extend euclidian algorithm otherwise using tables of logartihms)
-+            ],
-+dnl FIXME: need to run some tests
-+  [s390*], [AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)],
-   []
- )
- 
diff --git a/pkgs/applications/science/math/singular/use-older-ax-prog-cc-for-build.patch b/pkgs/applications/science/math/singular/use-older-ax-prog-cc-for-build.patch
deleted file mode 100644
index f664378617c..00000000000
--- a/pkgs/applications/science/math/singular/use-older-ax-prog-cc-for-build.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-diff --git a/m4/ax_prog_cc_for_build.m4 b/m4/ax_prog_cc_for_build.m4
-index f7410d74b..12cb005a5 100644
---- a/m4/ax_prog_cc_for_build.m4
-+++ b/m4/ax_prog_cc_for_build.m4
-@@ -32,35 +32,31 @@
- #   and this notice are preserved. This file is offered as-is, without any
- #   warranty.
- 
--#serial 18
-+#serial 9
- 
- AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD])
- AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl
- AC_REQUIRE([AC_PROG_CC])dnl
- AC_REQUIRE([AC_PROG_CPP])dnl
--AC_REQUIRE([AC_CANONICAL_BUILD])dnl
-+AC_REQUIRE([AC_EXEEXT])dnl
-+AC_REQUIRE([AC_CANONICAL_HOST])dnl
- 
- dnl Use the standard macros, but make them use other variable names
- dnl
- pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl
--pushdef([ac_cv_prog_cc_c89], ac_cv_build_prog_cc_c89)dnl
- pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl
- pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl
- pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl
- pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl
--pushdef([ac_cv_c_compiler_gnu], ac_cv_build_c_compiler_gnu)dnl
- pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl
- pushdef([ac_cv_objext], ac_cv_build_objext)dnl
- pushdef([ac_exeext], ac_build_exeext)dnl
- pushdef([ac_objext], ac_build_objext)dnl
- pushdef([CC], CC_FOR_BUILD)dnl
- pushdef([CPP], CPP_FOR_BUILD)dnl
--pushdef([GCC], GCC_FOR_BUILD)dnl
- pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
- pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
--pushdef([EXEEXT], BUILD_EXEEXT)dnl
- pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
--pushdef([OBJEXT], BUILD_OBJEXT)dnl
- pushdef([host], build)dnl
- pushdef([host_alias], build_alias)dnl
- pushdef([host_cpu], build_cpu)dnl
-@@ -71,29 +67,27 @@ pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
- pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
- pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
- pushdef([ac_cv_host_os], ac_cv_build_os)dnl
--pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
--pushdef([am_cv_CC_dependencies_compiler_type], am_cv_build_CC_dependencies_compiler_type)dnl
--pushdef([am_cv_prog_cc_c_o], am_cv_build_prog_cc_c_o)dnl
--pushdef([cross_compiling], cross_compiling_build)dnl
-+pushdef([ac_cpp], ac_build_cpp)dnl
-+pushdef([ac_compile], ac_build_compile)dnl
-+pushdef([ac_link], ac_build_link)dnl
- 
--cross_compiling_build=no
-+save_cross_compiling=$cross_compiling
-+save_ac_tool_prefix=$ac_tool_prefix
-+cross_compiling=no
-+ac_tool_prefix=
- 
--ac_build_tool_prefix=
--AS_IF([test -n "$build"],      [ac_build_tool_prefix="$build-"],
--      [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
--
--AC_LANG_PUSH([C])
- AC_PROG_CC
--_AC_COMPILER_EXEEXT
--_AC_COMPILER_OBJEXT
- AC_PROG_CPP
-+AC_EXEEXT
-+
-+ac_tool_prefix=$save_ac_tool_prefix
-+cross_compiling=$save_cross_compiling
- 
- dnl Restore the old definitions
- dnl
--popdef([cross_compiling])dnl
--popdef([am_cv_prog_cc_c_o])dnl
--popdef([am_cv_CC_dependencies_compiler_type])dnl
--popdef([ac_tool_prefix])dnl
-+popdef([ac_link])dnl
-+popdef([ac_compile])dnl
-+popdef([ac_cpp])dnl
- popdef([ac_cv_host_os])dnl
- popdef([ac_cv_host_vendor])dnl
- popdef([ac_cv_host_cpu])dnl
-@@ -104,33 +98,25 @@ popdef([host_vendor])dnl
- popdef([host_cpu])dnl
- popdef([host_alias])dnl
- popdef([host])dnl
--popdef([OBJEXT])dnl
- popdef([LDFLAGS])dnl
--popdef([EXEEXT])dnl
- popdef([CPPFLAGS])dnl
- popdef([CFLAGS])dnl
--popdef([GCC])dnl
- popdef([CPP])dnl
- popdef([CC])dnl
- popdef([ac_objext])dnl
- popdef([ac_exeext])dnl
- popdef([ac_cv_objext])dnl
- popdef([ac_cv_exeext])dnl
--popdef([ac_cv_c_compiler_gnu])dnl
- popdef([ac_cv_prog_cc_g])dnl
- popdef([ac_cv_prog_cc_cross])dnl
- popdef([ac_cv_prog_cc_works])dnl
--popdef([ac_cv_prog_cc_c89])dnl
- popdef([ac_cv_prog_gcc])dnl
- popdef([ac_cv_prog_CPP])dnl
- 
--dnl restore global variables ac_ext, ac_cpp, ac_compile,
--dnl ac_link, ac_compiler_gnu (dependant on the current
--dnl language after popping):
--AC_LANG_POP([C])
--
- dnl Finally, set Makefile variables
- dnl
-+BUILD_EXEEXT=$ac_build_exeext
-+BUILD_OBJEXT=$ac_build_objext
- AC_SUBST(BUILD_EXEEXT)dnl
- AC_SUBST(BUILD_OBJEXT)dnl
- AC_SUBST([CFLAGS_FOR_BUILD])dnl
-diff --git a/m4/ax_prog_cxx_for_build.m4 b/m4/ax_prog_cxx_for_build.m4
-index 4d976769f..17c19a89f 100644
---- a/m4/ax_prog_cxx_for_build.m4
-+++ b/m4/ax_prog_cxx_for_build.m4
-@@ -31,7 +31,7 @@
- #   and this notice are preserved. This file is offered as-is, without any
- #   warranty.
- 
--#serial 4
-+#serial 3
- 
- AU_ALIAS([AC_PROG_CXX_FOR_BUILD], [AX_PROG_CXX_FOR_BUILD])
- AC_DEFUN([AX_PROG_CXX_FOR_BUILD], [dnl
-@@ -49,7 +49,6 @@ pushdef([ac_cv_prog_cxx_cross], ac_cv_build_prog_cxx_cross)dnl
- pushdef([ac_cv_prog_cxx_g], ac_cv_build_prog_cxx_g)dnl
- pushdef([CXX], CXX_FOR_BUILD)dnl
- pushdef([CXXCPP], CXXCPP_FOR_BUILD)dnl
--pushdef([GXX], GXX_FOR_BUILD)dnl
- pushdef([CXXFLAGS], CXXFLAGS_FOR_BUILD)dnl
- pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
- pushdef([CXXCPPFLAGS], CXXCPPFLAGS_FOR_BUILD)dnl
-@@ -63,25 +62,26 @@ pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl
- pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl
- pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl
- pushdef([ac_cv_host_os], ac_cv_build_os)dnl
--pushdef([ac_tool_prefix], ac_build_tool_prefix)dnl
--pushdef([am_cv_CXX_dependencies_compiler_type], am_cv_build_CXX_dependencies_compiler_type)dnl
--pushdef([cross_compiling], cross_compiling_build)dnl
-+pushdef([ac_cxxcpp], ac_build_cxxcpp)dnl
-+pushdef([ac_compile], ac_build_compile)dnl
-+pushdef([ac_link], ac_build_link)dnl
- 
--cross_compiling_build=no
-+save_cross_compiling=$cross_compiling
-+save_ac_tool_prefix=$ac_tool_prefix
-+cross_compiling=no
-+ac_tool_prefix=
- 
--ac_build_tool_prefix=
--AS_IF([test -n "$build"],      [ac_build_tool_prefix="$build-"],
--      [test -n "$build_alias"],[ac_build_tool_prefix="$build_alias-"])
--
--AC_LANG_PUSH([C++])
- AC_PROG_CXX
- AC_PROG_CXXCPP
- 
-+ac_tool_prefix=$save_ac_tool_prefix
-+cross_compiling=$save_cross_compiling
-+
- dnl Restore the old definitions
- dnl
--popdef([cross_compiling])dnl
--popdef([am_cv_CXX_dependencies_compiler_type])dnl
--popdef([ac_tool_prefix])dnl
-+popdef([ac_link])dnl
-+popdef([ac_compile])dnl
-+popdef([ac_cxxcpp])dnl
- popdef([ac_cv_host_os])dnl
- popdef([ac_cv_host_vendor])dnl
- popdef([ac_cv_host_cpu])dnl
-@@ -103,10 +103,6 @@ popdef([ac_cv_prog_cxx_works])dnl
- popdef([ac_cv_prog_gxx])dnl
- popdef([ac_cv_prog_CXXCPP])dnl
- 
--dnl restore global variables (dependant on the current
--dnl language after popping):
--AC_LANG_POP([C++])
--
- dnl Finally, set Makefile variables
- dnl
- AC_SUBST([CXXFLAGS_FOR_BUILD])dnl
diff --git a/pkgs/applications/science/math/singular/vspace-MAX_PROCESS.patch b/pkgs/applications/science/math/singular/vspace-MAX_PROCESS.patch
deleted file mode 100644
index 78d658f926e..00000000000
--- a/pkgs/applications/science/math/singular/vspace-MAX_PROCESS.patch
+++ /dev/null
@@ -1,35 +0,0 @@
-diff --git a/kernel/GBEngine/kChinese.cc b/kernel/GBEngine/kChinese.cc
-index 829a66609..84655caf2 100644
---- a/kernel/GBEngine/kChinese.cc
-+++ b/kernel/GBEngine/kChinese.cc
-@@ -209,6 +209,8 @@ ideal id_ChineseRemainder_0(ideal *xx, number *q, int rl, const ring r)
-     return NULL;
-   }
-   int cpus=(int)(long)feOptValue(FE_OPT_CPUS);
-+  if (cpus>=vspace::internals::MAX_PROCESS)
-+    cpus=vspace::internals::MAX_PROCESS-1;
-   if ((cpus==1) || (2*cpus>=cnt))
-     /* at least 2 polys for each process, or switch to seriell version */
-     return id_ChineseRemainder(xx,q,rl,r);
-@@ -295,6 +297,8 @@ ideal id_Farey_0(ideal x, number N, const ring r)
- {
-   int cnt=IDELEMS(x)*x->nrows;
-   int cpus=(int)(long)feOptValue(FE_OPT_CPUS);
-+  if (cpus>=vspace::internals::MAX_PROCESS)
-+    cpus=vspace::internals::MAX_PROCESS-1;
-   if (2*cpus>=cnt) /* at least 2 polys for each process, 
-                      or switch to seriell version */
-     return id_Farey(x,N,r);
-diff --git a/kernel/GBEngine/kverify.cc b/kernel/GBEngine/kverify.cc
-index 909d84994..aa06d6624 100644
---- a/kernel/GBEngine/kverify.cc
-+++ b/kernel/GBEngine/kverify.cc
-@@ -176,6 +176,8 @@ BOOLEAN kVerify2(ideal F, ideal Q)
-   /*---------------------------------------------------------------------*/
-   BOOLEAN all_okay=TRUE;
-   int cpus=(int)(long)feOptValue(FE_OPT_CPUS);
-+  if (cpus>=vspace::internals::MAX_PROCESS)
-+    cpus=vspace::internals::MAX_PROCESS-1;
-   int parent_pid=getpid();
-   using namespace vspace;
-   vmem_init();