sage: 8.9 -> 9.2 fixups

+217 -36
+4
pkgs/applications/science/math/maxima/default.nix
··· 87 87 88 88 enableParallelBuilding = true; 89 89 90 + passthru = { 91 + ecl = ecl; 92 + }; 93 + 90 94 meta = { 91 95 description = "Computer algebra system"; 92 96 homepage = "http://maxima.sourceforge.net";
+26 -10
pkgs/applications/science/math/sage/default.nix
··· 9 9 let 10 10 inherit (pkgs) symlinkJoin callPackage nodePackages; 11 11 12 - python = pkgs.python3.override { 12 + python3 = pkgs.python3.override { 13 13 packageOverrides = self: super: { 14 14 # `sagelib`, i.e. all of sage except some wrappers and runtime dependencies 15 15 sagelib = self.callPackage ./sagelib.nix { 16 16 inherit flint arb; 17 17 inherit sage-src env-locations pynac singular; 18 + ecl = maxima-ecl.ecl; 18 19 linbox = pkgs.linbox.override { withSage = true; }; 19 20 pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig 20 21 }; ··· 42 43 env-locations = callPackage ./env-locations.nix { 43 44 inherit pari_data; 44 45 inherit singular maxima-ecl; 45 - cysignals = python.pkgs.cysignals; 46 + ecl = maxima-ecl.ecl; 47 + cysignals = python3.pkgs.cysignals; 46 48 three = nodePackages.three; 47 49 mathjax = nodePackages.mathjax; 48 50 }; ··· 50 52 # The shell file that gets sourced on every sage start. Will also source 51 53 # the env-locations file. 52 54 sage-env = callPackage ./sage-env.nix { 53 - sagelib = python.pkgs.sagelib; 55 + sagelib = python3.pkgs.sagelib; 54 56 inherit env-locations; 55 - inherit python singular palp flint pynac pythonEnv maxima-ecl; 57 + inherit python3 singular palp flint pynac pythonEnv maxima-ecl; 58 + ecl = maxima-ecl.ecl; 56 59 pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig 57 60 }; 58 61 59 62 # The documentation for sage, building it takes a lot of ram. 60 63 sagedoc = callPackage ./sagedoc.nix { 61 64 inherit sage-with-env; 62 - inherit python maxima-ecl; 65 + inherit python3 maxima-ecl; 63 66 }; 64 67 65 68 # sagelib with added wrappers and a dependency on sage-tests to make sure thet tests were run. 66 69 sage-with-env = callPackage ./sage-with-env.nix { 67 - inherit pythonEnv; 70 + inherit python3 pythonEnv; 68 71 inherit sage-env; 69 72 inherit pynac singular maxima-ecl; 70 73 pkg-config = pkgs.pkgconfig; # not to confuse with pythonPackages.pkgconfig ··· 81 84 82 85 sage-src = callPackage ./sage-src.nix {}; 83 86 84 - pythonRuntimeDeps = with python.pkgs; [ 87 + pythonRuntimeDeps = with python3.pkgs; [ 85 88 sagelib 86 89 cvxopt 87 90 networkx ··· 95 98 ipywidgets 96 99 rpy2 97 100 sphinx 98 - typing 99 101 pillow 100 102 ]; 101 103 102 - pythonEnv = python.buildEnv.override { 104 + pythonEnv = python3.buildEnv.override { 103 105 extraLibs = pythonRuntimeDeps; 104 106 ignoreCollisions = true; 105 107 } // { extraLibs = pythonRuntimeDeps; }; # make the libs accessible ··· 108 110 109 111 singular = pkgs.singular.override { inherit flint; }; 110 112 111 - maxima-ecl = pkgs.maxima-ecl; 113 + maxima-ecl = pkgs.maxima-ecl.override { 114 + ecl = pkgs.ecl.override { 115 + # "echo syntax error | ecl > /dev/full 2>&1" segfaults in 116 + # ECL. We apply a patch to fix it (write_error.patch), but it 117 + # only works if threads are disabled. sage 9.2 tests this 118 + # (src/sage/interfaces/tests.py) and ships ecl like so. 119 + # https://gitlab.com/embeddable-common-lisp/ecl/-/merge_requests/1#note_1657275 120 + threadSupport = false; 121 + 122 + # if we don't use the system boehmgc, sending a SIGINT to ecl 123 + # can segfault if we it happens during memory allocation. 124 + # src/sage/libs/ecl.pyx would intermittently fail in this case. 125 + useBoehmgc = true; 126 + }; 127 + }; 112 128 113 129 # *not* to confuse with the python package "pynac" 114 130 pynac = pkgs.pynac.override { inherit singular flint; };
+1 -1
pkgs/applications/science/math/sage/env-locations.nix
··· 44 44 export JSMOL_DIR="${jmol}/share/jsmol" 45 45 export MATHJAX_DIR="${mathjax}/lib/node_modules/mathjax" 46 46 export THREEJS_DIR="${three}/lib/node_modules/three" 47 - export SAGE_INCLUDE_DIRECTORIES="${cysignals}/lib/python2.7/site-packages" 47 + export SAGE_INCLUDE_DIRECTORIES="${cysignals}/${cysignals.pythonModule.sitePackages}" 48 48 ''; 49 49 }
+39
pkgs/applications/science/math/sage/patches/pillow-update.patch
··· 1 + diff --git a/src/sage/repl/image.py b/src/sage/repl/image.py 2 + index d7d00b0..cd1607a 100644 3 + --- a/src/sage/repl/image.py 4 + +++ b/src/sage/repl/image.py 5 + @@ -77,7 +77,7 @@ class Image(SageObject): 6 + 7 + - ``size`` -- 2-tuple, containing (width, height) in pixels. 8 + 9 + - - ``color`` -- string or tuple of numeric. What colour to use 10 + + - ``color`` -- string, numeric or tuple of numeric. What colour to use 11 + for the image. Default is black. If given, this should be a 12 + a tuple with one value per band. When creating RGB images, 13 + you can also use colour strings as supported by the 14 + @@ -91,9 +91,15 @@ class Image(SageObject): 15 + EXAMPLES:: 16 + 17 + sage: from sage.repl.image import Image 18 + - sage: Image('P', (16, 16), (13,)) 19 + + sage: Image('P', (16, 16), 13) 20 + 16x16px 8-bit Color image 21 + """ 22 + + # pillow does not support Sage integers as color 23 + + from sage.rings.integer import Integer 24 + + if isinstance(color, Integer): 25 + + color = int(color) 26 + + elif isinstance(color, tuple): 27 + + color = tuple(int(i) if isinstance(i, Integer) else i for i in color) 28 + self._pil = PIL.Image.new(mode, size, color) 29 + 30 + @property 31 + @@ -233,7 +239,7 @@ class Image(SageObject): 32 + EXAMPLES:: 33 + 34 + sage: from sage.repl.image import Image 35 + - sage: img = Image('P', (12, 34), (13,)) 36 + + sage: img = Image('P', (12, 34), 13) 37 + sage: filename = tmp_filename(ext='.png') 38 + sage: img.save(filename) 39 + sage: with open(filename, 'rb') as f:
+36
pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch
··· 1 + diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py 2 + index cb3667659e..867f547d71 100644 3 + --- a/src/sage/doctest/forker.py 4 + +++ b/src/sage/doctest/forker.py 5 + @@ -200,6 +200,15 @@ def init_sage(controller=None): 6 + from sage.cpython._py2_random import Random 7 + sage.misc.randstate.DEFAULT_PYTHON_RANDOM = Random 8 + 9 + + # IPython's pretty printer sorts the repr of dicts by their keys by default 10 + + # (or their keys' str() if they are not otherwise orderable). However, it 11 + + # disables this for CPython 3.6+ opting to instead display dicts' "natural" 12 + + # insertion order, which is preserved in those versions). 13 + + # However, this order is random in some instances. 14 + + # Also modifications of code may affect the order. 15 + + # So here we fore sorted dict printing. 16 + + IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}')) 17 + + 18 + if controller is None: 19 + import sage.repl.ipython_kernel.all_jupyter 20 + else: 21 + @@ -222,15 +231,6 @@ def init_sage(controller=None): 22 + from sage.repl.rich_output.backend_doctest import BackendDoctest 23 + dm.switch_backend(BackendDoctest()) 24 + 25 + - # IPython's pretty printer sorts the repr of dicts by their keys by default 26 + - # (or their keys' str() if they are not otherwise orderable). However, it 27 + - # disables this for CPython 3.6+ opting to instead display dicts' "natural" 28 + - # insertion order, which is preserved in those versions). 29 + - # However, this order is random in some instances. 30 + - # Also modifications of code may affect the order. 31 + - # So here we fore sorted dict printing. 32 + - IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}')) 33 + - 34 + # Switch on extra debugging 35 + from sage.structure.debug_options import debug 36 + debug.refine_category_hash_check = True
+13
pkgs/applications/science/math/sage/patches/sagespawn-implicit-casting.patch
··· 1 + diff --git a/src/sage/interfaces/sagespawn.pyx b/src/sage/interfaces/sagespawn.pyx 2 + index 9041238f1d..469befbc66 100644 3 + --- a/src/sage/interfaces/sagespawn.pyx 4 + +++ b/src/sage/interfaces/sagespawn.pyx 5 + @@ -228,7 +228,7 @@ class SagePtyProcess(PtyProcess): 6 + Check that the process eventually dies after calling 7 + ``terminate_async``:: 8 + 9 + - sage: s.ptyproc.terminate_async(interval=0.2) 10 + + sage: s.ptyproc.terminate_async(interval=float(0.2)) 11 + sage: while True: 12 + ....: try: 13 + ....: os.kill(s.pid, 0)
+1 -1
pkgs/applications/science/math/sage/patches/sphinx-docbuild-subprocesses.patch
··· 36 36 # Run Sphinx with Sage's special logger 37 37 - sys.argv = ["sphinx-build"] + build_command.split() 38 38 - from .sphinxbuild import runsphinx 39 - + args = "python -um sage_setup.docbuild.sphinxbuild -N".split() + build_command.split() 39 + + args = "python3 -um sage_setup.docbuild.sphinxbuild -N".split() + build_command.split() 40 40 try: 41 41 - runsphinx() 42 42 + subprocess.check_call(args)
+16 -9
pkgs/applications/science/math/sage/sage-env.nix
··· 1 1 { stdenv 2 2 , lib 3 3 , writeTextFile 4 - , python 5 4 , sagelib 6 5 , env-locations 7 6 , gfortran ··· 67 66 "@sage-local@" 68 67 "@sage-local@/build" 69 68 pythonEnv 70 - # empty python env to add python wrapper that clears PYTHONHOME (see 71 - # wrapper.nix). This is necessary because sage will call the python3 binary 72 - # (from python2 code). The python2 PYTHONHOME (again set in wrapper.nix) 73 - # will then confuse python3, if it is not overwritten. 74 - python3.buildEnv 75 69 gfortran # for inline fortran 76 70 stdenv.cc # for cython 77 71 bash ··· 129 123 ] 130 124 }' 131 125 export SAGE_ROOT='${sagelib.src}' 132 - export SAGE_LOCAL='@sage-local@' 126 + '' + 127 + # TODO: is using pythonEnv instead of @sage-local@ here a good 128 + # idea? there is a test in src/sage/env.py that checks if the values 129 + # SAGE_ROOT and SAGE_LOCAL set here match the ones set in env.py. 130 + # we fix up env.py's SAGE_ROOT in sage-src.nix (which does not 131 + # have access to sage-with-env), but env.py autodetects 132 + # SAGE_LOCAL to be pythonEnv. 133 + # setting SAGE_LOCAL to pythonEnv also avoids having to create 134 + # python3, ipython, ipython3 and jupyter symlinks in 135 + # sage-with-env.nix. 136 + '' 137 + export SAGE_LOCAL='${pythonEnv}' 138 + 133 139 export SAGE_SHARE='${sagelib}/share' 140 + export SAGE_ENV_CONFIG_SOURCED=1 # sage-env complains if sage-env-config is not sourced beforehand 134 141 orig_path="$PATH" 135 142 export PATH='${runtimepath}' 136 143 ··· 177 184 ]) 178 185 }' 179 186 180 - export SAGE_LIB='${sagelib}/${python.sitePackages}' 187 + export SAGE_LIB='${sagelib}/${python3.sitePackages}' 181 188 182 - export SAGE_EXTCODE='${sagelib.src}/src/ext' 189 + export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data' 183 190 184 191 # for find_library 185 192 export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
+62 -4
pkgs/applications/science/math/sage/sage-src.nix
··· 39 39 # Parallelize docubuild using subprocesses, fixing an isolation issue. See 40 40 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE 41 41 ./patches/sphinx-docbuild-subprocesses.patch 42 + 43 + # Sage's workaround to pretty print dicts (in 44 + # src/sage/doctest/forker.py:init_sage) runs too late (after 45 + # controller.load_environment(), which imports sage.all.*) to to 46 + # affect sage.sandpiles.Sandpile{Config,Divisor}'s pretty printer. 47 + # Due to the sandpiles module being lazily loaded, this only 48 + # affects the first run (subsequent runs read from an import cache 49 + # at ~/.sage/cache and are not affected), which is probably why 50 + # other distributions don't hit this bug. This breaks two sandpile 51 + # tests, so do the workaround a little bit earlier. 52 + # https://trac.sagemath.org/ticket/31053 53 + ./patches/register-pretty-printer-earlier.patch 42 54 ]; 43 55 44 56 # Since sage unfortunately does not release bugfix releases, packagers must ··· 48 60 # To help debug the transient error in 49 61 # https://trac.sagemath.org/ticket/23087 when it next occurs. 50 62 ./patches/configurationpy-error-verbose.patch 63 + 64 + # fix intermittent errors in Sage 9.2's psage.py (this patch is 65 + # already included in Sage 9.3): https://trac.sagemath.org/ticket/30730 66 + (fetchpatch { 67 + name = "fix-psage-is-locked.patch"; 68 + url = "https://git.sagemath.org/sage.git/patch/?id=75df605f216ddc7b6ca719be942d666b241520e9"; 69 + sha256 = "0g9pl1wbb3sgs26d3bvv70cpa77sfskylv4kd255y1794f1fgk4q"; 70 + }) 71 + 72 + # fix intermittent errors in sagespawn.pyx: https://trac.sagemath.org/ticket/31052 73 + ./patches/sagespawn-implicit-casting.patch 51 74 ]; 52 75 53 76 # Patches needed because of package updates. We could just pin the versions of ··· 77 100 78 101 # ignore a deprecation warning for usage of `cmp` in the attrs library in the doctests 79 102 ./patches/ignore-cmp-deprecation.patch 103 + 104 + # adapt sage's Image class to pillow 8.0.1 (https://trac.sagemath.org/ticket/30971) 105 + ./patches/pillow-update.patch 80 106 ]; 81 107 82 108 patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches; ··· 84 110 postPatch = '' 85 111 # make sure shebangs etc are fixed, but sage-python23 still works 86 112 find . -type f -exec sed \ 87 - -e 's/sage-python23/python/g' \ 113 + -e 's/sage-python23/python3/g' \ 88 114 -i {} \; 89 115 90 116 echo '#!${runtimeShell} 91 - python "$@"' > build/bin/sage-python23 117 + python3 "$@"' > build/bin/sage-python23 92 118 93 119 # Make sure sage can at least be imported without setting any environment 94 120 # variables. It won't be close to feature complete though. 95 121 sed -i \ 96 - "s|var('SAGE_LOCAL',.*|var('SAGE_LOCAL', '$out/src')|" \ 122 + "s|var('SAGE_ROOT'.*|var('SAGE_ROOT', '$out')|" \ 97 123 src/sage/env.py 98 124 99 125 # Do not use sage-env-config (generated by ./configure). ··· 101 127 echo '# do nothing' > src/bin/sage-env-config 102 128 ''; 103 129 104 - configurePhase = "# do nothing"; 130 + # Test src/doc/en/reference/spkg/conf.py will fail if 131 + # src/doc/en/reference/spkg/index.rst is not generated. It is 132 + # generated by src/doc/bootstrap, so I've copied the relevant part 133 + # here. An alternative would be to create an empty 134 + # src/doc/en/reference/spkg/index.rst file. 135 + configurePhase = '' 136 + OUTPUT_DIR="src/doc/en/reference/spkg" 137 + mkdir -p "$OUTPUT_DIR" 138 + OUTPUT_INDEX="$OUTPUT_DIR"/index.rst 139 + cat > "$OUTPUT_INDEX" <<EOF 140 + 141 + External Packages 142 + ================= 143 + 144 + .. toctree:: 145 + :maxdepth: 1 146 + 147 + EOF 148 + for PKG_SCRIPTS in build/pkgs/*; do 149 + if [ -d "$PKG_SCRIPTS" ]; then 150 + PKG_BASE=$(basename "$PKG_SCRIPTS") 151 + if [ -f "$PKG_SCRIPTS"/SPKG.rst ]; then 152 + # Instead of just copying, we may want to call 153 + # a version of sage-spkg-info to format extra information. 154 + cp "$PKG_SCRIPTS"/SPKG.rst "$OUTPUT_DIR"/$PKG_BASE.rst 155 + echo >> "$OUTPUT_INDEX" " $PKG_BASE" 156 + fi 157 + fi 158 + done 159 + cat >> "$OUTPUT_INDEX" <<EOF 160 + .. include:: ../footer.txt 161 + EOF 162 + ''; 105 163 106 164 buildPhase = "# do nothing"; 107 165
+2 -4
pkgs/applications/science/math/sage/sage-with-env.nix
··· 50 50 ]; 51 51 52 52 # remove python prefix, replace "-" in the name by "_", apply patch_names 53 - # python2.7-some-pkg-1.0 -> some_pkg-1.0 53 + # python3.8-some-pkg-1.0 -> some_pkg-1.0 54 54 pkg_to_spkg_name = pkg: patch_names: let 55 55 parts = lib.splitString "-" pkg.name; 56 - # remove python2.7- 56 + # remove python3.8- 57 57 stripped_parts = if (builtins.head parts) == python3.libPrefix then builtins.tail parts else parts; 58 58 version = lib.last stripped_parts; 59 59 orig_pkgname = lib.init stripped_parts; ··· 125 125 # the scripts in src/bin will find the actual sage source files using environment variables set in `sage-env` 126 126 cp -r src/bin "$out/bin" 127 127 cp -r build/bin "$out/build/bin" 128 - 129 - ln -s "${python3}/bin/python3" "$out/bin/python3" 130 128 131 129 cp -f '${sage-env}/sage-env' "$out/bin/sage-env" 132 130 substituteInPlace "$out/bin/sage-env" \
+17 -5
pkgs/applications/science/math/sage/sagedoc.nix
··· 1 1 { stdenv 2 2 , sage-with-env 3 - , python 3 + , python3 4 4 , maxima-ecl 5 5 , tachyon 6 6 , jmol ··· 17 17 # modules are imported and because matplotlib is used to produce plots. 18 18 buildInputs = [ 19 19 sage-with-env.env.lib 20 - python 20 + python3 21 21 maxima-ecl 22 22 tachyon 23 23 jmol 24 24 cddlib 25 - ] ++ (with python.pkgs; [ 25 + ] ++ (with python3.pkgs; [ 26 26 psutil 27 27 future 28 28 sphinx ··· 34 34 ipykernel 35 35 ipywidgets 36 36 jupyter_client 37 - typing 38 37 ]); 39 38 40 39 unpackPhase = '' ··· 45 44 chmod -R 755 "$SAGE_DOC_SRC_OVERRIDE" 46 45 ''; 47 46 47 + postPatch = '' 48 + # src/doc/bootstrap generates installation instructions for 49 + # arch, debian, fedora, cygwin and homebrew. as a hack, disable 50 + # including the generated files. 51 + sed -i "/literalinclude/d" $SAGE_DOC_SRC_OVERRIDE/en/installation/source.rst 52 + ''; 53 + 48 54 buildPhase = '' 49 55 export SAGE_NUM_THREADS="$NIX_BUILD_CORES" 50 56 export HOME="$TMPDIR/sage_home" 51 57 mkdir -p "$HOME" 52 58 53 59 # needed to link them in the sage docs using intersphinx 54 - export PPLPY_DOCS=${python.pkgs.pplpy.doc}/share/doc/pplpy 60 + export PPLPY_DOCS=${python3.pkgs.pplpy.doc}/share/doc/pplpy 61 + 62 + # adapted from src/doc/bootstrap 63 + OUTPUT_DIR="$SAGE_DOC_SRC_OVERRIDE/en/reference/repl" 64 + mkdir -p "$OUTPUT_DIR" 65 + OUTPUT="$OUTPUT_DIR/options.txt" 66 + ${sage-with-env}/bin/sage -advanced > "$OUTPUT" 55 67 56 68 ${sage-with-env}/bin/sage -python -m sage_setup.docbuild \ 57 69 --mathjax \
-2
pkgs/applications/science/math/sage/sagelib.nix
··· 53 53 , gmpy2 54 54 , pplpy 55 55 , sqlite 56 - , boehmgc # FIXME 57 56 }: 58 57 59 58 assert (!blas.isILP64) && (!lapack.isILP64); ··· 129 128 gmpy2 130 129 pplpy 131 130 sqlite 132 - boehmgc # FIXME 133 131 ]; 134 132 135 133 buildPhase = ''