summary refs log tree commit diff
path: root/pkgs/applications/science/math/sage
diff options
context:
space:
mode:
authorMasanori Ogino <167209+omasanori@users.noreply.github.com>2020-10-22 17:20:17 +0900
committerMauricio Collares <mauricio@collares.org>2020-12-14 19:24:18 -0300
commit5c4136daf7c182b631ab0f298d30464d88086f40 (patch)
treedeb156f39395e0f589140112ed7d8124a817f3ee /pkgs/applications/science/math/sage
parentdd95aa337e23a8a48fe82f0f7b1cced8bc03e379 (diff)
downloadnixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar.gz
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar.bz2
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar.lz
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar.xz
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.tar.zst
nixpkgs-5c4136daf7c182b631ab0f298d30464d88086f40.zip
sage: 8.9 -> 9.2
Diffstat (limited to 'pkgs/applications/science/math/sage')
-rw-r--r--pkgs/applications/science/math/sage/default.nix33
-rw-r--r--pkgs/applications/science/math/sage/flask-oldsessions.nix36
-rw-r--r--pkgs/applications/science/math/sage/flask-openid.nix28
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch21
-rw-r--r--pkgs/applications/science/math/sage/patches/do-not-test-find-library.patch33
-rw-r--r--pkgs/applications/science/math/sage/patches/docutils-0.15.patch24
-rw-r--r--pkgs/applications/science/math/sage/patches/ignore-cmp-deprecation.patch30
-rw-r--r--pkgs/applications/science/math/sage/patches/ignore-werkzeug-immutable-dict-deprecation.patch12
-rw-r--r--pkgs/applications/science/math/sage/patches/pari-stackwarn.patch20
-rw-r--r--pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch28
-rw-r--r--pkgs/applications/science/math/sage/patches/sagenb-cmp-deprecation.patch13
-rw-r--r--pkgs/applications/science/math/sage/patches/sympow-cache.patch14
-rw-r--r--pkgs/applications/science/math/sage/pybrial.nix25
-rw-r--r--pkgs/applications/science/math/sage/python-openid.nix40
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix74
-rw-r--r--pkgs/applications/science/math/sage/sage-with-env.nix6
-rw-r--r--pkgs/applications/science/math/sage/sage.nix1
-rw-r--r--pkgs/applications/science/math/sage/sagedoc.nix2
-rw-r--r--pkgs/applications/science/math/sage/sagelib.nix6
-rw-r--r--pkgs/applications/science/math/sage/sagenb.nix57
20 files changed, 66 insertions, 437 deletions
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index caf51c3da25..2a95e9a5985 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -9,30 +9,11 @@
 let
   inherit (pkgs) symlinkJoin callPackage nodePackages;
 
