2020-04-24 23:36:52 +00:00
|
|
|
{ stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchpatch
|
2024-01-25 14:12:00 +00:00
|
|
|
, fetchurl
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
# This file is responsible for fetching the sage source and adding necessary patches.
|
|
|
|
# It does not actually build anything, it just copies the patched sources to $out.
|
|
|
|
# This is done because multiple derivations rely on these sources and they should
|
|
|
|
# all get the same sources with the same patches applied.
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "10.3";
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "sage-src";
|
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sagemath";
|
|
|
|
repo = "sage";
|
|
|
|
rev = version;
|
2024-04-21 15:54:59 +00:00
|
|
|
hash = "sha256-OHtMv8t0RrP6R8XIREU+C1vpazeQLWa75wx9Mv6BN1U=";
|
2024-01-25 14:12:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# 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}
|
2024-04-21 15:54:59 +00:00
|
|
|
url = "mirror://sageupstream/configure/configure-ab1a517b64b02bf15bbcb8d7c2d4d643bd5eff9b.tar.gz";
|
|
|
|
hash = "sha256-pe9AxTM+gFSR4/eVfUzay+4bwjoubbYeDPc+avKjlaw=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# Patches needed because of particularities of nix or the way this is packaged.
|
|
|
|
# The goal is to upstream all of them and get rid of this list.
|
|
|
|
nixPatches = [
|
|
|
|
# Parallelize docubuild using subprocesses, fixing an isolation issue. See
|
|
|
|
# https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
|
|
|
|
./patches/sphinx-docbuild-subprocesses.patch
|
2023-05-24 13:37:59 +00:00
|
|
|
|
|
|
|
# After updating smypow to (https://github.com/sagemath/sage/issues/3360)
|
|
|
|
# we can now set the cache dir to be within the .sage directory. This is
|
|
|
|
# not strictly necessary, but keeps us from littering in the user's HOME.
|
|
|
|
./patches/sympow-cache.patch
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Since sage unfortunately does not release bugfix releases, packagers must
|
|
|
|
# fix those bugs themselves. This is for critical bugfixes, where "critical"
|
|
|
|
# == "causes (transient) doctest failures / somebody complained".
|
|
|
|
bugfixPatches = [
|
2023-05-24 13:37:59 +00:00
|
|
|
# Sage uses mixed integer programs (MIPs) to find edge disjoint
|
|
|
|
# spanning trees. For some reason, aarch64 glpk takes much longer
|
|
|
|
# than x86_64 glpk to solve such MIPs. Since the MIP formulation
|
|
|
|
# has "numerous problems" and will be replaced by a polynomial
|
|
|
|
# algorithm soon, disable this test for now.
|
|
|
|
# https://github.com/sagemath/sage/issues/34575
|
|
|
|
./patches/disable-slow-glpk-test.patch
|
2024-04-21 15:54:59 +00:00
|
|
|
|
|
|
|
# https://github.com/sagemath/sage/pull/37489, landed in 10.4.beta1
|
|
|
|
(fetchpatch {
|
|
|
|
name = "quaternionalgebra-random-failure.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/1c3f991b9d3c5778e409e5414c6cfcd456113f19.diff";
|
|
|
|
hash = "sha256-uCXchYx26DdxTjR1k2748KCEHPnekKS2fAM7SpyhNvM=";
|
|
|
|
})
|
2024-05-15 15:35:15 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
# compile libs/gap/element.pyx with -O1
|
|
|
|
# a more conservative version of https://github.com/sagemath/sage/pull/37951
|
|
|
|
./patches/gap-element-crash.patch
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
# Patches needed because of package updates. We could just pin the versions of
|
|
|
|
# dependencies, but that would lead to rebuilds, confusion and the burdons of
|
|
|
|
# maintaining multiple versions of dependencies. Instead we try to make sage
|
|
|
|
# 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.
|
2021-03-12 07:09:13 +00:00
|
|
|
packageUpgradePatches = [
|
2024-07-27 06:49:29 +00:00
|
|
|
# https://github.com/sagemath/sage/pull/37763, landed in 10.4.beta2
|
|
|
|
(fetchpatch {
|
|
|
|
name = "scipy-fault-tolerance.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/551139c09f26a5da96b1187c3f0dd17b8d80ef84.diff";
|
|
|
|
hash = "sha256-PR4przrZ3ieHaW2nSY7l7VhNfrUupu9yCIrXpeyoAgg=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# https://github.com/sagemath/sage/pull/37492, landed in 10.4.beta5
|
2024-02-07 01:22:34 +00:00
|
|
|
(fetchpatch {
|
2024-04-21 15:54:59 +00:00
|
|
|
name = "singular-4.3.2p14-upgrade.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/a0c56816b051e97da44ac0a4e4d4f6915cf7fa0f.diff";
|
|
|
|
sha256 = "sha256-WGMmPeBoj2LUC+2qxWuaJL89QUuGt6axGvxWkpM9LYg=";
|
2024-02-07 01:22:34 +00:00
|
|
|
})
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
# https://github.com/sagemath/sage/pull/37949, landed in 10.4.beta6
|
|
|
|
(fetchpatch {
|
|
|
|
name = "conway-polynomials-new-len.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/c9f5b45179e92ea0de1e0dbe0f47464010902851.diff";
|
|
|
|
hash = "sha256-DwN2UIX8dxfxjIiqVvMdGbIxJ7CR/Ag2XUmS5vUKFTs=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# https://github.com/sagemath/sage/pull/37967, landed in 10.4.beta6
|
|
|
|
(fetchpatch {
|
|
|
|
name = "conway-polynomials-ell-point.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/4e0bbaf90262a42f8ea14d5bcfed65f9d1787f54.diff";
|
|
|
|
hash = "sha256-9gXydi1A+n7+K8YpH0PB8l/OMexhgO2F5NccU0cK+ls=";
|
|
|
|
})
|
|
|
|
|
|
|
|
# https://github.com/sagemath/sage/pull/38100, landed in 10.4.beta8
|
|
|
|
(fetchpatch {
|
|
|
|
name = "sphinx-7.3-update.patch";
|
|
|
|
url = "https://github.com/sagemath/sage/commit/e1b22690db42885423be5049246eb71ff52bdfef.diff";
|
|
|
|
hash = "sha256-04KAyz8+0pJbRV8Ld0bNX1OoEx/35gIh3Nff+6n8QUU=";
|
|
|
|
})
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# do not create .orig backup files if patch applies with fuzz
|
|
|
|
patchFlags = [ "--no-backup-if-mismatch" "-p1" ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postPatch = ''
|
|
|
|
# Make sure sage can at least be imported without setting any environment
|
|
|
|
# variables. It won't be close to feature complete though.
|
|
|
|
sed -i \
|
2021-04-26 19:14:03 +00:00
|
|
|
"s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
|
2020-04-24 23:36:52 +00:00
|
|
|
src/sage/env.py
|
2024-01-25 14:12:00 +00:00
|
|
|
|
|
|
|
# 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
|
2020-12-25 13:55:36 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPhase = "# do nothing";
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
cp -r . "$out"
|
2024-01-25 14:12:00 +00:00
|
|
|
tar xkzf ${configure-src} -C "$out"
|
|
|
|
rm "$out/configure"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
}
|