summary refs log tree commit diff
path: root/pkgs/applications/science/math/sage/patches
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/math/sage/patches')
-rw-r--r--pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch35
-rw-r--r--pkgs/applications/science/math/sage/patches/dochtml-optional.patch127
-rw-r--r--pkgs/applications/science/math/sage/patches/eclib-20180710.patch24
-rw-r--r--pkgs/applications/science/math/sage/patches/numpy-1.15.1.patch (renamed from pkgs/applications/science/math/sage/patches/numpy-1.14.3.patch)207
-rw-r--r--pkgs/applications/science/math/sage/patches/pari-no-threads.patch18
-rw-r--r--pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch71
-rw-r--r--pkgs/applications/science/math/sage/patches/singular-4.1.1p2.patch274
-rw-r--r--pkgs/applications/science/math/sage/patches/spkg-scripts.patch46
-rw-r--r--pkgs/applications/science/math/sage/patches/test-in-tmpdir.patch31
9 files changed, 259 insertions, 574 deletions
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
new file mode 100644
index 000000000000..8cd80281d0e4
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/Only-test-py2-py3-optional-tests-when-all-of-sage-is.patch
@@ -0,0 +1,35 @@
+From 8218bd4fdeb4c92de8af0d3aabec55980fc4fb3d 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(-)
+
+diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
+index bf18df8b2b..935c67abf7 100644
+--- a/src/sage/doctest/control.py
++++ b/src/sage/doctest/control.py
+@@ -362,7 +362,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
+ 
+@@ -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
+
diff --git a/pkgs/applications/science/math/sage/patches/dochtml-optional.patch b/pkgs/applications/science/math/sage/patches/dochtml-optional.patch
deleted file mode 100644
index a51e30312ed9..000000000000
--- a/pkgs/applications/science/math/sage/patches/dochtml-optional.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff --git a/src/doc/common/conf.py b/src/doc/common/conf.py
-index 25f94f7b7d..9f6139ea4a 100644
---- a/src/doc/common/conf.py
-+++ b/src/doc/common/conf.py
-@@ -622,9 +622,9 @@ def call_intersphinx(app, env, node, contnode):
-     Check that the link from the thematic tutorials to the reference
-     manual is relative, see :trac:`20118`::
- 
--        sage: from sage.env import SAGE_DOC
--        sage: thematic_index = os.path.join(SAGE_DOC, "html", "en", "thematic_tutorials", "index.html")
--        sage: for line in open(thematic_index).readlines():
-+        sage: from sage.env import SAGE_DOC  # optional - dochtml
-+        sage: thematic_index = os.path.join(SAGE_DOC, "html", "en", "thematic_tutorials", "index.html")  # optional - dochtml
-+        sage: for line in open(thematic_index).readlines():  # optional - dochtml
-         ....:     if "padics" in line:
-         ....:         sys.stdout.write(line)
-         <li><a class="reference external" href="../reference/padics/sage/rings/padics/tutorial.html#sage-rings-padics-tutorial" title="(in Sage Reference Manual: p-Adics ...)"><span>Introduction to the -adics</span></a></li>
-diff --git a/src/sage/doctest/control.py b/src/sage/doctest/control.py
-index 4236fd05e0..8e499cbaf7 100644
---- a/src/sage/doctest/control.py
-+++ b/src/sage/doctest/control.py
-@@ -87,7 +87,7 @@ class DocTestDefaults(SageObject):
-         self.sagenb = False
-         self.long = False
-         self.warn_long = None
--        self.optional = set(['sage']) | auto_optional_tags
-+        self.optional = set(['sage', 'dochtml']) | auto_optional_tags
-         self.randorder = None
-         self.global_iterations = 1  # sage-runtests default is 0
-         self.file_iterations = 1    # sage-runtests default is 0
-@@ -343,7 +343,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
-         self.files = args
-@@ -741,7 +742,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', 'py3']
-+            ['guava', 'magma']
- 
-         We check that files are skipped appropriately::
- 
-@@ -968,7 +969,7 @@ class DocTestController(SageObject):
-             sage: from sage.doctest.control import DocTestDefaults, DocTestController
-             sage: DC = DocTestController(DocTestDefaults(), [])
-             sage: DC._optional_tags_string()
--            'sage'
-+            'dochtml,sage'
-             sage: DC = DocTestController(DocTestDefaults(optional="all,and,some,more"), [])
-             sage: DC._optional_tags_string()
-             'all'
-diff --git a/src/sage/misc/sagedoc.py b/src/sage/misc/sagedoc.py
-index 9255aa848f..cc4712d3ec 100644
---- a/src/sage/misc/sagedoc.py
-+++ b/src/sage/misc/sagedoc.py
-@@ -18,9 +18,9 @@ TESTS:
- Check that argspecs of extension function/methods appear correctly,
- see :trac:`12849`::
- 
--    sage: from sage.env import SAGE_DOC
--    sage: docfilename = os.path.join(SAGE_DOC, 'html', 'en', 'reference', 'calculus', 'sage', 'symbolic', 'expression.html')
--    sage: with open(docfilename) as fobj:
-+    sage: from sage.env import SAGE_DOC  # optional - dochtml
-+    sage: docfilename = os.path.join(SAGE_DOC, 'html', 'en', 'reference', 'calculus', 'sage', 'symbolic', 'expression.html')  # optional - dochtml
-+    sage: with open(docfilename) as fobj:  # optional - dochtml
-     ....:     for line in fobj:
-     ....:         if "#sage.symbolic.expression.Expression.numerical_approx" in line:
-     ....:             print(line)
-@@ -790,11 +790,12 @@ def _search_src_or_doc(what, string, extra1='', extra2='', extra3='',
- 
-     ::
- 
--        sage: len(_search_src_or_doc('src', r'matrix\(', 'incidence_structures', 'self', 'combinat', interact=False).splitlines()) > 1
-+        sage: from sage.misc.sagedoc import _search_src_or_doc  # optional - dochtml
-+        sage: len(_search_src_or_doc('src', r'matrix\(', 'incidence_structures', 'self', 'combinat', interact=False).splitlines()) > 1  # optional - dochtml
-         True
--        sage: 'abvar/homology' in _search_src_or_doc('doc', 'homology', 'variety', interact=False)  # long time (4s on sage.math, 2012)
-+        sage: 'abvar/homology' in _search_src_or_doc('doc', 'homology', 'variety', interact=False)  # optional - dochtml, long time (4s on sage.math, 2012)
-         True
--        sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)
-+        sage: 'divisors' in _search_src_or_doc('src', '^ *def prime', interact=False)  # optional - dochtml
-         True
-     """
-     # process keywords
-@@ -1160,9 +1161,9 @@ def search_doc(string, extra1='', extra2='', extra3='', extra4='',
-     counting the length of ``search_doc('tree',
-     interact=False).splitlines()`` gives the number of matches. ::
- 
--        sage: len(search_doc('tree', interact=False).splitlines()) > 4000  # long time
-+        sage: len(search_doc('tree', interact=False).splitlines()) > 4000  # optional - dochtml, long time
-         True
--        sage: len(search_doc('tree', whole_word=True, interact=False).splitlines()) < 2000  # long time
-+        sage: len(search_doc('tree', whole_word=True, interact=False).splitlines()) < 2000  # optional - dochtml, long time
-         True
-     """
-     return _search_src_or_doc('doc', string, extra1=extra1, extra2=extra2,
-@@ -1332,9 +1333,9 @@ class _sage_doc:
- 
-     EXAMPLES::
- 
--        sage: browse_sage_doc._open("reference", testing=True)[0]  # indirect doctest
-+        sage: browse_sage_doc._open("reference", testing=True)[0]  # optional - dochtml, indirect doctest
-         'http://localhost:8000/doc/live/reference/index.html'
--        sage: browse_sage_doc(identity_matrix, 'rst')[-107:-47]
-+        sage: browse_sage_doc(identity_matrix, 'rst')[-107:-47]  # optional - dochtml
-         'Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring'
-     """
-     def __init__(self):
-@@ -1494,9 +1495,9 @@ class _sage_doc:
- 
-         EXAMPLES::
- 
--            sage: browse_sage_doc._open("reference", testing=True)[0]
-+            sage: browse_sage_doc._open("reference", testing=True)[0]  # optional - dochtml
-             'http://localhost:8000/doc/live/reference/index.html'
--            sage: browse_sage_doc._open("tutorial", testing=True)[1]
-+            sage: browse_sage_doc._open("tutorial", testing=True)[1]  # optional - dochtml
-             '.../html/en/tutorial/index.html'
-         """
-         url = self._base_url + os.path.join(name, "index.html")
diff --git a/pkgs/applications/science/math/sage/patches/eclib-20180710.patch b/pkgs/applications/science/math/sage/patches/eclib-20180710.patch
index d06e1e6cedf2..986ae42aeb62 100644
--- a/pkgs/applications/science/math/sage/patches/eclib-20180710.patch
+++ b/pkgs/applications/science/math/sage/patches/eclib-20180710.patch
@@ -14,27 +14,3 @@ index 4417b59276..ae57ca2991 100644
      """
      global instances
      try:
-diff --git a/src/sage/libs/eclib/wrap.cpp b/src/sage/libs/eclib/wrap.cpp
-index 5fd5693b53..d12468faa8 100644
---- a/src/sage/libs/eclib/wrap.cpp
-+++ b/src/sage/libs/eclib/wrap.cpp
-@@ -133,8 +133,8 @@ char* Curvedata_isogeny_class(struct Curvedata* E, int verbose)
- 
- 
- int mw_process(struct Curvedata* curve, struct mw* m,
--                      const struct bigint* x, const struct bigint* y,
--                      const struct bigint* z, int sat)
-+                      const bigint* x, const bigint* y,
-+                      const bigint* z, int sat)
- {
-   Point P(*curve, *x, *y, *z);
-   if (!P.isvalid())
-@@ -188,7 +188,7 @@ int mw_rank(struct mw* m)
- }
- 
- /* Returns index and unsat long array, which user must deallocate */
--int mw_saturate(struct mw* m, struct bigint* index, char** unsat,
-+int mw_saturate(struct mw* m, bigint* index, char** unsat,
-                        long sat_bd, int odd_primes_only)
- {
-   vector<long> v;
diff --git a/pkgs/applications/science/math/sage/patches/numpy-1.14.3.patch b/pkgs/applications/science/math/sage/patches/numpy-1.15.1.patch
index 5927bc116096..9e855ba4ad94 100644
--- a/pkgs/applications/science/math/sage/patches/numpy-1.14.3.patch
+++ b/pkgs/applications/science/math/sage/patches/numpy-1.15.1.patch
@@ -1,5 +1,5 @@
 diff --git a/src/doc/en/faq/faq-usage.rst b/src/doc/en/faq/faq-usage.rst
-index 79b4205fd3..9a89bd2136 100644
+index 2347a1190d..f5b0fe71a4 100644
 --- a/src/doc/en/faq/faq-usage.rst
 +++ b/src/doc/en/faq/faq-usage.rst
 @@ -338,7 +338,7 @@ ints. For example::
@@ -174,7 +174,7 @@ index 5b89cd75ee..e50b2ea5d4 100644
  This creates a random 5x5 matrix ``A``, and solves `Ax=b` where
  ``b=[0.0,1.0,2.0,3.0,4.0]``. There are many other routines in the :mod:`numpy.linalg`
 diff --git a/src/sage/calculus/riemann.pyx b/src/sage/calculus/riemann.pyx
-index df85cce43d..34ea164be0 100644
+index 60f37f7557..4ac3dedf1d 100644
 --- a/src/sage/calculus/riemann.pyx
 +++ b/src/sage/calculus/riemann.pyx
 @@ -1191,30 +1191,30 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
@@ -248,7 +248,7 @@ index df85cce43d..34ea164be0 100644
  
      TESTS::
 diff --git a/src/sage/combinat/fully_packed_loop.py b/src/sage/combinat/fully_packed_loop.py
-index 61b1003002..4baee9cbbd 100644
+index 0a9bd61267..d2193cc2d6 100644
 --- a/src/sage/combinat/fully_packed_loop.py
 +++ b/src/sage/combinat/fully_packed_loop.py
 @@ -72,11 +72,11 @@ def _make_color_list(n, colors=None,  color_map=None, randomize=False):
@@ -269,10 +269,10 @@ index 61b1003002..4baee9cbbd 100644
          ['blue', 'blue', 'red', 'blue', 'red', 'red', 'red', 'blue']
      """
 diff --git a/src/sage/finance/time_series.pyx b/src/sage/finance/time_series.pyx
-index c37700d14e..49b7298d0b 100644
+index 28779365df..3ab0282861 100644
 --- a/src/sage/finance/time_series.pyx
 +++ b/src/sage/finance/time_series.pyx
-@@ -109,8 +109,8 @@ cdef class TimeSeries:
+@@ -111,8 +111,8 @@ cdef class TimeSeries:
  
              sage: import numpy
              sage: v = numpy.array([[1,2], [3,4]], dtype=float); v
@@ -283,7 +283,7 @@ index c37700d14e..49b7298d0b 100644
              sage: finance.TimeSeries(v)
              [1.0000, 2.0000, 3.0000, 4.0000]
              sage: finance.TimeSeries(v[:,0])
-@@ -2098,14 +2098,14 @@ cdef class TimeSeries:
+@@ -2100,14 +2100,14 @@ cdef class TimeSeries:
  
              sage: w[0] = 20
              sage: w
@@ -301,7 +301,7 @@ index c37700d14e..49b7298d0b 100644
              sage: v
              [20.0000, -3.0000, 4.5000, -2.0000]
 diff --git a/src/sage/functions/hyperbolic.py b/src/sage/functions/hyperbolic.py
-index 931a4b41e4..bf33fc483d 100644
+index aff552f450..7a6df931e7 100644
 --- a/src/sage/functions/hyperbolic.py
 +++ b/src/sage/functions/hyperbolic.py
 @@ -214,7 +214,7 @@ class Function_coth(GinacFunction):
@@ -341,7 +341,7 @@ index 931a4b41e4..bf33fc483d 100644
          return arctanh(1.0 / x)
  
 diff --git a/src/sage/functions/orthogonal_polys.py b/src/sage/functions/orthogonal_polys.py
-index 017c85a96f..33fbb499c5 100644
+index ed6365bef4..99b8b04dad 100644
 --- a/src/sage/functions/orthogonal_polys.py
 +++ b/src/sage/functions/orthogonal_polys.py
 @@ -810,12 +810,12 @@ class Func_chebyshev_T(ChebyshevFunction):
@@ -379,10 +379,10 @@ index 017c85a96f..33fbb499c5 100644
              array([ 0.2 , -0.96])
          """
 diff --git a/src/sage/functions/other.py b/src/sage/functions/other.py
-index 679384c907..d63b295a4c 100644
+index 1883daa3e6..9885222817 100644
 --- a/src/sage/functions/other.py
 +++ b/src/sage/functions/other.py
-@@ -390,7 +390,7 @@ class Function_ceil(BuiltinFunction):
+@@ -389,7 +389,7 @@ class Function_ceil(BuiltinFunction):
              sage: import numpy
              sage: a = numpy.linspace(0,2,6)
              sage: ceil(a)
@@ -391,7 +391,7 @@ index 679384c907..d63b295a4c 100644
  
          Test pickling::
  
-@@ -539,7 +539,7 @@ class Function_floor(BuiltinFunction):
+@@ -553,7 +553,7 @@ class Function_floor(BuiltinFunction):
              sage: import numpy
              sage: a = numpy.linspace(0,2,6)
              sage: floor(a)
@@ -400,7 +400,7 @@ index 679384c907..d63b295a4c 100644
              sage: floor(x)._sympy_()
              floor(x)
  
-@@ -840,7 +840,7 @@ def sqrt(x, *args, **kwds):
+@@ -869,7 +869,7 @@ def sqrt(x, *args, **kwds):
              sage: import numpy
              sage: a = numpy.arange(2,5)
              sage: sqrt(a)
@@ -409,11 +409,35 @@ index 679384c907..d63b295a4c 100644
          """
          if isinstance(x, float):
              return math.sqrt(x)
+diff --git a/src/sage/functions/spike_function.py b/src/sage/functions/spike_function.py
+index 1e021de3fe..56635ca98f 100644
+--- a/src/sage/functions/spike_function.py
++++ b/src/sage/functions/spike_function.py
+@@ -157,7 +157,7 @@ class SpikeFunction:
+             sage: S = spike_function([(-3,4),(-1,1),(2,3)]); S
+             A spike function with spikes at [-3.0, -1.0, 2.0]
+             sage: P = S.plot_fft_abs(8)
+-            sage: p = P[0]; p.ydata
++            sage: p = P[0]; p.ydata  # abs tol 1e-8
+             [5.0, 5.0, 3.367958691924177, 3.367958691924177, 4.123105625617661, 4.123105625617661, 4.759921664218055, 4.759921664218055]
+         """
+         w = self.vector(samples = samples, xmin=xmin, xmax=xmax)
+@@ -176,8 +176,8 @@ class SpikeFunction:
+             sage: S = spike_function([(-3,4),(-1,1),(2,3)]); S
+             A spike function with spikes at [-3.0, -1.0, 2.0]
+             sage: P = S.plot_fft_arg(8)
+-            sage: p = P[0]; p.ydata
+-            [0.0, 0.0, -0.211524990023434..., -0.211524990023434..., 0.244978663126864..., 0.244978663126864..., -0.149106180027477..., -0.149106180027477...]
++            sage: p = P[0]; p.ydata  # abs tol 1e-8
++            [0.0, 0.0, -0.211524990023434, -0.211524990023434, 0.244978663126864, 0.244978663126864, -0.149106180027477, -0.149106180027477]
+         """
+         w = self.vector(samples = samples, xmin=xmin, xmax=xmax)
+         xmin, xmax = self._ranges(xmin, xmax)
 diff --git a/src/sage/functions/trig.py b/src/sage/functions/trig.py
-index e7e7a311cd..e7ff78a9de 100644
+index 501e7ff6b6..5f760912f0 100644
 --- a/src/sage/functions/trig.py
 +++ b/src/sage/functions/trig.py
-@@ -731,7 +731,7 @@ class Function_arccot(GinacFunction):
+@@ -724,7 +724,7 @@ class Function_arccot(GinacFunction):
              sage: import numpy
              sage: a = numpy.arange(2, 5)
              sage: arccot(a)
@@ -422,7 +446,7 @@ index e7e7a311cd..e7ff78a9de 100644
          """
          return math.pi/2 - arctan(x)
  
-@@ -787,7 +787,7 @@ class Function_arccsc(GinacFunction):
+@@ -780,7 +780,7 @@ class Function_arccsc(GinacFunction):
              sage: import numpy
              sage: a = numpy.arange(2, 5)
              sage: arccsc(a)
@@ -431,7 +455,7 @@ index e7e7a311cd..e7ff78a9de 100644
          """
          return arcsin(1.0/x)
  
-@@ -845,7 +845,7 @@ class Function_arcsec(GinacFunction):
+@@ -838,7 +838,7 @@ class Function_arcsec(GinacFunction):
              sage: import numpy
              sage: a = numpy.arange(2, 5)
              sage: arcsec(a)
@@ -440,7 +464,7 @@ index e7e7a311cd..e7ff78a9de 100644
          """
          return arccos(1.0/x)
  
-@@ -920,13 +920,13 @@ class Function_arctan2(GinacFunction):
+@@ -913,13 +913,13 @@ class Function_arctan2(GinacFunction):
              sage: a = numpy.linspace(1, 3, 3)
              sage: b = numpy.linspace(3, 6, 3)
              sage: atan2(a, b)
@@ -458,10 +482,10 @@ index e7e7a311cd..e7ff78a9de 100644
          TESTS::
  
 diff --git a/src/sage/matrix/constructor.pyx b/src/sage/matrix/constructor.pyx
-index 19a1d37df0..5780dfae1c 100644
+index 12136f1773..491bf22e62 100644
 --- a/src/sage/matrix/constructor.pyx
 +++ b/src/sage/matrix/constructor.pyx
-@@ -494,8 +494,8 @@ class MatrixFactory(object):
+@@ -503,8 +503,8 @@ def matrix(*args, **kwds):
          [7 8 9]
          Full MatrixSpace of 3 by 3 dense matrices over Integer Ring
          sage: n = matrix(QQ, 2, 2, [1, 1/2, 1/3, 1/4]).numpy(); n
@@ -473,10 +497,31 @@ index 19a1d37df0..5780dfae1c 100644
          [  1 1/2]
          [1/3 1/4]
 diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx
-index 48e0a8a97f..1be5d35b19 100644
+index 66e54a79a4..0498334f4b 100644
 --- a/src/sage/matrix/matrix_double_dense.pyx
 +++ b/src/sage/matrix/matrix_double_dense.pyx
-@@ -2546,7 +2546,7 @@ cdef class Matrix_double_dense(Matrix_dense):
+@@ -606,6 +606,9 @@ cdef class Matrix_double_dense(Matrix_dense):
+             [ 3.0 + 9.0*I 4.0 + 16.0*I 5.0 + 25.0*I]
+             [6.0 + 36.0*I 7.0 + 49.0*I 8.0 + 64.0*I]
+             sage: B.condition()
++            doctest:warning
++            ...
++            ComplexWarning: Casting complex values to real discards the imaginary part
+             203.851798...
+             sage: B.condition(p='frob')
+             203.851798...
+@@ -654,9 +657,7 @@ cdef class Matrix_double_dense(Matrix_dense):
+             True
+             sage: B = A.change_ring(CDF)
+             sage: B.condition()
+-            Traceback (most recent call last):
+-            ...
+-            LinAlgError: Singular matrix
++            +Infinity
+ 
+         Improper values of ``p`` are caught.  ::
+ 
+@@ -2519,7 +2520,7 @@ cdef class Matrix_double_dense(Matrix_dense):
              sage: P.is_unitary(algorithm='orthonormal')
              Traceback (most recent call last):
              ...
@@ -485,7 +530,7 @@ index 48e0a8a97f..1be5d35b19 100644
  
          TESTS::
  
-@@ -3662,8 +3662,8 @@ cdef class Matrix_double_dense(Matrix_dense):
+@@ -3635,8 +3636,8 @@ cdef class Matrix_double_dense(Matrix_dense):
              [0.0 1.0 2.0]
              [3.0 4.0 5.0]
              sage: m.numpy()
@@ -496,7 +541,7 @@ index 48e0a8a97f..1be5d35b19 100644
  
          Alternatively, numpy automatically calls this function (via
          the magic :meth:`__array__` method) to convert Sage matrices
-@@ -3674,16 +3674,16 @@ cdef class Matrix_double_dense(Matrix_dense):
+@@ -3647,16 +3648,16 @@ cdef class Matrix_double_dense(Matrix_dense):
              [0.0 1.0 2.0]
              [3.0 4.0 5.0]
              sage: numpy.array(m)
@@ -518,10 +563,10 @@ index 48e0a8a97f..1be5d35b19 100644
              dtype('complex128')
  
 diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py
-index c698ba5e97..b743bab354 100644
+index ccbd208810..c3f9a65093 100644
 --- a/src/sage/matrix/special.py
 +++ b/src/sage/matrix/special.py
-@@ -705,7 +705,7 @@ def diagonal_matrix(arg0=None, arg1=None, arg2=None, sparse=True):
+@@ -706,7 +706,7 @@ def diagonal_matrix(arg0=None, arg1=None, arg2=None, sparse=True):
  
          sage: import numpy
          sage: entries = numpy.array([1.2, 5.6]); entries
@@ -530,7 +575,7 @@ index c698ba5e97..b743bab354 100644
          sage: A = diagonal_matrix(3, entries); A
          [1.2 0.0 0.0]
          [0.0 5.6 0.0]
-@@ -715,7 +715,7 @@ def diagonal_matrix(arg0=None, arg1=None, arg2=None, sparse=True):
+@@ -716,7 +716,7 @@ def diagonal_matrix(arg0=None, arg1=None, arg2=None, sparse=True):
  
          sage: j = numpy.complex(0,1)
          sage: entries = numpy.array([2.0+j, 8.1, 3.4+2.6*j]); entries
@@ -540,10 +585,10 @@ index c698ba5e97..b743bab354 100644
          [2.0 + 1.0*I         0.0         0.0]
          [        0.0         8.1         0.0]
 diff --git a/src/sage/modules/free_module_element.pyx b/src/sage/modules/free_module_element.pyx
-index 230f142117..2ab1c0ae68 100644
+index 37d92c1282..955d083b34 100644
 --- a/src/sage/modules/free_module_element.pyx
 +++ b/src/sage/modules/free_module_element.pyx
-@@ -982,7 +982,7 @@ cdef class FreeModuleElement(Vector):   # abstract base class
+@@ -988,7 +988,7 @@ cdef class FreeModuleElement(Vector):   # abstract base class
              sage: v.numpy()
              array([1, 2, 5/6], dtype=object)
              sage: v.numpy(dtype=float)
@@ -552,7 +597,7 @@ index 230f142117..2ab1c0ae68 100644
              sage: v.numpy(dtype=int)
              array([1, 2, 0])
              sage: import numpy
-@@ -993,7 +993,7 @@ cdef class FreeModuleElement(Vector):   # abstract base class
+@@ -999,7 +999,7 @@ cdef class FreeModuleElement(Vector):   # abstract base class
          be more efficient but may have unintended consequences::
  
              sage: v.numpy(dtype=None)
@@ -596,22 +641,6 @@ index 39fc2970de..2badf98284 100644
          """
          if dtype is None or dtype is self._vector_numpy.dtype:
              from copy import copy
-diff --git a/src/sage/numerical/optimize.py b/src/sage/numerical/optimize.py
-index 17b5ebb84b..92ce35c502 100644
---- a/src/sage/numerical/optimize.py
-+++ b/src/sage/numerical/optimize.py
-@@ -486,9 +486,9 @@ def minimize_constrained(func,cons,x0,gradient=None,algorithm='default', **args)
-                 else:
-                     min = optimize.fmin_tnc(f, x0, approx_grad=True, bounds=cons, messages=0, **args)[0]
-         elif isinstance(cons[0], function_type) or isinstance(cons[0], Expression):
--            min = optimize.fmin_cobyla(f, x0, cons, iprint=0, **args)
-+            min = optimize.fmin_cobyla(f, x0, cons, disp=0, **args)
-     elif isinstance(cons, function_type) or isinstance(cons, Expression):
--        min = optimize.fmin_cobyla(f, x0, cons, iprint=0, **args)
-+        min = optimize.fmin_cobyla(f, x0, cons, disp=0, **args)
-     return vector(RDF, min)
- 
- 
 diff --git a/src/sage/plot/complex_plot.pyx b/src/sage/plot/complex_plot.pyx
 index ad9693da62..758fb709b7 100644
 --- a/src/sage/plot/complex_plot.pyx
@@ -649,6 +678,76 @@ index ad9693da62..758fb709b7 100644
      """
      import numpy
      cdef unsigned int i, j, imax, jmax
+diff --git a/src/sage/plot/histogram.py b/src/sage/plot/histogram.py
+index 5d28473731..fc4b2046c0 100644
+--- a/src/sage/plot/histogram.py
++++ b/src/sage/plot/histogram.py
+@@ -53,10 +53,17 @@ class Histogram(GraphicPrimitive):
+         """
+         import numpy as np
+         self.datalist=np.asarray(datalist,dtype=float)
++        if 'normed' in options:
++            from sage.misc.superseded import deprecation
++            deprecation(25260, "the 'normed' option is deprecated. Use 'density' instead.")
+         if 'linestyle' in options:
+             from sage.plot.misc import get_matplotlib_linestyle
+             options['linestyle'] = get_matplotlib_linestyle(
+                     options['linestyle'], return_type='long')
++        if options.get('range', None):
++            # numpy.histogram performs type checks on "range" so this must be
++            # actual floats
++            options['range'] = [float(x) for x in options['range']]
+         GraphicPrimitive.__init__(self, options)
+ 
+     def get_minmax_data(self):
+@@ -80,10 +87,14 @@ class Histogram(GraphicPrimitive):
+             {'xmax': 4.0, 'xmin': 0, 'ymax': 2, 'ymin': 0}
+ 
+         TESTS::
+-
+             sage: h = histogram([10,3,5], normed=True)[0]
+-            sage: h.get_minmax_data()  # rel tol 1e-15
+-            {'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.4761904761904765, 'ymin': 0}
++            doctest:warning...:
++            DeprecationWarning: the 'normed' option is deprecated. Use 'density' instead.
++            See https://trac.sagemath.org/25260 for details.
++            sage: h.get_minmax_data()
++            doctest:warning ...:
++            VisibleDeprecationWarning: Passing `normed=True` on non-uniform bins has always been broken, and computes neither the probability density function nor the probability mass function. The result is only correct if the bins are uniform, when density=True will produce the same result anyway. The argument will be removed in a future version of numpy.
++            {'xmax': 10.0, 'xmin': 3.0, 'ymax': 0.476190476190..., 'ymin': 0}
+         """
+         import numpy
+ 
+@@ -152,7 +163,7 @@ class Histogram(GraphicPrimitive):
+                 'rwidth': 'The relative width of the bars as a fraction of the bin width',
+                 'cumulative': '(True or False) If True, then a histogram is computed in which each bin gives the counts in that bin plus all bins for smaller values.  Negative values give a reversed direction of accumulation.',
+                 'range': 'A list [min, max] which define the range of the histogram. Values outside of this range are treated as outliers and omitted from counts.',
+-                'normed': 'Deprecated alias for density',
++                'normed': 'Deprecated. Use density instead.',
+                 'density': '(True or False) If True, the counts are normalized to form a probability density. (n/(len(x)*dbin)',
+                 'weights': 'A sequence of weights the same length as the data list. If supplied, then each value contributes its associated weight to the bin count.',
+                 'stacked': '(True or False) If True, multiple data are stacked on top of each other.',
+@@ -199,7 +210,7 @@ class Histogram(GraphicPrimitive):
+             subplot.hist(self.datalist.transpose(), **options)
+ 
+ 
+-@options(aspect_ratio='automatic',align='mid', weights=None, range=None, bins=10, edgecolor='black')
++@options(aspect_ratio='automatic', align='mid', weights=None, range=None, bins=10, edgecolor='black')
+ def histogram(datalist, **options):
+     """
+     Computes and draws the histogram for list(s) of numerical data.
+@@ -231,8 +242,9 @@ def histogram(datalist, **options):
+     - ``linewidth`` -- (float) width of the lines defining the bars
+     - ``linestyle`` -- (default: 'solid') Style of the line. One of 'solid'
+       or '-', 'dashed' or '--', 'dotted' or ':', 'dashdot' or '-.'
+-    - ``density`` -- (boolean - default: False) If True, the counts are
+-      normalized to form a probability density.
++    - ``density`` -- (boolean - default: False) If True, the result is the
++      value of the probability density function at the bin, normalized such
++      that the integral over the range is 1.
+     - ``range`` -- A list [min, max] which define the range of the
+       histogram. Values outside of this range are treated as outliers and
+       omitted from counts
 diff --git a/src/sage/plot/line.py b/src/sage/plot/line.py
 index 23f5e61446..3b1b51d7cf 100644
 --- a/src/sage/plot/line.py
@@ -718,7 +817,7 @@ index f3da57c370..3806f4b32f 100644
          TESTS:
  
 diff --git a/src/sage/probability/probability_distribution.pyx b/src/sage/probability/probability_distribution.pyx
-index f66cd898b9..35995886d5 100644
+index 1b119e323f..3290b00695 100644
 --- a/src/sage/probability/probability_distribution.pyx
 +++ b/src/sage/probability/probability_distribution.pyx
 @@ -130,7 +130,17 @@ cdef class ProbabilityDistribution:
@@ -741,10 +840,10 @@ index f66cd898b9..35995886d5 100644
          import pylab
          l = [float(self.get_random_element()) for _ in range(num_samples)]
 diff --git a/src/sage/rings/rational.pyx b/src/sage/rings/rational.pyx
-index a0bfe080f5..7d95e7a1a8 100644
+index 12ca1b222b..9bad7dae0c 100644
 --- a/src/sage/rings/rational.pyx
 +++ b/src/sage/rings/rational.pyx
-@@ -1056,7 +1056,7 @@ cdef class Rational(sage.structure.element.FieldElement):
+@@ -1041,7 +1041,7 @@ cdef class Rational(sage.structure.element.FieldElement):
              dtype('O')
  
              sage: numpy.array([1, 1/2, 3/4])
@@ -754,10 +853,10 @@ index a0bfe080f5..7d95e7a1a8 100644
          if mpz_cmp_ui(mpq_denref(self.value), 1) == 0:
              if mpz_fits_slong_p(mpq_numref(self.value)):
 diff --git a/src/sage/rings/real_mpfr.pyx b/src/sage/rings/real_mpfr.pyx
-index 4c630867a4..64e2187f5b 100644
+index 9b90c8833e..1ce05b937d 100644
 --- a/src/sage/rings/real_mpfr.pyx
 +++ b/src/sage/rings/real_mpfr.pyx
-@@ -1438,7 +1438,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
+@@ -1439,7 +1439,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
  
              sage: import numpy
              sage: numpy.arange(10.0)
@@ -767,10 +866,10 @@ index 4c630867a4..64e2187f5b 100644
              dtype('float64')
              sage: numpy.array([1.000000000000000000000000000000000000]).dtype
 diff --git a/src/sage/schemes/elliptic_curves/height.py b/src/sage/schemes/elliptic_curves/height.py
-index 3d270ebf9d..1144f168e3 100644
+index de31fe9883..7a33ea6f5b 100644
 --- a/src/sage/schemes/elliptic_curves/height.py
 +++ b/src/sage/schemes/elliptic_curves/height.py
-@@ -1623,18 +1623,18 @@ class EllipticCurveCanonicalHeight:
+@@ -1627,18 +1627,18 @@ class EllipticCurveCanonicalHeight:
          even::
  
              sage: H.wp_on_grid(v,4)
@@ -798,10 +897,10 @@ index 3d270ebf9d..1144f168e3 100644
          tau = self.tau(v)
          fk, err = self.fk_intervals(v, 15, CDF)
 diff --git a/src/sage/symbolic/ring.pyx b/src/sage/symbolic/ring.pyx
-index 2dcb0492b9..2b1a06385c 100644
+index 9da38002e8..d61e74bf82 100644
 --- a/src/sage/symbolic/ring.pyx
 +++ b/src/sage/symbolic/ring.pyx
-@@ -1135,7 +1135,7 @@ cdef class NumpyToSRMorphism(Morphism):
+@@ -1136,7 +1136,7 @@ cdef class NumpyToSRMorphism(Morphism):
          sage: cos(numpy.int('2'))
          cos(2)
          sage: numpy.cos(numpy.int('2'))
diff --git a/pkgs/applications/science/math/sage/patches/pari-no-threads.patch b/pkgs/applications/science/math/sage/patches/pari-no-threads.patch
deleted file mode 100644
index 13b47dbdd31b..000000000000
--- a/pkgs/applications/science/math/sage/patches/pari-no-threads.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/src/sage/libs/pari/__init__.py b/src/sage/libs/pari/__init__.py
-index e451766474..77eda66097 100644
---- a/src/sage/libs/pari/__init__.py
-+++ b/src/sage/libs/pari/__init__.py
-@@ -205,6 +205,13 @@ def _get_pari_instance():
-     # messages in Sage.
-     P.default("debugmem", 0)
- 
-+    # Make sure pari doesn't use threads, regardless of how it was compiled.
-+    # Threads cause some doctest failures (memory issues). Those could probably
-+    # be solved without disabling threads. But that would require figuring out
-+    # some sensible values for `threadsizemax`. See
-+    # https://pari.math.u-bordeaux.fr/dochtml/html/GP_defaults.html
-+    P.default("nbthreads", 1)
-+
-     return P
- 
- pari = _get_pari_instance()
diff --git a/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch b/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch
new file mode 100644
index 000000000000..64dd6fd93777
--- /dev/null
+++ b/pkgs/applications/science/math/sage/patches/revert-sphinx-always-fork.patch
@@ -0,0 +1,71 @@
+commit f1c59929c3c180ac283334c2b3c901ac8c82f6b1
+Author: Timo Kaufmann <timokau@zoho.com>
+Date:   Sat Oct 20 20:07:41 2018 +0200
+
+    Revert "Something related to the sphinxbuild seems to be leaking memory"
+    
+    This reverts commit 7d85dc796c58c3de57401bc22d3587b94e205091.
+
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 0b24b1a60b..084c3f89d7 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -265,29 +265,35 @@ class DocBuilder(object):
+     # import the customized builder for object.inv files
+     inventory = builder_helper('inventory')
+ 
+-def build_many(target, args):
+-    # Pool() uses an actual fork() to run each new instance. This is important
+-    # for performance reasons, i.e., don't use a forkserver when it becomes
+-    # available with Python 3: Here, sage is already initialized which is quite
+-    # costly, with a forkserver we would have to reinitialize it for every
+-    # document we build. At the same time, don't serialize this by taking the
+-    # pool (and thus the call to fork()) out completely: The call to Sphinx
+-    # leaks memory, so we need to build each document in its own process to
+-    # control the RAM usage.
+-    from multiprocessing import Pool
+-    pool = Pool(NUM_THREADS, maxtasksperchild=1)
+-    # map_async handles KeyboardInterrupt correctly. Plain map and
+-    # apply_async does not, so don't use it.
+-    x = pool.map_async(target, args, 1)
+-    try:
+-        ret = x.get(99999)
+-        pool.close()
+-        pool.join()
+-    except Exception:
+-        pool.terminate()
+-        if ABORT_ON_ERROR:
+-            raise
+-    return ret
++if NUM_THREADS > 1:
++    def build_many(target, args):
++        from multiprocessing import Pool
++        pool = Pool(NUM_THREADS, maxtasksperchild=1)
++        # map_async handles KeyboardInterrupt correctly. Plain map and
++        # apply_async does not, so don't use it.
++        x = pool.map_async(target, args, 1)
++        try:
++            ret = x.get(99999)
++            pool.close()
++            pool.join()
++        except Exception:
++            pool.terminate()
++            if ABORT_ON_ERROR:
++                raise
++        return ret
++else:
++    def build_many(target, args):
++        results = []
++
++        for arg in args:
++            try:
++                results.append(target(arg))
++            except Exception:
++                if ABORT_ON_ERROR:
++                    raise
++
++        return results
++
+ 
+ ##########################################
+ #      Parallel Building Ref Manual      #
diff --git a/pkgs/applications/science/math/sage/patches/singular-4.1.1p2.patch b/pkgs/applications/science/math/sage/patches/singular-4.1.1p2.patch
deleted file mode 100644
index 4c8df92904ed..000000000000
--- a/pkgs/applications/science/math/sage/patches/singular-4.1.1p2.patch
+++ /dev/null
@@ -1,274 +0,0 @@
-diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
-index 9d65c9fa6c..a028bbe719 100644
---- a/src/sage/interfaces/singular.py
-+++ b/src/sage/interfaces/singular.py
-@@ -654,7 +654,7 @@ class Singular(ExtraTabCompletion, Expect):
- 
-         s = Expect.eval(self, x, **kwds)
- 
--        if s.find("error") != -1 or s.find("Segment fault") != -1:
-+        if s.find("error occurred") != -1 or s.find("Segment fault") != -1:
-             raise SingularError('Singular error:\n%s'%s)
- 
-         if get_verbose() > 0:
-@@ -1079,7 +1079,7 @@ class Singular(ExtraTabCompletion, Expect):
-             sage: S = singular.ring('real', '(a,b)', 'lp')
-             sage: singular.current_ring()
-             polynomial ring, over a field, global ordering
--            //   coefficients: float
-+            //   coefficients: Float()
-             //   number of vars : 2
-             //        block   1 : ordering lp
-             //                  : names    a b
-@@ -1157,7 +1157,7 @@ class Singular(ExtraTabCompletion, Expect):
-              sage: singular._tab_completion()
-              ['exteriorPower',
-               ...
--              'flintZ']
-+              'crossprod']
-          """
-         p = re.compile("// *([a-z0-9A-Z_]*).*") #compiles regular expression
-         proclist = self.eval("listvar(proc)").splitlines()
-@@ -1183,7 +1183,7 @@ class Singular(ExtraTabCompletion, Expect):
-         EXAMPLES::
- 
-             sage: singular.version()
--            "Singular ... version 4.1.0 ...
-+            "Singular ... version 4...
-         """
-         return singular_version()
- 
-@@ -1562,7 +1562,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
-         elif charstr[0] in ['0', 'QQ']:
-             from sage.all import QQ
-             br = QQ
--        elif charstr[0]=='real':
-+        elif charstr[0].startswith('Float'):
-             from sage.all import RealField, ceil, log
-             prec = singular.eval('ringlist(basering)[1][2][1]')
-             br = RealField(ceil((ZZ(prec)+1)/log(2,10)))
-@@ -1750,7 +1750,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
- 
-         # Singular 4 puts parentheses around floats and sign outside them
-         charstr = self.parent().eval('charstr(basering)').split(',',1)
--        if charstr[0] in ['real', 'complex']:
-+        if charstr[0]=='complex' or charstr[0].startswith('Float'):
-               for i in range(coeff_start, 2 * coeff_start):
-                   singular_poly_list[i] = singular_poly_list[i].replace('(','').replace(')','')
- 
-@@ -1992,7 +1992,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
-             sage: S = singular.ring('real', '(a,b)', 'lp')
-             sage: singular.current_ring()
-             polynomial ring, over a field, global ordering
--            //   coefficients: float
-+            //   coefficients: Float()
-             //   number of vars : 2
-             //        block   1 : ordering lp
-             //                  : names    a b
-@@ -2072,7 +2072,7 @@ class SingularElement(ExtraTabCompletion, ExpectElement):
-             sage: R._tab_completion()
-             ['exteriorPower',
-              ...
--             'flintZ']
-+             'crossprod']
-         """
-         return self.parent()._tab_completion()
- 
-@@ -2358,7 +2358,7 @@ def singular_version():
-     EXAMPLES::
- 
-         sage: singular.version()
--        "Singular ... version 4.1.0 ...
-+        "Singular ... version 4...
-     """
-     return singular.eval('system("--version");')
- 
-diff --git a/src/sage/libs/singular/decl.pxd b/src/sage/libs/singular/decl.pxd
-index 4b658c4807..d863740419 100644
---- a/src/sage/libs/singular/decl.pxd
-+++ b/src/sage/libs/singular/decl.pxd
-@@ -170,7 +170,7 @@ cdef extern from "singular/Singular/libsingular.h":
- 
-     int n_NumberOfParameters(const n_Procs_s* r)
- 
--    ctypedef struct poly "polyrec":
-+    ctypedef struct poly "spolyrec":
-         poly *next
-         number *coef
-         unsigned long exp[1]
-@@ -630,9 +630,13 @@ cdef extern from "singular/Singular/libsingular.h":
-     # return p*q, destroys p and q
-     poly *p_Mult_q(poly *p, poly *q, ring *r)
- 
-+    # polynomial division, ignoring the rest
-+    # via singclap_pdivide resp. idLift, destroys p,q
-+    poly *p_Divide(poly *p, poly *q, ring *r)
-+
-     # divide monomial p by monomial q, p,q const
- 
--    poly *pDivide(poly *p,poly *q)
-+    poly *pMDivide(poly *p,poly *q)
- 
-     # return the i-th power of p; p destroyed, requires global ring
- 
-diff --git a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
-index 2a8d9ae021..aeff53af6c 100644
---- a/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
-+++ b/src/sage/rings/polynomial/multi_polynomial_libsingular.pyx
-@@ -190,8 +190,8 @@ from sage.libs.singular.decl cimport (
-     n_IsUnit, n_Invers,
-     p_ISet, rChangeCurrRing, p_Copy, p_Init, p_SetCoeff, p_Setm, p_SetExp, p_Add_q,
-     p_NSet, p_GetCoeff, p_Delete, p_GetExp, pNext, rRingVar, omAlloc0, omStrDup,
--    omFree, pDivide, p_SetCoeff0, n_Init, p_DivisibleBy, pLcm, p_LmDivisibleBy,
--    pDivide, p_IsConstant, p_ExpVectorEqual, p_String, p_LmInit, n_Copy,
-+    omFree, pMDivide, p_Divide, p_SetCoeff0, n_Init, p_DivisibleBy, pLcm, p_LmDivisibleBy,
-+    pMDivide, p_IsConstant, p_ExpVectorEqual, p_String, p_LmInit, n_Copy,
-     p_IsUnit, p_Series, p_Head, idInit, fast_map_common_subexp, id_Delete,
-     p_IsHomogeneous, p_Homogen, p_Totaldegree,pLDeg1_Totaldegree, singclap_pdivide, singclap_factorize,
-     idLift, IDELEMS, On, Off, SW_USE_CHINREM_GCD, SW_USE_EZGCD,
-@@ -1693,8 +1693,8 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
-         if not g._poly:
-             raise ZeroDivisionError
- 
--        if r!=currRing: rChangeCurrRing(r)  # pDivide
--        res = pDivide(f._poly, g._poly)
-+        if r!=currRing: rChangeCurrRing(r)  # pMDivide
-+        res = pMDivide(f._poly, g._poly)
-         if coeff:
-             if r.cf.type == n_unknown or r.cf.cfDivBy(p_GetCoeff(f._poly, r), p_GetCoeff(g._poly, r), r.cf):
-                 n = r.cf.cfDiv( p_GetCoeff(f._poly, r) , p_GetCoeff(g._poly, r), r.cf)
-@@ -1853,8 +1853,8 @@ cdef class MPolynomialRing_libsingular(MPolynomialRing_base):
-                    and (<MPolynomial_libsingular>g) \
-                    and g.parent() is self \
-                    and p_LmDivisibleBy((<MPolynomial_libsingular>g)._poly, m, r):
--                if r!=currRing: rChangeCurrRing(r)  # pDivide
--                flt = pDivide(f._poly, (<MPolynomial_libsingular>g)._poly)
-+                if r!=currRing: rChangeCurrRing(r)  # pMDivide
-+                flt = pMDivide(f._poly, (<MPolynomial_libsingular>g)._poly)
-                 #p_SetCoeff(flt, n_Div( p_GetCoeff(f._poly, r) , p_GetCoeff((<MPolynomial_libsingular>g)._poly, r), r), r)
-                 p_SetCoeff(flt, n_Init(1, r), r)
-                 return new_MP(self,flt), g
-@@ -4023,16 +4023,6 @@ cdef class MPolynomial_libsingular(MPolynomial):
-             Traceback (most recent call last):
-             ...
-             NotImplementedError: Division of multivariate polynomials over non fields by non-monomials not implemented.
--
--        TESTS::
--
--            sage: P.<x,y> = ZZ[]
--            sage: p = 3*(-x^8*y^2 - x*y^9 + 6*x^8*y + 17*x^2*y^6 - x^3*y^2)
--            sage: q = 7*(x^2 + x*y + y^2 + 1)
--            sage: p*q//q == p
--            True
--            sage: p*q//p == q
--            True
-         """
-         cdef MPolynomialRing_libsingular parent = self._parent
-         cdef ring *r = self._parent_ring
-@@ -4052,13 +4042,18 @@ cdef class MPolynomial_libsingular(MPolynomial):
-         _right = <MPolynomial_libsingular>right
- 
-         if r.cf.type != n_unknown:
-+            if r.cf.type == n_Z:
-+                P = parent.change_ring(RationalField())
-+                f = P(self)//P(right)
-+                CM = list(f)
-+                return parent(sum([c.floor()*m for c,m in CM]))
-             if _right.is_monomial():
-                 p = _self._poly
-                 quo = p_ISet(0,r)
--                if r != currRing: rChangeCurrRing(r)   # pDivide
-+                if r != currRing: rChangeCurrRing(r)   # pMDivide
-                 while p:
-                     if p_DivisibleBy(_right._poly, p, r):
--                        temp = pDivide(p, _right._poly)
-+                        temp = pMDivide(p, _right._poly)
-                         p_SetCoeff0(temp, n_Copy(p_GetCoeff(p, r), r), r)
-                         quo = p_Add_q(quo, temp, r)
-                     p = pNext(p)
-@@ -4794,6 +4789,8 @@ cdef class MPolynomial_libsingular(MPolynomial):
-             sage: p = -x*y + x*z + 54*x - 2
-             sage: (5*p^2).lcm(3*p) == 15*p^2
-             True
-+            sage: lcm(2*x,2*x*y)
-+            2*x*y
-         """
-         cdef ring *_ring = self._parent_ring
-         cdef poly *ret
-@@ -4821,9 +4818,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
-         if _ring!=currRing: rChangeCurrRing(_ring)  # singclap_gcd
-         gcd = singclap_gcd(p_Copy(self._poly, _ring), p_Copy(_g._poly, _ring), _ring )
-         prod = pp_Mult_qq(self._poly, _g._poly, _ring)
--        ret = singclap_pdivide(prod , gcd , _ring)
--        p_Delete(&prod, _ring)
--        p_Delete(&gcd, _ring)
-+        ret = p_Divide(prod, gcd, _ring)
-         if count >= 20:
-             sig_off()
-         return new_MP(self._parent, ret)
-@@ -4866,7 +4861,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
-             sage: f.quo_rem(y)
-             (2*x^2, x + 1)
-             sage: f.quo_rem(3*x)
--            (2*x*y + 1, -4*x^2*y - 2*x + 1)
-+            (0, 2*x^2*y + x + 1)
- 
-         TESTS::
- 
-@@ -4888,7 +4883,7 @@ cdef class MPolynomial_libsingular(MPolynomial):
-         if right.is_zero():
-             raise ZeroDivisionError
- 
--        if not self._parent._base.is_field() and not is_IntegerRing(self._parent._base):
-+        if not self._parent._base.is_field():
-             py_quo = self//right
-             py_rem = self - right*py_quo
-             return py_quo, py_rem
-diff --git a/src/sage/rings/polynomial/plural.pyx b/src/sage/rings/polynomial/plural.pyx
-index d5439f7f08..ad20ebcca0 100644
---- a/src/sage/rings/polynomial/plural.pyx
-+++ b/src/sage/rings/polynomial/plural.pyx
-@@ -998,7 +998,7 @@ cdef class NCPolynomialRing_plural(Ring):
-         if not g._poly:
-             raise ZeroDivisionError
- 
--        res = pDivide(f._poly,g._poly)
-+        res = pMDivide(f._poly,g._poly)
-         if coeff:
-             if (r.cf.type == n_unknown) or r.cf.cfDivBy(p_GetCoeff(f._poly, r), p_GetCoeff(g._poly, r), r.cf):
-                 n = r.cf.cfDiv( p_GetCoeff(f._poly, r) , p_GetCoeff(g._poly, r), r.cf)
-@@ -1193,7 +1193,7 @@ cdef class NCPolynomialRing_plural(Ring):
-             if isinstance(g, NCPolynomial_plural) \
-                    and (<NCPolynomial_plural>g) \
-                    and p_LmDivisibleBy((<NCPolynomial_plural>g)._poly, m, r):
--                flt = pDivide(f._poly, (<NCPolynomial_plural>g)._poly)
-+                flt = pMDivide(f._poly, (<NCPolynomial_plural>g)._poly)
-                 #p_SetCoeff(flt, n_Div( p_GetCoeff(f._poly, r) , p_GetCoeff((<NCPolynomial_plural>g)._poly, r), r), r)
-                 p_SetCoeff(flt, n_Init(1, r), r)
-                 return new_NCP(self,flt), g
-diff --git a/src/sage/rings/polynomial/polynomial_singular_interface.py b/src/sage/rings/polynomial/polynomial_singular_interface.py
-index 9331169f8b..f753610fd3 100644
---- a/src/sage/rings/polynomial/polynomial_singular_interface.py
-+++ b/src/sage/rings/polynomial/polynomial_singular_interface.py
-@@ -81,8 +81,8 @@ class PolynomialRing_singular_repr:
-             sage: R.<x,y> = PolynomialRing(CC)
-             sage: singular(R)
-             polynomial ring, over a field, global ordering
--            //   coefficients: float[I](complex:15 digits, additional 0 digits)/(I^2+1)
--            //   number of vars : 2
-+            // coefficients: real[I](complex:15 digits, additional 0 digits)/(I^2+1)
-+            // number of vars : 2
-             //        block   1 : ordering dp
-             //                  : names    x y
-             //        block   2 : ordering C
-@@ -90,8 +90,8 @@ class PolynomialRing_singular_repr:
-             sage: R.<x,y> = PolynomialRing(RealField(100))
-             sage: singular(R)
-             polynomial ring, over a field, global ordering
--            //   coefficients: float
--            //   number of vars : 2
-+            // coefficients: Float()
-+            // number of vars : 2
-             //        block   1 : ordering dp
-             //                  : names    x y
-             //        block   2 : ordering C
diff --git a/pkgs/applications/science/math/sage/patches/spkg-scripts.patch b/pkgs/applications/science/math/sage/patches/spkg-scripts.patch
deleted file mode 100644
index 4d37998b288b..000000000000
--- a/pkgs/applications/science/math/sage/patches/spkg-scripts.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-commit f02714d4aea80e17cb8df62bab75d7c1a1b61a8e
-Author: Timo Kaufmann <timokau@zoho.com>
-Date:   Mon Jul 9 18:26:18 2018 +0200
-
-    Don't attempt to create dirs when showing pkg info
-    
-    The script dir cannot be assumed to be writeable after installation.
-
-diff --git a/build/bin/sage-spkg b/build/bin/sage-spkg
-index f3e02aeae5..190d558ad1 100755
---- a/build/bin/sage-spkg
-+++ b/build/bin/sage-spkg
-@@ -167,14 +167,6 @@ if [ -z "$SAGE_BUILD_DIR" ]; then
-     export SAGE_BUILD_DIR="$SAGE_LOCAL/var/tmp/sage/build"
- fi
- 
--for dir in "$SAGE_SPKG_INST" "$SAGE_SPKG_SCRIPTS"; do
--    mkdir -p "$dir"
--    if [ $? -ne 0 ]; then
--        error_msg "Error creating directory $dir"
--        exit 1
--    fi
--done
--
- 
- # Remove '.' from PYTHONPATH, which may also come from SAGE_PATH, to avoid
- # trouble with setuptools / easy_install (cf. #10192, #10176):
-@@ -563,11 +555,13 @@ fi
- # Setup directories
- ##################################################################
- 
--mkdir -p "$SAGE_BUILD_DIR"
--if [ $? -ne 0 ]; then
--    error_msg "Error creating directory $SAGE_BUILD_DIR"
--    exit 1
--fi
-+for dir in "$SAGE_SPKG_INST" "$SAGE_SPKG_SCRIPTS" "$SAGE_BUILD_DIR"; do
-+    mkdir -p "$dir"
-+    if [ $? -ne 0 ]; then
-+        error_msg "Error creating directory $dir"
-+        exit 1
-+    fi
-+done
- 
- # Trac #5852: check write permissions
- if [ ! -w "$SAGE_BUILD_DIR" ]; then
diff --git a/pkgs/applications/science/math/sage/patches/test-in-tmpdir.patch b/pkgs/applications/science/math/sage/patches/test-in-tmpdir.patch
deleted file mode 100644
index febab3702771..000000000000
--- a/pkgs/applications/science/math/sage/patches/test-in-tmpdir.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-diff --git a/src/sage/repl/ipython_kernel/install.py b/src/sage/repl/ipython_kernel/install.py
-index aa23c8405d..8a87de0591 100644
---- a/src/sage/repl/ipython_kernel/install.py
-+++ b/src/sage/repl/ipython_kernel/install.py
-@@ -112,7 +112,7 @@ class SageKernelSpec(object):
-         EXAMPLES::
- 
-             sage: from sage.repl.ipython_kernel.install import SageKernelSpec
--            sage: spec = SageKernelSpec()
-+            sage: spec = SageKernelSpec(prefix = tmp_dir())
-             sage: spec.use_local_mathjax()
-             sage: mathjax = os.path.join(spec.nbextensions_dir, 'mathjax')
-             sage: os.path.isdir(mathjax)
-@@ -129,7 +129,7 @@ class SageKernelSpec(object):
-         EXAMPLES::
- 
-             sage: from sage.repl.ipython_kernel.install import SageKernelSpec
--            sage: spec = SageKernelSpec()
-+            sage: spec = SageKernelSpec(prefix = tmp_dir())
-             sage: spec.use_local_jsmol()
-             sage: jsmol = os.path.join(spec.nbextensions_dir, 'jsmol')
-             sage: os.path.isdir(jsmol)
-@@ -146,7 +146,7 @@ class SageKernelSpec(object):
-         EXAMPLES::
- 
-             sage: from sage.repl.ipython_kernel.install import SageKernelSpec
--            sage: spec = SageKernelSpec()
-+            sage: spec = SageKernelSpec(prefix = tmp_dir())
-             sage: spec.use_local_threejs()
-             sage: threejs = os.path.join(spec.nbextensions_dir, 'threejs')
-             sage: os.path.isdir(threejs)