about summary refs log tree commit diff
path: root/pkgs/applications/science/math
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/science/math')
-rw-r--r--pkgs/applications/science/math/eigenmath/default.nix6
-rw-r--r--pkgs/applications/science/math/sage/default.nix3
-rw-r--r--pkgs/applications/science/math/sage/patches/disable-slow-glpk-test.patch6
-rw-r--r--pkgs/applications/science/math/sage/patches/numpy-1.25-deprecation.patch18
-rw-r--r--pkgs/applications/science/math/sage/python-modules/sage-setup.nix4
-rw-r--r--pkgs/applications/science/math/sage/sage-src.nix113
-rw-r--r--pkgs/applications/science/math/sage/sagedoc.nix25
-rw-r--r--pkgs/applications/science/math/sage/sagelib.nix24
8 files changed, 35 insertions, 164 deletions
diff --git a/pkgs/applications/science/math/eigenmath/default.nix b/pkgs/applications/science/math/eigenmath/default.nix
index 561c9c66a50ec..3cd9384ecf1fd 100644
--- a/pkgs/applications/science/math/eigenmath/default.nix
+++ b/pkgs/applications/science/math/eigenmath/default.nix
@@ -7,13 +7,13 @@
 
 stdenv.mkDerivation rec {
   pname = "eigenmath";
-  version = "unstable-2023-12-31";
+  version = "unstable-2024-01-22";
 
   src = fetchFromGitHub {
     owner = "georgeweigt";
     repo = pname;
-    rev = "cc92936e226b0a4c77cdc5d00b7a02c472746f6f";
-    hash = "sha256-wY06pZzqcgYdBS7ecB3ZnvmK74ve651n6aHHAN5DWdw=";
+    rev = "db4b22cd536cefbdf0b6c928f11c793a5580da0b";
+    hash = "sha256-T1GXh1go08XVTToEg5Dq4BuwTCxxqYwQsx+c8g1RPxg=";
   };
 
   checkPhase = let emulator = stdenv.hostPlatform.emulator buildPackages; in ''
diff --git a/pkgs/applications/science/math/sage/default.nix b/pkgs/applications/science/math/sage/default.nix
index a4173d1f5e6d8..765c691c95551 100644
--- a/pkgs/applications/science/math/sage/default.nix
+++ b/pkgs/applications/science/math/sage/default.nix
@@ -32,6 +32,7 @@ let
     });
   };
 
