sage: use fetchSageDiff whenever possible

wip/yesman
Mauricio Collares 3 years ago
parent 5e74f259f3
commit a0f55e48fa
  1. 39
      pkgs/applications/science/math/sage/patches/pillow-update.patch
  2. 36
      pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch
  3. 13
      pkgs/applications/science/math/sage/patches/sagespawn-implicit-casting.patch
  4. 66
      pkgs/applications/science/math/sage/sage-src.nix

@ -1,39 +0,0 @@
diff --git a/src/sage/repl/image.py b/src/sage/repl/image.py
index d7d00b0..cd1607a 100644
--- a/src/sage/repl/image.py
+++ b/src/sage/repl/image.py
@@ -77,7 +77,7 @@ class Image(SageObject):
- ``size`` -- 2-tuple, containing (width, height) in pixels.
- - ``color`` -- string or tuple of numeric. What colour to use
+ - ``color`` -- string, numeric or tuple of numeric. What colour to use
for the image. Default is black. If given, this should be a
a tuple with one value per band. When creating RGB images,
you can also use colour strings as supported by the
@@ -91,9 +91,15 @@ class Image(SageObject):
EXAMPLES::
sage: from sage.repl.image import Image
- sage: Image('P', (16, 16), (13,))
+ sage: Image('P', (16, 16), 13)
16x16px 8-bit Color image
"""
+ # pillow does not support Sage integers as color
+ from sage.rings.integer import Integer
+ if isinstance(color, Integer):
+ color = int(color)
+ elif isinstance(color, tuple):
+ color = tuple(int(i) if isinstance(i, Integer) else i for i in color)
self._pil = PIL.Image.new(mode, size, color)
@property
@@ -233,7 +239,7 @@ class Image(SageObject):
EXAMPLES::
sage: from sage.repl.image import Image
- sage: img = Image('P', (12, 34), (13,))
+ sage: img = Image('P', (12, 34), 13)
sage: filename = tmp_filename(ext='.png')
sage: img.save(filename)
sage: with open(filename, 'rb') as f:

@ -1,36 +0,0 @@
diff --git a/src/sage/doctest/forker.py b/src/sage/doctest/forker.py
index cb3667659e..867f547d71 100644
--- a/src/sage/doctest/forker.py
+++ b/src/sage/doctest/forker.py
@@ -200,6 +200,15 @@ def init_sage(controller=None):
from sage.cpython._py2_random import Random
sage.misc.randstate.DEFAULT_PYTHON_RANDOM = Random
+ # IPython's pretty printer sorts the repr of dicts by their keys by default
+ # (or their keys' str() if they are not otherwise orderable). However, it
+ # disables this for CPython 3.6+ opting to instead display dicts' "natural"
+ # insertion order, which is preserved in those versions).
+ # However, this order is random in some instances.
+ # Also modifications of code may affect the order.
+ # So here we fore sorted dict printing.
+ IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}'))
+
if controller is None:
import sage.repl.ipython_kernel.all_jupyter
else:
@@ -222,15 +231,6 @@ def init_sage(controller=None):
from sage.repl.rich_output.backend_doctest import BackendDoctest
dm.switch_backend(BackendDoctest())
- # IPython's pretty printer sorts the repr of dicts by their keys by default
- # (or their keys' str() if they are not otherwise orderable). However, it
- # disables this for CPython 3.6+ opting to instead display dicts' "natural"
- # insertion order, which is preserved in those versions).
- # However, this order is random in some instances.
- # Also modifications of code may affect the order.
- # So here we fore sorted dict printing.
- IPython.lib.pretty.for_type(dict, _sorted_dict_pprinter_factory('{', '}'))
-
# Switch on extra debugging
from sage.structure.debug_options import debug
debug.refine_category_hash_check = True

@ -1,13 +0,0 @@
diff --git a/src/sage/interfaces/sagespawn.pyx b/src/sage/interfaces/sagespawn.pyx
index 9041238f1d..469befbc66 100644
--- a/src/sage/interfaces/sagespawn.pyx
+++ b/src/sage/interfaces/sagespawn.pyx
@@ -228,7 +228,7 @@ class SagePtyProcess(PtyProcess):
Check that the process eventually dies after calling
``terminate_async``::
- sage: s.ptyproc.terminate_async(interval=0.2)
+ sage: s.ptyproc.terminate_async(interval=float(0.2))
sage: while True:
....: try:
....: os.kill(s.pid, 0)

@ -9,6 +9,20 @@
# This is done because multiple derivations rely on these sources and they should
# all get the same sources with the same patches applied.
let
# Fetch a diff between `base` and `rev` on sage's git server.
# Used to fetch trac tickets by setting the `base` to the last release and the
# `rev` to the last commit of the ticket.
fetchSageDiff = { base, name, rev, sha256, ...}@args: (
fetchpatch ({
inherit name sha256;
url = "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}";
# We don't care about sage's own build system (which builds all its dependencies).
# Exclude build system changes to avoid conflicts.
excludes = [ "build/*" ];
} // builtins.removeAttrs args [ "rev" "base" "sha256" ])
);
in
stdenv.mkDerivation rec {
version = "9.2";
pname = "sage-src";
@ -40,17 +54,13 @@ stdenv.mkDerivation rec {
# https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
./patches/sphinx-docbuild-subprocesses.patch
# Sage's workaround to pretty print dicts (in
# src/sage/doctest/forker.py:init_sage) runs too late (after
# controller.load_environment(), which imports sage.all.*) to to
# affect sage.sandpiles.Sandpile{Config,Divisor}'s pretty printer.
# Due to the sandpiles module being lazily loaded, this only
# affects the first run (subsequent runs read from an import cache
# at ~/.sage/cache and are not affected), which is probably why
# other distributions don't hit this bug. This breaks two sandpile
# tests, so do the workaround a little bit earlier.
# https://trac.sagemath.org/ticket/31053
./patches/register-pretty-printer-earlier.patch
# Register sorted dict pprinter earlier (https://trac.sagemath.org/ticket/31053)
(fetchSageDiff {
base = "9.3.beta4";
name = "register-pretty-printer-earlier.patch";
rev = "d658230ce06ca19f4a3b3a4576297ee82f2d2151";
sha256 = "sha256-9mPUV7K5PoLDH2vVaYaOfvDLDpmxU0Aj7m/eaXYotDs=";
})
];
# Since sage unfortunately does not release bugfix releases, packagers must
@ -63,14 +73,20 @@ stdenv.mkDerivation rec {
# fix intermittent errors in Sage 9.2's psage.py (this patch is
# already included in Sage 9.3): https://trac.sagemath.org/ticket/30730
(fetchpatch {
(fetchSageDiff {
base = "9.2.rc2";
name = "fix-psage-is-locked.patch";
url = "https://git.sagemath.org/sage.git/patch/?id=75df605f216ddc7b6ca719be942d666b241520e9";
rev = "75df605f216ddc7b6ca719be942d666b241520e9";
sha256 = "0g9pl1wbb3sgs26d3bvv70cpa77sfskylv4kd255y1794f1fgk4q";
})
# fix intermittent errors in sagespawn.pyx: https://trac.sagemath.org/ticket/31052
./patches/sagespawn-implicit-casting.patch
(fetchSageDiff {
base = "9.2";
name = "sagespawn-implicit-casting.patch";
rev = "2959ac792ebd6107fe87c9af1541083de5ba02d6";
sha256 = "sha256-bWIpEGir9Kawak5CJegBMNcHm/CqhWmdru+emeSsvO0=";
})
# disable pexpect interrupt test (see https://trac.sagemath.org/ticket/30945)
./patches/disable-pexpect-intermittent-failure.patch
@ -82,20 +98,7 @@ stdenv.mkDerivation rec {
# compatible with never dependency versions when possible. All these changes
# should come from or be proposed to upstream. This list will probably never
# be empty since dependencies update all the time.
packageUpgradePatches = let
# Fetch a diff between `base` and `rev` on sage's git server.
# Used to fetch trac tickets by setting the `base` to the last release and the
# `rev` to the last commit of the ticket.
fetchSageDiff = { base, rev, name ? "sage-diff-${base}-${rev}.patch", ...}@args: (
fetchpatch ({
inherit name;
url = "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}";
# We don't care about sage's own build system (which builds all its dependencies).
# Exclude build system changes to avoid conflicts.
excludes = [ "build/*" ];
} // builtins.removeAttrs args [ "rev" "base" ])
);
in [
packageUpgradePatches = [
# 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.
@ -105,7 +108,12 @@ stdenv.mkDerivation rec {
./patches/ignore-cmp-deprecation.patch
# adapt sage's Image class to pillow 8.0.1 (https://trac.sagemath.org/ticket/30971)
./patches/pillow-update.patch
(fetchSageDiff {
base = "9.3.beta2";
name = "pillow-8.0.1-update.patch";
rev = "f05f2d0aac9c4b5abe68105cee2cc7f2c8461847";
sha256 = "sha256-uY2UlgSd5hhOUUukB4Xc3Gjy0/e7p/qyq9jdvz10IOs=";
})
# fix test output with sympy 1.7 (https://trac.sagemath.org/ticket/30985)
./patches/sympy-1.7-update.patch

Loading…
Cancel
Save