···1-diff --git a/src/sage/env.py b/src/sage/env.py
2-index c4953cfa65..47b880f9ad 100644
3---- a/src/sage/env.py
4-+++ b/src/sage/env.py
5-@@ -244,81 +244,8 @@ os.environ['MPMATH_SAGE'] = '1'
6- SAGE_BANNER = var("SAGE_BANNER", "")
7- SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes")
8-9--
10--def _get_shared_lib_path(*libnames: str) -> Optional[str]:
11-- """
12-- Return the full path to a shared library file installed in
13-- ``$SAGE_LOCAL/lib`` or the directories associated with the
14-- Python sysconfig.
15--
16-- This can also be passed more than one library name (e.g. for cases where
17-- some library may have multiple names depending on the platform) in which
18-- case the first one found is returned.
19--
20-- This supports most *NIX variants (in which ``lib<libname>.so`` is found
21-- under ``$SAGE_LOCAL/lib``), macOS (same, but with the ``.dylib``
22-- extension), and Cygwin (under ``$SAGE_LOCAL/bin/cyg<libname>.dll``,
23-- or ``$SAGE_LOCAL/bin/cyg<libname>-*.dll`` for versioned DLLs).
24--
25-- For distributions like Debian that use a multiarch layout, we also try the
26-- multiarch lib paths (i.e. ``/usr/lib/<arch>/``).
27--
28-- This returns ``None`` if no matching library file could be found.
29--
30-- EXAMPLES::
31--
32-- sage: from sage.env import _get_shared_lib_path
33-- sage: "gap" in _get_shared_lib_path("gap")
34-- True
35-- sage: _get_shared_lib_path("an_absurd_lib") is None
36-- True
37--
38-- """
39--
40-- for libname in libnames:
41-- search_directories: List[Path] = []
42-- patterns: List[str] = []
43-- if sys.platform == 'cygwin':
44-- # Later down we take the first matching DLL found, so search
45-- # SAGE_LOCAL first so that it takes precedence
46-- if SAGE_LOCAL:
47-- search_directories.append(Path(SAGE_LOCAL) / 'bin')
48-- search_directories.append(Path(sysconfig.get_config_var('BINDIR')))
49-- # Note: The following is not very robust, since if there are multible
50-- # versions for the same library this just selects one more or less
51-- # at arbitrary. However, practically speaking, on Cygwin, there
52-- # will only ever be one version
53-- patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
54-- else:
55-- if sys.platform == 'darwin':
56-- ext = 'dylib'
57-- else:
58-- ext = 'so'
59--
60-- if SAGE_LOCAL:
61-- search_directories.append(Path(SAGE_LOCAL) / 'lib')
62-- libdir = sysconfig.get_config_var('LIBDIR')
63-- if libdir is not None:
64-- libdir = Path(libdir)
65-- search_directories.append(libdir)
66--
67-- multiarchlib = sysconfig.get_config_var('MULTIARCH')
68-- if multiarchlib is not None:
69-- search_directories.append(libdir / multiarchlib),
70--
71-- patterns = [f'lib{libname}.{ext}']
72--
73-- for directory in search_directories:
74-- for pattern in patterns:
75-- path = next(directory.glob(pattern), None)
76-- if path is not None:
77-- return str(path.resolve())
78--
79-- # Just return None if no files were found
80-- return None
81--
82- # locate libgap shared object
83--GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
84-+GAP_SO = var("GAP_SO", '/default')
85-86- # post process
87- if DOT_SAGE is not None and ' ' in DOT_SAGE:
···8# This is done because multiple derivations rely on these sources and they should
9# all get the same sources with the same patches applied.
1011-let
12- # Fetch a diff between `base` and `rev` on sage's git server.
13- # Used to fetch trac tickets by setting the `base` to the last release and the
14- # `rev` to the last commit of the ticket.
15- #
16- # We don't use sage's own build system (which builds all its
17- # dependencies), so we exclude changes to "build/" from patches by
18- # default to avoid conflicts.
19- fetchSageDiff = { base, name, rev, sha256, squashed ? false, excludes ? [ "build/*" ]
20- , ...}@args: (
21- fetchpatch ({
22- inherit name sha256 excludes;
23-24- # There are three places to get changes from:
25- #
26- # 1) From Sage's Trac. Contains all release tags (like "9.4") and all developer
27- # branches (wip patches from tickets), but exports each commit as a separate
28- # patch, so merge commits can lead to conflicts. Used if squashed == false.
29- #
30- # The above is the preferred option. To use it, find a Trac ticket and pass the
31- # "Commit" field from the ticket as "rev", choosing "base" as an appropriate
32- # release tag, i.e. a tag that doesn't cause the patch to include a lot of
33- # unrelated changes. If there is no such tag (due to nonlinear history, for
34- # example), there are two other options, listed below.
35- #
36- # 2) From GitHub's sagemath/sage repo. This lets us use a GH feature that allows
37- # us to choose between a .patch file, with one patch per commit, or a .diff file,
38- # which squashes all commits into a single diff. This is used if squashed ==
39- # true. This repo has all release tags. However, it has no developer branches, so
40- # this option can't be used if a change wasn't yet shipped in a (possibly beta)
41- # release.
42- #
43- # 3) From GitHub's sagemath/sagetrac-mirror repo. Mirrors all developer branches,
44- # but has no release tags. The only use case not covered by 1 or 2 is when we need
45- # to apply a patch from an open ticket that contains merge commits.
46- #
47- # Item 3 could cover all use cases if the sagemath/sagetrack-mirror repo had
48- # release tags, but it requires a sha instead of a release number in "base", which
49- # is inconvenient.
50- urls = if squashed
51- then [
52- "https://github.com/sagemath/sage/compare/${base}...${rev}.diff"
53- "https://github.com/sagemath/sagetrac-mirror/compare/${base}...${rev}.diff"
54- ]
55- else [ "https://git.sagemath.org/sage.git/patch?id2=${base}&id=${rev}" ];
56- } // builtins.removeAttrs args [ "rev" "base" "sha256" "squashed" "excludes" ])
57- );
58-in
59stdenv.mkDerivation rec {
60- version = "9.8";
61 pname = "sage-src";
6263 src = fetchFromGitHub {
64 owner = "sagemath";
65 repo = "sage";
66 rev = version;
67- sha256 = "sha256-dDbrzJXsOBARYfJz0r7n3LbaoXHnx7Acz6HBa95NV9o=";
68 };
6970 # Patches needed because of particularities of nix or the way this is packaged.
71 # The goal is to upstream all of them and get rid of this list.
72 nixPatches = [
73- # Fixes a potential race condition which can lead to transient doctest failures.
74- ./patches/fix-ecl-race.patch
75-76- # Not necessary since library location is set explicitly
77- # https://trac.sagemath.org/ticket/27660#ticket
78- ./patches/do-not-test-find-library.patch
79-80 # Parallelize docubuild using subprocesses, fixing an isolation issue. See
81 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
82 ./patches/sphinx-docbuild-subprocesses.patch
0000083 ];
8485 # Since sage unfortunately does not release bugfix releases, packagers must
86 # fix those bugs themselves. This is for critical bugfixes, where "critical"
87 # == "causes (transient) doctest failures / somebody complained".
88 bugfixPatches = [
89- # To help debug the transient error in
90- # https://trac.sagemath.org/ticket/23087 when it next occurs.
91- ./patches/configurationpy-error-verbose.patch
000092 ];
9394 # Patches needed because of package updates. We could just pin the versions of
···98 # should come from or be proposed to upstream. This list will probably never
99 # be empty since dependencies update all the time.
100 packageUpgradePatches = [
101- # After updating smypow to (https://trac.sagemath.org/ticket/3360) we can
102- # now set the cache dir to be within the .sage directory. This is not
103- # strictly necessary, but keeps us from littering in the user's HOME.
104- ./patches/sympow-cache.patch
105-106- # Upstream will wait until Sage 9.7 to upgrade to linbox 1.7 because it
107- # does not support gcc 6. We can upgrade earlier.
108- # https://trac.sagemath.org/ticket/32959
109- ./patches/linbox-1.7-upgrade.patch
110-111- # adapted from https://trac.sagemath.org/ticket/23712#comment:22
112- ./patches/tachyon-renamed-focallength.patch
113-114- # https://trac.sagemath.org/ticket/34391
115- (fetchSageDiff {
116- name = "gap-4.12-upgrade.patch";
117- base = "9.8.beta7";
118- rev = "dd4a17281adcda74e11f998ef519b6bd0dafb043";
119- sha256 = "sha256-UQT9DO9xd5hh5RucvUkIm+rggPKu8bc1YaSI6LVYH98=";
120- })
121-122- # https://trac.sagemath.org/ticket/34701
123- (fetchSageDiff {
124- name = "libgap-fix-gc-crashes-on-aarch64.patch";
125- base = "eb8cd42feb58963adba67599bf6e311e03424328"; # TODO: update when #34391 lands
126- rev = "90acc7f1c13a80b8aa673469a2668feb9cd4207f";
127- sha256 = "sha256-9BhQLFB3wUhiXRQsK9L+I62lSjvTfrqMNi7QUIQvH4U=";
128- })
129-130- # https://github.com/sagemath/sage/pull/35235
131 (fetchpatch {
132- name = "ipython-8.11-upgrade.patch";
133- url = "https://github.com/sagemath/sage/commit/23471e2d242c4de8789d7b1fc8b07a4b1d1e595a.diff";
134- sha256 = "sha256-wvH4BvDiaBv7jbOP8LvOE5Vs16Kcwz/C9jLpEMohzLQ=";
135 })
136137- # positively reviewed
138 (fetchpatch {
139- name = "matplotlib-3.7.0-upgrade.patch";
140- url = "https://github.com/sagemath/sage/pull/35177.diff";
141- sha256 = "sha256-YdPnMsjXBm9ZRm6a8hH8rSynkrABjLoIzqwp3F/rKAw=";
142 })
143144- # https://github.com/sagemath/sage/pull/35336, merged in 10.0.beta8
145 (fetchpatch {
146- name = "ipywidgets-8.0.5-upgrade.patch";
147- url = "https://github.com/sagemath/sage/commit/7ab3e3aa81d47a35d09161b965bba8ab16fd5c9e.diff";
148- sha256 = "sha256-WjdsPTui6uv92RerlV0mqltmLaxADvz+3aqSvxBFmfU=";
149 })
150151- # https://github.com/sagemath/sage/pull/35499
152 (fetchpatch {
153- name = "ipywidgets-8.0.5-upgrade-part-deux.patch";
154- url = "https://github.com/sagemath/sage/pull/35499.diff";
155- sha256 = "sha256-uNCjLs9qrARTQNsq1+kTdvuV2A1M4xx5b1gWh5c55X0=";
156 })
157-158- # rebased from https://github.com/sagemath/sage/pull/34994, merged in sage 10.0.beta2
159- ./patches/numpy-1.24-upgrade.patch
160-161- # Sage uses mixed integer programs (MIPs) to find edge disjoint
162- # spanning trees. For some reason, aarch64 glpk takes much longer
163- # than x86_64 glpk to solve such MIPs. Since the MIP formulation
164- # has "numerous problems" and will be replaced by a polynomial
165- # algorithm soon, disable this test for now.
166- # https://trac.sagemath.org/ticket/34575
167- ./patches/disable-slow-glpk-test.patch
168 ];
169170 patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
···179 "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
180 src/sage/env.py
181182- # src/doc/en/reference/spkg/conf.py expects index.rst in its directory,
183- # a list of external packages in the sage distribution (build/pkgs)
184- # generated by the bootstrap script (which we don't run). this is not
185- # relevant for other distributions, so remove it.
186- rm src/doc/en/reference/spkg/conf.py
187- sed -i "/spkg/d" src/doc/en/reference/index.rst
188189 # the bootstrap script also generates installation instructions for
190 # arch, debian, fedora, cygwin and homebrew using data from build/pkgs.
···8# This is done because multiple derivations rely on these sources and they should
9# all get the same sources with the same patches applied.
1000000000000000000000000000000000000000000000000011stdenv.mkDerivation rec {
12+ version = "10.0";
13 pname = "sage-src";
1415 src = fetchFromGitHub {
16 owner = "sagemath";
17 repo = "sage";
18 rev = version;
19+ sha256 = "sha256-zN/Lo/GBCjYGemuaYpgG3laufN8te3wPjXMQ+Me9zgY=";
20 };
2122 # Patches needed because of particularities of nix or the way this is packaged.
23 # The goal is to upstream all of them and get rid of this list.
24 nixPatches = [
000000025 # Parallelize docubuild using subprocesses, fixing an isolation issue. See
26 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
27 ./patches/sphinx-docbuild-subprocesses.patch
28+29+ # After updating smypow to (https://github.com/sagemath/sage/issues/3360)
30+ # we can now set the cache dir to be within the .sage directory. This is
31+ # not strictly necessary, but keeps us from littering in the user's HOME.
32+ ./patches/sympow-cache.patch
33 ];
3435 # Since sage unfortunately does not release bugfix releases, packagers must
36 # fix those bugs themselves. This is for critical bugfixes, where "critical"
37 # == "causes (transient) doctest failures / somebody complained".
38 bugfixPatches = [
39+ # Sage uses mixed integer programs (MIPs) to find edge disjoint
40+ # spanning trees. For some reason, aarch64 glpk takes much longer
41+ # than x86_64 glpk to solve such MIPs. Since the MIP formulation
42+ # has "numerous problems" and will be replaced by a polynomial
43+ # algorithm soon, disable this test for now.
44+ # https://github.com/sagemath/sage/issues/34575
45+ ./patches/disable-slow-glpk-test.patch
46 ];
4748 # Patches needed because of package updates. We could just pin the versions of
···52 # should come from or be proposed to upstream. This list will probably never
53 # be empty since dependencies update all the time.
54 packageUpgradePatches = [
55+ # https://github.com/sagemath/sage/pull/35584, positively reviewed
0000000000000000000000000000056 (fetchpatch {
57+ name = "networkx-3.1-upgrade.patch";
58+ url = "https://github.com/sagemath/sage/compare/10.0.rc2..e599562cf5fdfb9799a5412fac40c2f8e9f97341.diff";
59+ sha256 = "sha256-3A90kXqNR0c7+k8xrZXAt5wqWg/VFAPNhQujwTdOyhI=";
60 })
6162+ # https://github.com/sagemath/sage/pull/35612, positively reviewed
63 (fetchpatch {
64+ name = "linbox-1.7-upgrade.patch";
65+ url = "https://github.com/sagemath/sage/compare/10.0.rc2..9c8796c7b677e3a056348e3510331ea8b8c3c42e.diff";
66+ sha256 = "sha256-/TpvIQZUqmbUuz6wvp3ni9oRir5LBA2FKDJcmnHI1r4=";
67 })
6869+ # https://github.com/sagemath/sage/pull/35619
70 (fetchpatch {
71+ name = "maxima-5.46.0-upgrade.patch";
72+ url = "https://github.com/sagemath/sage/compare/10.0.rc3..7e86af5dae8f89868b25a6f57189bb5ca618da89.diff";
73+ sha256 = "sha256-pxSxdJ2lyHoMUIxhlIn1nTHaddRxGvvTj9IbwFCTBFU=";
74 })
7576+ # https://github.com/sagemath/sage/pull/35635, positively reviewed
77 (fetchpatch {
78+ name = "sympy-1.12-upgrade.patch";
79+ url = "https://github.com/sagemath/sage/compare/10.0.rc2..aa4193cdc8ec9fb7bd7c49696b7f914668f7913a.diff";
80+ sha256 = "sha256-UAmYCxHvnE5p+H2DySNZTPFVm915jHtOEoG+tZz5n7I=";
81 })
0000000000082 ];
8384 patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
···93 "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
94 src/sage/env.py
9596+ # docbuilding expects a spkg index generated by the doc/bootstrap script (which
97+ # we don't run) to exist. the spkg list includes nix package names, but it's not
98+ # worth the hassle of running the bootstrap script, so just create a dummy index.
99+ touch src/doc/en/reference/spkg/index.rst
00100101 # the bootstrap script also generates installation instructions for
102 # arch, debian, fedora, cygwin and homebrew using data from build/pkgs.