+  # matches src/sage/repl/ipython_kernel/install.py:kernel_spec
   jupyter-kernel-definition = {
     displayName = "SageMath ${sage-src.version}";
     argv = [
@@ -42,7 +43,7 @@ let
       "-f"
       "{connection_file}"
     ];
-    language = "sagemath";
+    language = "sage";
     # just one 16x16 logo is available
     logo32 = "${sage-src}/src/doc/common/themes/sage/static/sageicon.png";
     logo64 = "${sage-src}/src/doc/common/themes/sage/static/sageicon.png";
diff --git a/pkgs/applications/science/math/sage/patches/disable-slow-glpk-test.patch b/pkgs/applications/science/math/sage/patches/disable-slow-glpk-test.patch
index c04463e7e99c4..89f0613589d4c 100644
--- a/pkgs/applications/science/math/sage/patches/disable-slow-glpk-test.patch
+++ b/pkgs/applications/science/math/sage/patches/disable-slow-glpk-test.patch
@@ -1,12 +1,12 @@
 diff --git a/src/sage/graphs/generic_graph.py b/src/sage/graphs/generic_graph.py
-index 0070705f78..ac19818f1b 100644
+index 2deb533f7f..663ff2cd13 100644
 --- a/src/sage/graphs/generic_graph.py
 +++ b/src/sage/graphs/generic_graph.py
-@@ -6699,12 +6699,6 @@ class GenericGraph(GenericGraph_pyx):
+@@ -6953,12 +6953,6 @@ class GenericGraph(GenericGraph_pyx):
              sage: G = DiGraph(d6, format='dig6')
              sage: G.edge_connectivity()
              5
--            sage: G.edge_disjoint_spanning_trees(5)  # long time
+-            sage: G.edge_disjoint_spanning_trees(5)     # long time                     # needs sage.numerical.mip
 -            [Digraph on 28 vertices,
 -             Digraph on 28 vertices,
 -             Digraph on 28 vertices,
diff --git a/pkgs/applications/science/math/sage/patches/numpy-1.25-deprecation.patch b/pkgs/applications/science/math/sage/patches/numpy-1.25-deprecation.patch
deleted file mode 100644
index 539afc4b3b77d..0000000000000
--- a/pkgs/applications/science/math/sage/patches/numpy-1.25-deprecation.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff --git a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
-index aa153fd4cd..eebbe87aff 100644
---- a/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
-+++ b/src/sage/tests/books/computational-mathematics-with-sagemath/graphique_doctest.py
-@@ -134,11 +134,11 @@ Sage example in ./graphique.tex, line 1120::
-   sage: t = srange(0, 5, 0.1); p = Graphics()
-   sage: for k in srange(0, 10, 0.15):
-   ....:       y = integrate.odeint(f, k, t)
--  ....:       p += line(zip(t, flatten(y)))
-+  ....:       p += line(zip(t, y.flatten()))
-   sage: t = srange(0, -5, -0.1); q = Graphics()
-   sage: for k in srange(0, 10, 0.15):
-   ....:       y = integrate.odeint(f, k, t)
--  ....:       q += line(zip(t, flatten(y)))
-+  ....:       q += line(zip(t, y.flatten()))
-   sage: y = var('y')
-   sage: v = plot_vector_field((1, -cos(x*y)), (x,-5,5), (y,-2,11))
-   sage: g = p + q + v; g.show()
diff --git a/pkgs/applications/science/math/sage/python-modules/sage-setup.nix b/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
index e1c497678d50b..a96f7ccd5d4c0 100644
--- a/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
+++ b/pkgs/applications/science/math/sage/python-modules/sage-setup.nix
@@ -1,7 +1,7 @@
 { lib
 , buildPythonPackage
 , sage-src
-, cython
+, cython_3
 , jinja2
 , pkgconfig # the python module, not the pkg-config alias
 }:
@@ -11,7 +11,7 @@ buildPythonPackage rec {
   pname = "sage-setup";
   src = sage-src;
 
-  nativeBuildInputs = [ cython ];
+  nativeBuildInputs = [ cython_3 ];
   buildInputs = [ pkgconfig ];
   propagatedBuildInputs = [ jinja2 ];
 
diff --git a/pkgs/applications/science/math/sage/sage-src.nix b/pkgs/applications/science/math/sage/sage-src.nix
index 96b1adb562f49..4149e9163a363 100644
--- a/pkgs/applications/science/math/sage/sage-src.nix
+++ b/pkgs/applications/science/math/sage/sage-src.nix
@@ -1,6 +1,7 @@
 { stdenv
 , fetchFromGitHub
 , fetchpatch
+, fetchurl
 }:
 
 # This file is responsible for fetching the sage source and adding necessary patches.
@@ -9,14 +10,23 @@
 # all get the same sources with the same patches applied.
 
 stdenv.mkDerivation rec {
-  version = "10.0";
+  version = "10.2";
   pname = "sage-src";
 
   src = fetchFromGitHub {
     owner = "sagemath";
     repo = "sage";
     rev = version;
-    sha256 = "sha256-zN/Lo/GBCjYGemuaYpgG3laufN8te3wPjXMQ+Me9zgY=";
+    sha256 = "sha256-VXnPdJhtw5Y/anecrVpevJDCyBVfnjksyuuZslNipm4=";
+  };
+
+  # contains essential files (e.g., setup.cfg) generated by the bootstrap script.
+  # TODO: investigate https://github.com/sagemath/sage/pull/35950
+  configure-src = fetchurl {
+    # the hash below is the tagged commit's _parent_. it can also be found by looking for
+    # the "configure" asset at https://github.com/sagemath/sage/releases/tag/${version}
+    url = "mirror://sageupstream/configure/configure-b2813506039143e6f0abe859ab67a343abf72c2e.tar.gz";
+    sha256 = "sha256-a1v0XyoKI+zO6Sjm8DzEwItRHbIgRDbpj4UfwVH+/hw=";
   };
 
   # Patches needed because of particularities of nix or the way this is packaged.
@@ -52,99 +62,6 @@ stdenv.mkDerivation rec {
   # should come from or be proposed to upstream. This list will probably never
   # be empty since dependencies update all the time.
   packageUpgradePatches = [
-    # https://github.com/sagemath/sage/pull/35584, landed in 10.1.beta1
-    (fetchpatch {
-      name = "networkx-3.1-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/be0aab74fd7e399e146988ef27260d2837baebae.diff";
-      sha256 = "sha256-xBGrylNaiF7CpfmX9/4lTioP2LSYKoRCkKlKSGZuv9U=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35612, landed in 10.1.beta1
-    (fetchpatch {
-      name = "linbox-1.7-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/35cbd2f2a2c4c355455d39b1424f05ea0aa4349b.diff";
-      sha256 = "sha256-/TpvIQZUqmbUuz6wvp3ni9oRir5LBA2FKDJcmnHI1r4=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35619, landed in 10.1.beta1
-    (fetchpatch {
-      name = "maxima-5.46.0-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/4ddf9328e7598284d4bc03cd2ed890f0be6b6399.diff";
-      sha256 = "sha256-f6YaZiLSj+E0LJMsMZHDt6vecWffSAuUHYVkegBEhno=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35635, landed in 10.1.beta1
-    (fetchpatch {
-      name = "sympy-1.12-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/1a73b3bbbfa0f4a297e05d49305070e1ed5ae598.diff";
-      sha256 = "sha256-k8Oam+EiRcfXC7qCdLacCx+7vpUAw2K1wsjKcQbeGb4=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35826, landed in 10.1.beta5
-    (fetchpatch {
-      name = "numpy-1.25.0-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/ecfe06b8f1fe729b07e885f0de55244467e5c137.diff";
-      sha256 = "sha256-G0xhl+LyNdDYPzRqSHK3fHaepcIzpuwmqRiussraDf0=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35826#issuecomment-1658569891
-    ./patches/numpy-1.25-deprecation.patch
-
-    # https://github.com/sagemath/sage/pull/35842, landed in 10.1.beta5
-    (fetchpatch {
-      name = "scipy-1.11-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/90ece168c3c61508baa36659b0027b7dd8b43add.diff";
-      sha256 = "sha256-Y5TmuJcUJR+veb2AuSVODGs+xkVV+pTM8fWTm4q+NDs=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35825, landed in 10.1.beta6
-    (fetchpatch {
-      name = "singular-4.3.2p2-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/1a1b49f814cdf4c4c8d0ac8930610f3fef6af5b0.diff";
-      sha256 = "sha256-GqMgoi0tsP7zcCcPumhdsbvhPB6fgw1ufx6gHlc6iSc=";
-    })
-
-    # https://github.com/sagemath/sage/pull/36006, landed in 10.2.beta2
-    (fetchpatch {
-      name = "gmp-6.3-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/5e841de46c3baa99cd1145b36ff9163e9340a55c.diff";
-      sha256 = "sha256-fJPDryLtGBQz9qHDiCkBwjiW2lN6v7HiHgxY7CTeHcs=";
-    })
-
-    # https://github.com/sagemath/sage/pull/36279, landed in 10.2.beta4
-    (fetchpatch {
-       name = "matplotlib-3.8-upgrade.patch";
-       url = "https://github.com/sagemath/sage/commit/0fcf88935908440930c5f79202155aca4ad57518.diff";
-       sha256 = "sha256-mvqAHaTCXsxPv901L8HSTnrfghfXYdq0wfLoP/cYQZI=";
-    })
-
-    # https://github.com/sagemath/sage/pull/35658, landed in 10.1.beta2
-    (fetchpatch {
-      name = "sphinx-7-upgrade.patch";
-      url = "https://github.com/sagemath/sage/commit/cacd9a89b5c4fdcf84a8dd2b7d5bdc10cc78109a.diff";
-      sha256 = "sha256-qJvliTJjR3XBc5pH6Q0jtm8c4bhtZcTcF3O04Ro1uaU=";
-    })
-
-    # https://github.com/sagemath/sage/pull/36296, landed in 10.2.beta4
-    (fetchpatch {
-      name = "duplicate-args-region_plot.patch";
-      url = "https://github.com/sagemath/sage/commit/461727b453712550a2c5dc0ae11933523255aaed.diff";
-      sha256 = "sha256-mC8084VQoUBk4hocALF+Y9Cwb38Zt360eldi/SSjna8=";
-    })
-
-    # https://github.com/sagemath/sage/pull/36218, landed in 10.2.beta3
-    (fetchpatch {
-      name = "sageenv-disable-file-validation.patch";
-      url = "https://github.com/sagemath/sage/commit/31a764f4a9ec54d3ea970aa9514a088c4e603ebd.diff";
-      sha256 = "sha256-NhYUTTmYlyjss3eS8HZXP8U11TElQY0cv6KW4wBOaJY=";
-    })
-
-    # https://github.com/sagemath/sage/pull/36235, landed in 10.2.beta3
-    (fetchpatch {
-      name = "ecl-23.9.9.patch";
-      url = "https://github.com/sagemath/sage/commit/b6b50a80e9660c002d069019f5b8f04e9324a423.diff";
-      sha256 = "sha256-nF+5oKad1VYms6Dxr1t9/V0XBkoMfhy0KCY/ZPddrm0=";
-    })
   ];
 
   patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
@@ -158,11 +75,17 @@ stdenv.mkDerivation rec {
     sed -i \
       "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
       src/sage/env.py
+
+    # sage --docbuild unsets JUPYTER_PATH, which breaks our docbuilding
+    # https://trac.sagemath.org/ticket/33650#comment:32
+    sed -i "/export JUPYTER_PATH/d" src/bin/sage
   '';
 
   buildPhase = "# do nothing";
 
   installPhase = ''
     cp -r . "$out"
+    tar xkzf ${configure-src} -C "$out"
+    rm "$out/configure"
   '';
 }
diff --git a/pkgs/applications/science/math/sage/sagedoc.nix b/pkgs/applications/science/math/sage/sagedoc.nix
index 228b5aa2c609c..5e2191486bf08 100644
--- a/pkgs/applications/science/math/sage/sagedoc.nix
+++ b/pkgs/applications/science/math/sage/sagedoc.nix
@@ -11,11 +11,6 @@ stdenv.mkDerivation rec {
 
   strictDeps = true;
 
-  nativeBuildInputs = [
-    # for patchShebangs below
-    python3
-  ];
-
   unpackPhase = ''
     export SAGE_DOC_OVERRIDE="$PWD/share/doc/sage"
     export SAGE_DOC_SRC_OVERRIDE="$PWD/docsrc"
@@ -29,18 +24,6 @@ stdenv.mkDerivation rec {
     export HOME="$TMPDIR/sage_home"
     mkdir -p "$HOME"
 
-    # run bootstrap script to generate Sage spkg docs, because unfortunately some unrelated doc
-    # pages link to them. it needs a few ugly (but self-contained) hacks for a standalone run.
-    cp -r "${src}/build" "$HOME"
-    chmod -R 755 "$HOME/build"
-    sed -i "/assert/d" "$HOME/build/sage_bootstrap/env.py"
-    sed -i "s|sage-bootstrap-python|python3|" "$HOME/build/bin/sage-package"
-    patchShebangs "$HOME/build/bin/sage-package"
-    pushd "$SAGE_DOC_SRC_OVERRIDE"
-    sed -i "s|OUTPUT_DIR=\"src/doc/|OUTPUT_DIR=\"$SAGE_DOC_SRC_OVERRIDE/|" bootstrap
-    PATH="$HOME/build/bin:$PATH" SAGE_ROOT="${src}" ./bootstrap
-    popd
-
     # adapted from src/doc/Makefile (doc-src target), which tries to call Sage from PATH
     mkdir -p $SAGE_DOC_SRC_OVERRIDE/en/reference/repl
     ${sage-with-env}/bin/sage -advanced > $SAGE_DOC_SRC_OVERRIDE/en/reference/repl/options.txt
@@ -51,12 +34,10 @@ stdenv.mkDerivation rec {
     # jupyter-sphinx calls the sagemath jupyter kernel during docbuild
     export JUPYTER_PATH=${jupyter-kernel-specs}
 
-    # sage --docbuild unsets JUPYTER_PATH, so we call sage_docbuild directly
-    # https://trac.sagemath.org/ticket/33650#comment:32
-    ${sage-with-env}/bin/sage --python3 -m sage_docbuild \
+    ${sage-with-env}/bin/sage --docbuild \
       --mathjax \
       --no-pdf-links \
-      all html < /dev/null
+      all html
   '';
 
   installPhase = ''
@@ -80,7 +61,7 @@ stdenv.mkDerivation rec {
     # sagemath_doc_html tests assume sage tests are being run, so we
     # compromise: we run standard tests, but only on files containing
     # relevant tests. as of Sage 9.6, there are only 4 such files.
-    grep -PRl "#.*optional.*sagemath_doc_html" ${src}/src/sage{,_docbuild} | \
+    grep -PRl "#.*(optional|needs).*sagemath_doc_html" ${src}/src/sage{,_docbuild} | \
       xargs ${sage-with-env}/bin/sage -t --optional=sage,sagemath_doc_html
   '';
 }
diff --git a/pkgs/applications/science/math/sage/sagelib.nix b/pkgs/applications/science/math/sage/sagelib.nix
index f8beabaac1ffa..5a1f4ee473c9b 100644
--- a/pkgs/applications/science/math/sage/sagelib.nix
+++ b/pkgs/applications/science/math/sage/sagelib.nix
@@ -48,7 +48,7 @@
 , cvxopt
 , cypari2
 , cysignals
-, cython
+, cython_3
 , fpylll
 , gmpy2
 , importlib-metadata
@@ -152,7 +152,7 @@ buildPythonPackage rec {
     cvxopt
     cypari2
     cysignals
-    cython
+    cython_3
     fpylll
     gmpy2
     importlib-metadata
@@ -202,29 +202,13 @@ buildPythonPackage rec {
     mkdir -p "$SAGE_SHARE/sage/ext/notebook-ipython"
     mkdir -p "var/lib/sage/installed"
 
-    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 '/sage_conf/d' src/setup.cfg.m4
-    sed -i '/sage_conf/d' src/requirements.txt.m4
-
     # version lower bounds are useful, but upper bounds are a hassle because
     # Sage tests already catch any relevant API breakage.
     # according to the discussion at https://trac.sagemath.org/ticket/33520,
     # upper bounds will be less noisy starting from Sage 9.6.
-    sed -i 's/==0.5.1/>=0.5.1/' ../ptyprocess/install-requires.txt
-    sed -i 's/, <[^, ]*//' ../*/install-requires.txt
-
-    for infile in src/*.m4; do
-        if [ -f "$infile" ]; then
-            outfile="src/$(basename $infile .m4)"
-            m4 "$infile" > "$outfile"
-        fi
-    done
+    sed -i 's/, <[^, ]*//' build/pkgs/*/install-requires.txt
 
-    cd src
+    cd build/pkgs/sagelib/src
   '';
 
   postInstall = ''