-  # https://trac.sagemath.org/ticket/15980 for tracking of python3 support
-  python = pkgs.python2.override {
+  python = pkgs.python3.override {
     packageOverrides = self: super: {
-      # python packages that appear unmaintained and were not accepted into the nixpkgs
-      # tree because of that. These packages are only dependencies of the more-or-less
-      # deprecated sagenb. However sagenb is still a default dependency and the doctests
-      # depend on it.
-      # See https://github.com/NixOS/nixpkgs/pull/38787 for a discussion.
-      # The dependency on the sage notebook (and therefore these packages) will be
-      # removed in the future:
-      # https://trac.sagemath.org/ticket/25837
-      flask-oldsessions = self.callPackage ./flask-oldsessions.nix {};
-      flask-openid = self.callPackage ./flask-openid.nix {};
-      python-openid = self.callPackage ./python-openid.nix {};
-      sagenb = self.callPackage ./sagenb.nix {
-        mathjax = nodePackages.mathjax;
-      };
-
-      # Package with a cyclic dependency with sage
-      pybrial = self.callPackage ./pybrial.nix {};
-
       # `sagelib`, i.e. all of sage except some wrappers and runtime dependencies
       sagelib = self.callPackage ./sagelib.nix {
-        inherit flint ecl arb;
+        inherit flint arb;
         inherit sage-src env-locations pynac singular;
         linbox = pkgs.linbox.override { withSage = true; };
         pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig
@@ -59,7 +40,7 @@ let
   # A bash script setting various environment variables to tell sage where
   # the files its looking fore are located. Also see `sage-env`.
   env-locations = callPackage ./env-locations.nix {
-    inherit pari_data ecl;
+    inherit pari_data;
     inherit singular maxima-ecl;
     cysignals = python.pkgs.cysignals;
     three = nodePackages.three;
@@ -71,7 +52,7 @@ let
   sage-env = callPackage ./sage-env.nix {
     sagelib = python.pkgs.sagelib;
     inherit env-locations;
-    inherit python ecl singular palp flint pynac pythonEnv maxima-ecl;
+    inherit python singular palp flint pynac pythonEnv maxima-ecl;
     pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig
   };
 
@@ -102,8 +83,6 @@ let
 
   pythonRuntimeDeps = with python.pkgs; [
     sagelib
-    pybrial
-    sagenb
     cvxopt
     networkx
     service-identity
@@ -129,7 +108,6 @@ let
 
   singular = pkgs.singular.override { inherit flint; };
 
-  # https://trac.sagemath.org/ticket/26625
   maxima-ecl = pkgs.maxima-ecl;
 
   # *not* to confuse with the python package "pynac"
@@ -161,9 +139,6 @@ let
       pari-seadata-small
     ];
   };
-
-  # https://trac.sagemath.org/ticket/22191
-  ecl = pkgs.ecl_16_1_2;
 in
 # A wrapper around sage that makes sure sage finds its docs (if they were build).
 callPackage ./sage.nix {
diff --git a/pkgs/applications/science/math/sage/flask-oldsessions.nix b/pkgs/applications/science/math/sage/flask-oldsessions.nix
deleted file mode 100644
index 86fe9912c19..00000000000
--- a/pkgs/applications/science/math/sage/flask-oldsessions.nix
+++ /dev/null
@@ -1,36 +0,0 @@
-{ stdenv
-, buildPythonPackage
-, fetchFromGitHub
-, python
-, flask
-}:
-
-buildPythonPackage rec {
-  pname = "Flask-OldSessions";
-  version = "0.10";
-
-  # no artifact on pypi: https://github.com/mitsuhiko/flask-oldsessions/issues/1
-  src = fetchFromGitHub {
-    owner = "mitsuhiko";
-    repo = "flask-oldsessions";
-    rev = version;
-    sha256 = "04b5m8njjiwld9a0zw55iqwvyjgwcpdbhz1cic8nyhgcmypbicqn";
-  };
-
-  propagatedBuildInputs = [
-    flask
-  ];
-
-  # missing module flask.testsuite, probably assumes an old version of flask
-  doCheck = false;
-  checkPhase = ''
-    ${python.interpreter} run-tests.py
-  '';
-
-  meta = with stdenv.lib; {
-    description = "Provides a session class that works like the one in Flask before 0.10.";
-    license = licenses.bsd2;
-    maintainers = teams.sage.members;
-    homepage = "https://github.com/mitsuhiko/flask-oldsessions";
-  };
-}
diff --git a/pkgs/applications/science/math/sage/flask-openid.nix b/pkgs/applications/science/math/sage/flask-openid.nix
deleted file mode 100644
index 900b033429e..00000000000
--- a/pkgs/applications/science/math/sage/flask-openid.nix
+++ /dev/null
@@ -1,28 +0,0 @@
-{ stdenv
-, buildPythonPackage
-, fetchPypi
-, flask
-, python-openid
-}:
-
-buildPythonPackage rec {
-  pname = "Flask-OpenID";
-  version = "1.2.5";
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "1aycwmwi7ilcaa5ab8hm0bp6323zl8z25q9ha0gwrl8aihfgx3ss";
-  };
-
-  propagatedBuildInputs = [
-    flask
-    python-openid
-  ];
-
-  meta = with stdenv.lib; {
-    description = "Adds openid support to flask applications";
-    license = licenses.bsd2;
-    maintainers = teams.sage.members;
-    homepage = "https://pythonhosted.org/Flask-OpenID/";
-  };
-}
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
index 8cd80281d0e..d5c19a54fd9 100644
--- 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
@@ -1,17 +1,17 @@
-From 8218bd4fdeb4c92de8af0d3aabec55980fc4fb3d Mon Sep 17 00:00:00 2001
+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 | 5 +++--
- 1 file changed, 3 insertions(+), 2 deletions(-)
+ 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 bf18df8b2b..935c67abf7 100644
+index 2d93841e50..6d156e29a1 100644
 --- a/src/sage/doctest/control.py
 +++ b/src/sage/doctest/control.py
-@@ -362,7 +362,8 @@ class DocTestController(SageObject):
+@@ -375,7 +375,8 @@ class DocTestController(SageObject):
                      if not optionaltag_regex.search(o):
                          raise ValueError('invalid optional tag {!r}'.format(o))
  
@@ -21,15 +21,6 @@ index bf18df8b2b..935c67abf7 100644
  
          self.options = options
  
-@@ -765,7 +766,7 @@ class DocTestController(SageObject):
-             sage: DC = DocTestController(DD, [dirname])
-             sage: DC.expand_files_into_sources()
-             sage: sorted(DC.sources[0].options.optional)  # abs tol 1
--            ['guava', 'magma', 'py2']
-+            ['guava', 'magma']
- 
-         We check that files are skipped appropriately::
- 
 -- 
-2.18.1
+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 3f844e1b1ef..98175920238 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,17 +1,17 @@
 diff --git a/src/sage/env.py b/src/sage/env.py
-index 061b94f3f1..67cd091540 100644
+index 1ddfc7cfb9..45033d6328 100644
 --- a/src/sage/env.py
 +++ b/src/sage/env.py
-@@ -189,88 +189,13 @@ var('MAXIMA_FAS')
+@@ -203,97 +203,13 @@ var('ARB_LIBRARY',                   'arb')
  var('SAGE_BANNER', '')
  var('SAGE_IMPORTALL', 'yes')
  
 -
 -def _get_shared_lib_filename(libname, *additional_libnames):
 -    """
--    Return the full path to a shared library file installed in the standard
--    location for the system within the ``LIBDIR`` prefix (or
--    ``$SAGE_LOCAL/lib`` in the case of manual build of Sage).
+-    Return the full path to a shared library file installed in
+-    ``$SAGE_LOCAL/lib`` or the directories associated with the
+-    Python sysconfig.
 -
 -    This can also be passed more than one library name (e.g. for cases where
 -    some library may have multiple names depending on the platform) in which
@@ -25,7 +25,7 @@ index 061b94f3f1..67cd091540 100644
 -    For distributions like Debian that use a multiarch layout, we also try the
 -    multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
 -
--    Returns ``None`` if the file does not exist.
+-    This returns ``None`` if the file does not exist.
 -
 -    EXAMPLES::
 -
@@ -48,11 +48,17 @@ index 061b94f3f1..67cd091540 100644
 -
 -    for libname in (libname,) + additional_libnames:
 -        if sys.platform == 'cygwin':
--            bindir = sysconfig.get_config_var('BINDIR')
+-            # Later down we take the last matching DLL found, so search
+-            # SAGE_LOCAL second so that it takes precedence
+-            bindirs = [
+-                sysconfig.get_config_var('BINDIR'),
+-                os.path.join(SAGE_LOCAL, 'bin')
+-            ]
 -            pats = ['cyg{}.dll'.format(libname), 'cyg{}-*.dll'.format(libname)]
 -            filenames = []
--            for pat in pats:
--                filenames += glob.glob(os.path.join(bindir, pat))
+-            for bindir in bindirs:
+-                for pat in pats:
+-                    filenames += glob.glob(os.path.join(bindir, pat))
 -
 -            # Note: This is not very robust, since if there are multi DLL
 -            # versions for the same library this just selects one more or less
@@ -66,10 +72,13 @@ index 061b94f3f1..67cd091540 100644
 -            else:
 -                ext = 'so'
 -
--            libdirs = [sysconfig.get_config_var('LIBDIR')]
+-            libdirs = [
+-                os.path.join(SAGE_LOCAL, 'lib'),
+-                sysconfig.get_config_var('LIBDIR')
+-            ]
 -            multilib = sysconfig.get_config_var('MULTILIB')
 -            if multilib:
--                libdirs.insert(0, os.path.join(libdirs[0], multilib))
+-                libdirs.insert(1, os.path.join(libdirs[0], multilib))
 -
 -            for libdir in libdirs:
 -                basename = 'lib{}.{}'.format(libname, ext)
@@ -89,7 +98,7 @@ index 061b94f3f1..67cd091540 100644
  
  # locate libgap shared object
 -GAP_SO= _get_shared_lib_filename('gap','')
-+GAP_SO= '/default'
++GAP_SO = '/default'
  var('GAP_SO', GAP_SO)
  
  # post process
diff --git a/pkgs/applications/science/math/sage/patches/docutils-0.15.patch b/pkgs/applications/science/math/sage/patches/docutils-0.15.patch
deleted file mode 100644
index 63f5d2e146d..00000000000
--- a/pkgs/applications/science/math/sage/patches/docutils-0.15.patch
+++ /dev/null
@@ -1,24 +0,0 @@
-diff --git a/src/sage/misc/sphinxify.py b/src/sage/misc/sphinxify.py
-index 4849c2bffa..76b7bc8602 100644
---- a/src/sage/misc/sphinxify.py
-+++ b/src/sage/misc/sphinxify.py
-@@ -25,6 +25,7 @@ from __future__ import absolute_import, print_function
- import os
- import re
- import shutil
-+import warnings
- from tempfile import mkdtemp
- from sphinx.application import Sphinx
- 
-@@ -120,7 +121,10 @@ smart_quotes = no""")
-     # buildername, confoverrides, status, warning, freshenv).
-     sphinx_app = Sphinx(srcdir, confdir, outdir, doctreedir, format,
-                         confoverrides, None, None, True)
--    sphinx_app.build(None, [rst_name])
-+    with warnings.catch_warnings():
-+        # Quick and dirty workaround for https://trac.sagemath.org/ticket/28856#comment:19
-+        warnings.simplefilter("ignore")
-+        sphinx_app.build(None, [rst_name])
-     sys.path = old_sys_path
- 
-     # We need to remove "_" from __builtin__ that the gettext module installs
diff --git a/pkgs/applications/science/math/sage/patches/ignore-cmp-deprecation.patch b/pkgs/applications/science/math/sage/patches/ignore-cmp-deprecation.patch
index 11ca7481961..a91ee319b8f 100644
--- a/pkgs/applications/science/math/sage/patches/ignore-cmp-deprecation.patch
+++ b/pkgs/applications/science/math/sage/patches/ignore-cmp-deprecation.patch
@@ -1,24 +1,24 @@
 diff --git a/src/sage/tests/cmdline.py b/src/sage/tests/cmdline.py
-index bd6b76ab82..ccf1203dec 100644
+index 6e034dcb5a..8ec60ec72b 100644
 --- a/src/sage/tests/cmdline.py
 +++ b/src/sage/tests/cmdline.py
-@@ -837,8 +837,6 @@ def test_executable(args, input="", timeout=100.0, **kwds):
+@@ -660,8 +660,8 @@ def test_executable(args, input="", timeout=100.0, pydebug_ignore_warnings=False
+         sage: with open(input, 'w') as F:
+         ....:     _ = F.write(s)
+         sage: L = ["sage", "--rst2ipynb", input, output]
+-        sage: test_executable(L)                              # optional - rst2ipynb
+-        ('', '', 0)
++        sage: test_executable(L)[2]                           # optional - rst2ipynb
++        0
+         sage: import json                                     # optional - rst2ipynb
+         sage: d = json.load(open(output,'r'))                 # optional - rst2ipynb
+         sage: type(d)                                         # optional - rst2ipynb
+@@ -757,8 +757,6 @@ def test_executable(args, input="", timeout=100.0, pydebug_ignore_warnings=False
          ///
          4
          }}}
--        sage: err # py2
+-        sage: err # py2 # optional -- sagenb
 -        ''
-         sage: ret
+         sage: ret # py2 # optional -- sagenb
          0
  
-@@ -871,8 +869,8 @@ def test_executable(args, input="", timeout=100.0, **kwds):
-         sage: output = tmp_filename(ext='.sws')
-         sage: with open(input, 'w') as F:
-         ....:     _ = F.write(s)
--        sage: test_executable(["sage", "--rst2sws", input, output]) # py2
--        ('', '', 0)
-+        sage: test_executable(["sage", "--rst2sws", input, output])[2] # py2
-+        0
-         sage: import tarfile # py2
-         sage: f = tarfile.open(output, 'r') # py2
-         sage: print(f.extractfile('sage_worksheet/worksheet.html').read()) # py2
diff --git a/pkgs/applications/science/math/sage/patches/ignore-werkzeug-immutable-dict-deprecation.patch b/pkgs/applications/science/math/sage/patches/ignore-werkzeug-immutable-dict-deprecation.patch
deleted file mode 100644
index c5f95b498d5..00000000000
--- a/pkgs/applications/science/math/sage/patches/ignore-werkzeug-immutable-dict-deprecation.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff --git a/src/sage/all.py b/src/sage/all.py
-index c87c9372e9..862fca4fcc 100644
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -306,6 +306,7 @@ warnings.filters.remove(('ignore', None, DeprecationWarning, None, 0))
- # Ignore all deprecations from IPython etc.
- warnings.filterwarnings('ignore', category=DeprecationWarning,
-     module='.*(IPython|ipykernel|jupyter_client|jupyter_core|nbformat|notebook|ipywidgets|storemagic)')
-+warnings.filterwarnings('ignore', category=DeprecationWarning, message=r".*The import 'werkzeug.ImmutableDict' is deprecated")
- # Ignore collections.abc warnings, there are a lot of them but they are
- # harmless.
- warnings.filterwarnings('ignore', category=DeprecationWarning,
diff --git a/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch b/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch
deleted file mode 100644
index 49cdfd189b9..00000000000
--- a/pkgs/applications/science/math/sage/patches/pari-stackwarn.patch
+++ /dev/null
@@ -1,20 +0,0 @@
-diff --git a/src/sage/doctest/parsing.py b/src/sage/doctest/parsing.py
-index 6bdc9a0..31fc780 100644
---- a/src/sage/doctest/parsing.py
-+++ b/src/sage/doctest/parsing.py
-@@ -40,6 +40,7 @@ from .external import available_software
- 
- float_regex = re.compile('\s*([+-]?\s*((\d*\.?\d+)|(\d+\.?))([eE][+-]?\d+)?)')
- optional_regex = re.compile(r'(py2|py3|long time|not implemented|not tested|known bug)|([^ a-z]\s*optional\s*[:-]*((\s|\w)*))')
-+pari_stack_warning_regex = re.compile(r'\s*\*\*\*.*(Warning: increasing stack size to )\d+\.')
- find_sage_prompt = re.compile(r"^(\s*)sage: ", re.M)
- find_sage_continuation = re.compile(r"^(\s*)\.\.\.\.:", re.M)
- random_marker = re.compile('.*random', re.I)
-@@ -935,6 +936,7 @@ class SageOutputChecker(doctest.OutputChecker):
-             <type 'float'>
-         """
-         got = self.human_readable_escape_sequences(got)
-+        got = pari_stack_warning_regex.sub('', got)
-         if isinstance(want, MarkedOutput):
-             if want.random:
-                 return True
diff --git a/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch b/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch
deleted file mode 100644
index 1b64f39fe60..00000000000
--- a/pkgs/applications/science/math/sage/patches/python-5755-hotpatch.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff --git a/src/sage/all.py b/src/sage/all.py
-index ca309ef..be3186b 100644
---- a/src/sage/all.py
-+++ b/src/sage/all.py
-@@ -298,6 +298,23 @@ warnings.filterwarnings('ignore', module='matplotlib[.]font_manager')
- warnings.filterwarnings('default',
-     '[\s\S]*See http://trac.sagemath.org/[0-9]* for details.')
- 
-+# Hotpatch around https://bugs.python.org/issue5755 which won't be fixed for
-+# python 2.7. Idea by https://stackoverflow.com/a/36293331.
-+from distutils.command.build_ext import build_ext
-+from distutils.sysconfig import customize_compiler
-+
-+_build_extensions = build_ext.build_extensions
-+
-+def build_extensions_patched(self):
-+    customize_compiler(self.compiler)
-+    try:
-+        self.compiler.compiler_so.remove("-Wstrict-prototypes")
-+    except (AttributeError, ValueError):
-+        pass
-+    _build_extensions(self)
-+
-+build_ext.build_extensions = build_extensions_patched
-+
- 
- # Set a new random number seed as the very last thing
- # (so that printing initial_seed() and using that seed
diff --git a/pkgs/applications/science/math/sage/patches/sagenb-cmp-deprecation.patch b/pkgs/applications/science/math/sage/patches/sagenb-cmp-deprecation.patch
deleted file mode 100644
index 9f502a66951..00000000000
--- a/pkgs/applications/science/math/sage/patches/sagenb-cmp-deprecation.patch
+++ /dev/null
@@ -1,13 +0,0 @@
-diff --git a/sagenb/__init__.py b/sagenb/__init__.py
-index 4db0d2cb..2fc5f01e 100644
---- a/sagenb/__init__.py
-+++ b/sagenb/__init__.py
-@@ -1,3 +1,8 @@
- # -*- coding: utf-8 -*
-   # init
-+import warnings
- from . import storage
-+
-+# deprecation in attrs, needs to be fixed in twisted
-+warnings.filterwarnings('ignore', category=DeprecationWarning,
-+    message=r'The usage of `cmp` is deprecated and will be removed.*')
diff --git a/pkgs/applications/science/math/sage/patches/sympow-cache.patch b/pkgs/applications/science/math/sage/patches/sympow-cache.patch
index 20020d610f8..d71f3acbc70 100644
--- a/pkgs/applications/science/math/sage/patches/sympow-cache.patch
+++ b/pkgs/applications/science/math/sage/patches/sympow-cache.patch
@@ -1,5 +1,5 @@
 diff --git a/src/sage/lfunctions/sympow.py b/src/sage/lfunctions/sympow.py
-index 1640ac4f6a..03578be7b8 100644
+index 92cb01fd73..b123e6accc 100644
 --- a/src/sage/lfunctions/sympow.py
 +++ b/src/sage/lfunctions/sympow.py
 @@ -50,6 +50,7 @@ from __future__ import print_function, absolute_import
@@ -8,14 +8,14 @@ index 1640ac4f6a..03578be7b8 100644
  
 +from sage.env import DOT_SAGE
  from sage.structure.sage_object import SageObject
- from sage.misc.all import pager, verbose
- import sage.rings.all
-@@ -76,7 +77,7 @@ class Sympow(SageObject):
+ from sage.misc.all import pager
+ from sage.misc.verbose import verbose
+@@ -78,7 +79,7 @@ class Sympow(SageObject):
          """
          Used to call sympow with given args
          """
--        cmd = 'sympow %s'%args
+-        cmd = 'sympow %s' % args
 +        cmd = 'env SYMPOW_CACHEDIR="%s/sympow///" sympow %s' % (DOT_SAGE, args)
-         v = os.popen(cmd).read().strip()
+         with os.popen(cmd) as f:
+             v = f.read().strip()
          verbose(v, level=2)
-         return v
diff --git a/pkgs/applications/science/math/sage/pybrial.nix b/pkgs/applications/science/math/sage/pybrial.nix
deleted file mode 100644
index 5fc8a4aa6f4..00000000000
--- a/pkgs/applications/science/math/sage/pybrial.nix
+++ /dev/null
@@ -1,25 +0,0 @@
-{ stdenv
-, fetchFromGitHub
-, buildPythonPackage
-, brial
-}:
-# This has a cyclic dependency with sage. I don't include sage in the
-# buildInputs and let python figure it out at runtime. Because of this,
-# I don't include the package in the main nipxkgs tree. It wouldn't be useful
-# outside of sage anyways (as you could just directly depend on sage and use
-# it).
-buildPythonPackage rec {
-    pname = "pyBRiAl";
-    version = brial.version;
-
-    # included with BRiAl source
-    src = brial.src;
-
-    sourceRoot = "source/sage-brial";
-
-    meta = with stdenv.lib; {
-      description = "python implementation of BRiAl";
-      license = licenses.gpl2;
-      maintainers = teams.sage.members;
-    };
-}
diff --git a/pkgs/applications/science/math/sage/python-openid.nix b/pkgs/applications/science/math/sage/python-openid.nix
deleted file mode 100644
index 1e8a908ac79..00000000000
--- a/pkgs/applications/science/math/sage/python-openid.nix
+++ /dev/null
@@ -1,40 +0,0 @@
-{ stdenv
-, buildPythonPackage
-, fetchPypi
-, isPy3k
-, django
-, nose
-, twill
-, pycrypto
-}:
-
-buildPythonPackage rec {
-  pname = "python-openid";
-  version = "2.2.5";
-
-  disabled = isPy3k;
-
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "1vvhxlghjan01snfdc4k7ykd80vkyjgizwgg9bncnin8rqz1ricj";
-  };
-
-  propagatedBuildInputs = [
-    pycrypto
-  ];
-
-  # Cannot access the djopenid example module.
-  # I don't know how to fix that (adding the examples dir to PYTHONPATH doesn't work)
-  doCheck = false;
-  checkInputs = [ nose django twill ];
-  checkPhase = ''
-    nosetests
-  '';
-
-  meta = with stdenv.lib; {
-    description = "OpenID library for Python";
-    license = licenses.asl20;
-    maintainers = teams.sage.members;
-    homepage = "https://github.com/openid/python-openid/";
-  };
-}
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index 4791d12450a..b0182e9693f 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -10,44 +10,23 @@
 # all get the same sources with the same patches applied.
 
 stdenv.mkDerivation rec {
-  version = "8.9";
+  version = "9.2";
   pname = "sage-src";
 
   src = fetchFromGitHub {
     owner = "sagemath";
     repo = "sage";
     rev = version;
-    sha256 = "1bwga58x3s8z42w5h51c232f91ndsc1861dlb1glhax3pn0rhn3a";
+    sha256 = "103j8d5x6szl9fxaz0dvdi4y47q1af9h9y5hmjh2xayi62qmp5ql";
   };
 
   # 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 = [
-    # https://trac.sagemath.org/ticket/25358
-    (fetchpatch {
-      name = "safe-directory-test-without-patch.patch";
-      url = "https://git.sagemath.org/sage.git/patch?id2=8bdc326ba57d1bb9664f63cf165a9e9920cc1afc&id=dc673c17555efca611f68398d5013b66e9825463";
-      sha256 = "1hhannz7xzprijakn2w2d0rhd5zv2zikik9p51i87bas3nc658f7";
-    })
-    
-    # `is_unitary` test in `matrix_double_dense.pyx` fails with some BLAS implementations
-    # https://trac.sagemath.org/ticket/29297 should be included in 9.1
-    (fetchpatch {
-      name = "is_unitary-special-case.patch";
-      url = "https://git.sagemath.org/sage.git/patch?id=cc3eb9ffa991e328b09028d32aab7e7cc2ddbb6a";
-      sha256 = "0jq4w8hnp5c9q99011ldr4n3knvm1rx2g85z0hidv3i9x868p0ay";
-    })
-
-    # Unfortunately inclusion in upstream sage was rejected. Instead the bug was
-    # fixed in python, but of course not backported to 2.7. So we'll probably
-    # have to keep this around until 2.7 is deprecated.
-    # https://trac.sagemath.org/ticket/25316
-    # https://github.com/python/cpython/pull/7476
-    ./patches/python-5755-hotpatch.patch
-
     # 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
 
     # Fixes a potential race condition which can lead to transient doctest failures.
@@ -60,11 +39,6 @@ stdenv.mkDerivation rec {
     # Parallelize docubuild using subprocesses, fixing an isolation issue. See
     # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
     ./patches/sphinx-docbuild-subprocesses.patch
-
-    # Fix doctest failures with docutils 0.15:
-    # https://nix-cache.s3.amazonaws.com/log/dzmzrb2zvardsmpy7idg7djkizmkzdhs-sage-tests-8.9.drv
-    # https://trac.sagemath.org/ticket/28856#comment:19
-    ./patches/docutils-0.15.patch
   ];
 
   # Since sage unfortunately does not release bugfix releases, packagers must
@@ -96,55 +70,13 @@ stdenv.mkDerivation rec {
       } // builtins.removeAttrs args [ "rev" "base" ])
     );
   in [
-    # New glpk version has new warnings, filter those out until upstream sage has found a solution
-    # Should be fixed with glpk > 4.65.
-    # https://trac.sagemath.org/ticket/24824
-    ./patches/pari-stackwarn.patch # not actually necessary since the pari upgrade, but necessary for the glpk patch to apply
-    (fetchpatch {
-      url = "https://salsa.debian.org/science-team/sagemath/raw/58bbba93a807ca2933ca317501d093a1bb4b84db/debian/patches/dt-version-glpk-4.65-ignore-warnings.patch";
-      sha256 = "0b9293v73wb4x13wv5zwyjgclc01zn16msccfzzi6znswklgvddp";
-      stripLen = 1;
-    })
-
     # After updating smypow to (https://trac.sagemath.org/ticket/3360) we can
     # now set the cache dir to be withing the .sage directory. This is not
     # strictly necessary, but keeps us from littering in the user's HOME.
     ./patches/sympow-cache.patch
 
-    # https://trac.sagemath.org/ticket/28472
-    (fetchpatch {
-      name = "eclib-20190909.patch";
-      url = "https://git.sagemath.org/sage.git/patch?id=d27dc479a5772d59e4bc85d805b6ffd595284f1d";
-      sha256 = "1nf1s9y7n30lhlbdnam7sghgaq9nasmv96415gl5jlcf7a3hlxk3";
-    })
-
     # ignore a deprecation warning for usage of `cmp` in the attrs library in the doctests
     ./patches/ignore-cmp-deprecation.patch
-
-    # Werkzeug has deprecated ImmutableDict, but it is still used in legacy
-    # sagenb. That's no big issue since sagenb will be removed soon anyways.
-    ./patches/ignore-werkzeug-immutable-dict-deprecation.patch
-
-    # threejs r109 (#28560)
-    (fetchpatch {
-      name = "threejs-r109.patch";
-      url = "https://git.sagemath.org/sage.git/patch?id=fcc11d6effa39f375bc5f4ea5831fb7a2f2767da";
-      sha256 = "0hnmc8ld3bblks0hcjvjjaydkgwdr1cs3dbl2ys4gfq964pjgqwc";
-    })
-
-    # https://trac.sagemath.org/ticket/28911
-    (fetchpatch {
-      name = "sympy-1.5.patch";
-      url = "https://git.sagemath.org/sage.git/patch/?h=c6d0308db15efd611211d26cfcbefbd180fc0831";
-      sha256 = "0nwai2jr22h49km4hx3kwafs3mzsc5kwsv7mqwjf6ibwfx2bbgyq";
-    })
-
-    # https://trac.sagemath.org/ticket/29313 (patch from ArchLinux)
-    (fetchpatch {
-      name = "pari-2.11.3.patch";
-      url = "https://aur.archlinux.org/cgit/aur.git/plain/sagemath-pari-2.11.3.patch?h=sagemath-git&id=02e1d58bd1cd70935d69a4990469d18be6bd2c43";
-      sha256 = "0z07444zvijyw96d11q7j81pvg7ysd6ycf1bbbjr6za9y74hv7d2";
-    })
   ];
 
   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 87c1e07f530..88436e1e0f5 100644
--- a/pkgs/applications/science/math/sage/sage-with-env.nix
+++ b/pkgs/applications/science/math/sage/sage-with-env.nix
@@ -13,7 +13,7 @@
 , pari
 , gmp
 , gfan
-, python2
+, python3
 , flintqs
 , eclib
 , ntl
@@ -54,7 +54,7 @@ let
   pkg_to_spkg_name = pkg: patch_names: let
     parts = lib.splitString "-" pkg.name;
     # remove python2.7-
-    stripped_parts = if (builtins.head parts) == python2.libPrefix then builtins.tail parts else parts;
+    stripped_parts = if (builtins.head parts) == python3.libPrefix then builtins.tail parts else parts;
     version = lib.last stripped_parts;
     orig_pkgname = lib.init stripped_parts;
     pkgname = patch_names (lib.concatStringsSep "_" orig_pkgname);
@@ -126,6 +126,8 @@ stdenv.mkDerivation rec {
     cp -r src/bin "$out/bin"
     cp -r build/bin "$out/build/bin"
 
+    ln -s "${python3}/bin/python3" "$out/bin/python3"
+
     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 a21bffea14c..e2acef7b8eb 100644
--- a/pkgs/applications/science/math/sage/sage.nix
+++ b/pkgs/applications/science/math/sage/sage.nix
@@ -61,7 +61,6 @@ stdenv.mkDerivation rec {
   };
 
   meta = with stdenv.lib; {
-    broken = true;
     description = "Open Source Mathematics Software, free alternative to Magma, Maple, Mathematica, and Matlab";
     license = licenses.gpl2;
     maintainers = teams.sage.members;
diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix
index bf618fe64f4..619a69b7aac 100644
--- a/pkgs/applications/science/math/sage/sagedoc.nix
+++ b/pkgs/applications/science/math/sage/sagedoc.nix
@@ -26,7 +26,6 @@ stdenv.mkDerivation rec {
     psutil
     future
     sphinx
-    sagenb
     scipy
     sympy
     matplotlib
@@ -36,7 +35,6 @@ stdenv.mkDerivation rec {
     ipywidgets
     jupyter_client
     typing
-    pybrial
   ]);
 
   unpackPhase = ''
diff --git a/pkgs/applications/science/math/sage/sagelib.nix b/pkgs/applications/science/math/sage/sagelib.nix
index 830d806a8bc..a60680139f9 100644
--- a/pkgs/applications/science/math/sage/sagelib.nix
+++ b/pkgs/applications/science/math/sage/sagelib.nix
@@ -15,6 +15,7 @@
 , ecm
 , flint
 , gd
+, giac
 , givaro
 , glpk
 , gsl
@@ -51,6 +52,8 @@
 , libbraiding
 , gmpy2
 , pplpy
+, sqlite
+, boehmgc # FIXME
 }:
 
 assert (!blas.isILP64) && (!lapack.isILP64);
@@ -94,6 +97,7 @@ buildPythonPackage rec {
     ecm
     fflas-ffpack
     flint
+    giac
     givaro
     glpk
     gsl
@@ -124,6 +128,8 @@ buildPythonPackage rec {
     libbraiding
     gmpy2
     pplpy
+    sqlite
+    boehmgc # FIXME
   ];
 
   buildPhase = ''
diff --git a/pkgs/applications/science/math/sage/sagenb.nix b/pkgs/applications/science/math/sage/sagenb.nix
deleted file mode 100644
index ad5c53b6c11..00000000000
--- a/pkgs/applications/science/math/sage/sagenb.nix
+++ /dev/null
@@ -1,57 +0,0 @@
-{ stdenv
-, python
-, buildPythonPackage
-, fetchFromGitHub
-, mathjax
-, twisted
-, flask
-, flask-oldsessions
-, flask-openid
-, flask-autoindex
-, flask-babel
-}:
-
-# Has a cyclic dependency with sage (not expressed here) and is not useful outside of sage.
-# Deprecated, hopefully soon to be removed. See
-# https://trac.sagemath.org/ticket/25837
-
-buildPythonPackage rec {
-  pname = "sagenb";
-  version = "1.1.2";
-
-  src = fetchFromGitHub {
-    owner = "sagemath";
-    repo = "sagenb";
-    rev = version;
-    sha256 = "0bxvhr03qh2nsjdfc4pyfiqrn9jhp3vf7irsc9gqx0185jlblbxs";
-  };
-
-  patches = [
-    # cmp deprecation in attrs needs to be handled in twisted
-    ./patches/sagenb-cmp-deprecation.patch
-  ];
-
-  propagatedBuildInputs = [
-    twisted
-    flask
-    flask-oldsessions
-    flask-openid
-    flask-autoindex
-    flask-babel
-  ];
-
-  # tests depend on sage
-  doCheck = false;
-
-  meta = with stdenv.lib; {
-    description = "Sage Notebook";
-    license = licenses.gpl3Plus;
-    maintainers = teams.sage.members;
-  };
-
-  # let sagenb use mathjax
-  postInstall = ''
-    mkdir -p "$out/${python.sitePackages}/sagenb/data"
-    ln -s ${mathjax}/lib/node_modules/mathjax "$out/${python.sitePackages}/sagenb/data/mathjax"
-  '';
-}