git.iko.soy/typeable/nixpkgs
on master help sign in
sage: use fetchSageDiff whenever possible
commita0f55e48fa0ecac41afeb61593d3a12041d7cd8a authorMauricio Collares <mauricio@collares.org> dateTue 2 Mar 2021, 17:45 (6 years ago) parent5e74f25
4 files changed+37−117
pkgs/applications/science/math/sage/patches/pillow-update.patch−39 pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patch−36 pkgs/applications/science/math/sage/patches/sagespawn-implicit-casting.patch−13 pkgs/applications/science/math/sage/sage-src.nix+37−29
pkgs/applications/science/math/sage/patches/pillow-update.patchdeleted−39
@@ -1,39 +0,0 @@
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:
pkgs/applications/science/math/sage/patches/register-pretty-printer-earlier.patchdeleted−36
@@ -1,36 +0,0 @@
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
pkgs/applications/science/math/sage/patches/sagespawn-implicit-casting.patchdeleted−13
@@ -1,13 +0,0 @@
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)
pkgs/applications/science/math/sage/sage-src.nix+37−29
@@ -9,6 +9,20 @@
99# This is done because multiple derivations rely on these sources and they should
1010# all get the same sources with the same patches applied.
1111
12+let
13+ # Fetch a diff between `base` and `rev` on sage's git server.
14+ # Used to fetch trac tickets by setting the `base` to the last release and the
15+ # `rev` to the last commit of the ticket.
16+ fetchSageDiff = { base, name, rev, sha256, ...}@args: (
17+ fetchpatch ({
18+ inherit name sha256;
19+ url = "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}";
20+ # We don't care about sage's own build system (which builds all its dependencies).
21+ # Exclude build system changes to avoid conflicts.
22+ excludes = [ "build/*" ];
23+ } // builtins.removeAttrs args [ "rev" "base" "sha256" ])
24+ );
25+in
1226stdenv.mkDerivation rec {
1327 version = "9.2";
1428 pname = "sage-src";
@@ -40,17 +54,13 @@ stdenv.mkDerivation rec {
4054 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
4155 ./patches/sphinx-docbuild-subprocesses.patch
4256
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
57+ # Register sorted dict pprinter earlier (https://trac.sagemath.org/ticket/31053)
58+ (fetchSageDiff {
59+ base = "9.3.beta4";
60+ name = "register-pretty-printer-earlier.patch";
61+ rev = "d658230ce06ca19f4a3b3a4576297ee82f2d2151";
62+ sha256 = "sha256-9mPUV7K5PoLDH2vVaYaOfvDLDpmxU0Aj7m/eaXYotDs=";
63+ })
5464 ];
5565
5666 # Since sage unfortunately does not release bugfix releases, packagers must
@@ -63,14 +73,20 @@ stdenv.mkDerivation rec {
6373
6474 # fix intermittent errors in Sage 9.2's psage.py (this patch is
6575 # already included in Sage 9.3): https://trac.sagemath.org/ticket/30730
66− (fetchpatch {
76+ (fetchSageDiff {
77+ base = "9.2.rc2";
6778 name = "fix-psage-is-locked.patch";
68− url = "https://git.sagemath.org/sage.git/patch/?id=75df605f216ddc7b6ca719be942d666b241520e9";
79+ rev = "75df605f216ddc7b6ca719be942d666b241520e9";
6980 sha256 = "0g9pl1wbb3sgs26d3bvv70cpa77sfskylv4kd255y1794f1fgk4q";
7081 })
7182
7283 # fix intermittent errors in sagespawn.pyx: https://trac.sagemath.org/ticket/31052
73− ./patches/sagespawn-implicit-casting.patch
84+ (fetchSageDiff {
85+ base = "9.2";
86+ name = "sagespawn-implicit-casting.patch";
87+ rev = "2959ac792ebd6107fe87c9af1541083de5ba02d6";
88+ sha256 = "sha256-bWIpEGir9Kawak5CJegBMNcHm/CqhWmdru+emeSsvO0=";
89+ })
7490
7591 # disable pexpect interrupt test (see https://trac.sagemath.org/ticket/30945)
7692 ./patches/disable-pexpect-intermittent-failure.patch
@@ -82,20 +98,7 @@ stdenv.mkDerivation rec {
8298 # compatible with never dependency versions when possible. All these changes
8399 # should come from or be proposed to upstream. This list will probably never
84100 # be empty since dependencies update all the time.
85− packageUpgradePatches = let
86− # Fetch a diff between `base` and `rev` on sage's git server.
87− # Used to fetch trac tickets by setting the `base` to the last release and the
88− # `rev` to the last commit of the ticket.
89− fetchSageDiff = { base, rev, name ? "sage-diff-${base}-${rev}.patch", ...}@args: (
90− fetchpatch ({
91− inherit name;
92− url = "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}";
93− # We don't care about sage's own build system (which builds all its dependencies).
94− # Exclude build system changes to avoid conflicts.
95− excludes = [ "build/*" ];
96− } // builtins.removeAttrs args [ "rev" "base" ])
97− );
98− in [
101+ packageUpgradePatches = [
99102 # After updating smypow to (https://trac.sagemath.org/ticket/3360) we can
100103 # now set the cache dir to be withing the .sage directory. This is not
101104 # strictly necessary, but keeps us from littering in the user's HOME.
@@ -105,7 +108,12 @@ stdenv.mkDerivation rec {
105108 ./patches/ignore-cmp-deprecation.patch
106109
107110 # adapt sage's Image class to pillow 8.0.1 (https://trac.sagemath.org/ticket/30971)
108− ./patches/pillow-update.patch
111+ (fetchSageDiff {
112+ base = "9.3.beta2";
113+ name = "pillow-8.0.1-update.patch";
114+ rev = "f05f2d0aac9c4b5abe68105cee2cc7f2c8461847";
115+ sha256 = "sha256-uY2UlgSd5hhOUUukB4Xc3Gjy0/e7p/qyq9jdvz10IOs=";
116+ })
109117
110118 # fix test output with sympy 1.7 (https://trac.sagemath.org/ticket/30985)
111119 ./patches/sympy-1.7-update.patch