···1diff --git a/src/sage/env.py b/src/sage/env.py
2-index 1ddfc7cfb9..45033d6328 100644
3--- a/src/sage/env.py
4+++ b/src/sage/env.py
5-@@ -203,97 +203,13 @@ var('ARB_LIBRARY', 'arb')
6- var('SAGE_BANNER', '')
7- var('SAGE_IMPORTALL', 'yes')
89-
10--def _get_shared_lib_filename(libname, *additional_libnames):
11- """
12- Return the full path to a shared library file installed in
13- ``$SAGE_LOCAL/lib`` or the directories associated with the
···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 the file does not exist.
29-
30- EXAMPLES::
31-
32- sage: import sys
33- sage: from fnmatch import fnmatch
34-- sage: from sage.env import _get_shared_lib_filename
35-- sage: lib_filename = _get_shared_lib_filename("Singular",
36-- ....: "singular-Singular")
37- sage: if sys.platform == 'cygwin':
38- ....: pattern = "*/cygSingular-*.dll"
39- ....: elif sys.platform == 'darwin':
40-- ....: pattern = "*/libSingular.dylib"
41- ....: else:
42-- ....: pattern = "*/lib*Singular.so"
43-- sage: fnmatch(lib_filename, pattern)
44- True
45-- sage: _get_shared_lib_filename("an_absurd_lib") is None
46- True
47- """
48-
49-- for libname in (libname,) + additional_libnames:
0050- if sys.platform == 'cygwin':
51-- # Later down we take the last matching DLL found, so search
52-- # SAGE_LOCAL second so that it takes precedence
53-- bindirs = [
54-- sysconfig.get_config_var('BINDIR'),
55-- os.path.join(SAGE_LOCAL, 'bin')
56- ]
57-- pats = ['cyg{}.dll'.format(libname), 'cyg{}-*.dll'.format(libname)]
58-- filenames = []
59-- for bindir in bindirs:
60-- for pat in pats:
61-- filenames += glob.glob(os.path.join(bindir, pat))
62--
63-- # Note: This is not very robust, since if there are multi DLL
64- # versions for the same library this just selects one more or less
65-- # at arbitrary. However, practically speaking, on Cygwin, there
66- # will only ever be one version
67-- if filenames:
68-- return filenames[-1]
69- else:
70- if sys.platform == 'darwin':
71- ext = 'dylib'
72- else:
73- ext = 'so'
74-
75-- libdirs = [
76-- os.path.join(SAGE_LOCAL, 'lib'),
77-- sysconfig.get_config_var('LIBDIR')
78-- ]
79-- multilib = sysconfig.get_config_var('MULTILIB')
80-- if multilib:
81-- libdirs.insert(1, os.path.join(libdirs[0], multilib))
82-
83-- for libdir in libdirs:
84-- basename = 'lib{}.{}'.format(libname, ext)
85-- filename = os.path.join(libdir, basename)
86-- if os.path.exists(filename):
87-- return filename
00000088-
89- # Just return None if no files were found
90- return None
91--
92-
93 # locate singular shared object
94 # On Debian it's libsingular-Singular so try that as well
95--SINGULAR_SO = _get_shared_lib_filename('Singular', 'singular-Singular')
96-+SINGULAR_SO = '/default'
97- var('SINGULAR_SO', SINGULAR_SO)
9899 # locate libgap shared object
100--GAP_SO= _get_shared_lib_filename('gap','')
101-+GAP_SO = '/default'
102- var('GAP_SO', GAP_SO)
103104 # post process
0
···1diff --git a/src/sage/env.py b/src/sage/env.py
2+index 2908f5d04f..81dfd75c0d 100644
3--- a/src/sage/env.py
4+++ b/src/sage/env.py
5+@@ -218,93 +218,12 @@ NTL_LIBDIR = var("NTL_LIBDIR")
6+ SAGE_BANNER = var("SAGE_BANNER", "")
7+ SAGE_IMPORTALL = var("SAGE_IMPORTALL", "yes")
89-
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
···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: import sys
33- sage: from fnmatch import fnmatch
34+- sage: from sage.env import _get_shared_lib_path
35+- sage: lib_filename = _get_shared_lib_path("Singular", "singular-Singular")
036- sage: if sys.platform == 'cygwin':
37- ....: pattern = "*/cygSingular-*.dll"
38- ....: elif sys.platform == 'darwin':
39+- ....: pattern = "*/libSingular-*.dylib"
40- ....: else:
41+- ....: pattern = "*/lib*Singular-*.so"
42+- sage: fnmatch(str(lib_filename), pattern)
43- True
44+- sage: _get_shared_lib_path("an_absurd_lib") is None
45- True
46- """
47-
48+- for libname in libnames:
49+- search_directories: List[Path] = []
50+- patterns: List[str] = []
51- if sys.platform == 'cygwin':
52+- # Later down we take the first matching DLL found, so search
53+- # SAGE_LOCAL first so that it takes precedence
54+- search_directories = [
55+- Path(SAGE_LOCAL) / 'bin',
56+- Path(sysconfig.get_config_var('BINDIR')),
57- ]
58+- # Note: The following is not very robust, since if there are multible
00000059- # versions for the same library this just selects one more or less
60+- # at arbitrary. However, practically speaking, on Cygwin, there
61- # will only ever be one version
62+- patterns = [f'cyg{libname}.dll', f'cyg{libname}-*.dll']
063- else:
64- if sys.platform == 'darwin':
65- ext = 'dylib'
66- else:
67- ext = 'so'
68-
69+- search_directories = [Path(SAGE_LOCAL) / 'lib']
70+- libdir = sysconfig.get_config_var('LIBDIR')
71+- if libdir is not None:
72+- libdir = Path(libdir)
73+- search_directories.append(libdir)
0074-
75+- multiarchlib = sysconfig.get_config_var('MULTIARCH')
76+- if multiarchlib is not None:
77+- search_directories.append(libdir / multiarchlib),
78+-
79+- patterns = [f'lib{libname}.{ext}']
80+-
81+- for directory in search_directories:
82+- for pattern in patterns:
83+- path = next(directory.glob(pattern), None)
84+- if path is not None:
85+- return str(path.resolve())
86-
87- # Just return None if no files were found
88- return None
089-
90 # locate singular shared object
91 # On Debian it's libsingular-Singular so try that as well
92+-SINGULAR_SO = var("SINGULAR_SO", _get_shared_lib_path("Singular", "singular-Singular"))
93++SINGULAR_SO = var("SINGULAR_SO", '/default')
09495 # locate libgap shared object
96+-GAP_SO = var("GAP_SO", _get_shared_lib_path("gap", ""))
97++GAP_SO = var("GAP_SO", '/default')
09899 # post process
100+ if ' ' in DOT_SAGE:
···24 );
25in
26stdenv.mkDerivation rec {
27- version = "9.2";
28 pname = "sage-src";
2930 src = fetchFromGitHub {
31 owner = "sagemath";
32 repo = "sage";
33 rev = version;
34- sha256 = "103j8d5x6szl9fxaz0dvdi4y47q1af9h9y5hmjh2xayi62qmp5ql";
35 };
3637 # Patches needed because of particularities of nix or the way this is packaged.
···53 # Parallelize docubuild using subprocesses, fixing an isolation issue. See
54 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
55 ./patches/sphinx-docbuild-subprocesses.patch
56-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- })
64 ];
6566 # Since sage unfortunately does not release bugfix releases, packagers must
···70 # To help debug the transient error in
71 # https://trac.sagemath.org/ticket/23087 when it next occurs.
72 ./patches/configurationpy-error-verbose.patch
73-74- # fix intermittent errors in Sage 9.2's psage.py (this patch is
75- # already included in Sage 9.3): https://trac.sagemath.org/ticket/30730
76- (fetchSageDiff {
77- base = "9.2.rc2";
78- name = "fix-psage-is-locked.patch";
79- rev = "75df605f216ddc7b6ca719be942d666b241520e9";
80- sha256 = "0g9pl1wbb3sgs26d3bvv70cpa77sfskylv4kd255y1794f1fgk4q";
81- })
82-83- # fix intermittent errors in sagespawn.pyx: https://trac.sagemath.org/ticket/31052
84- (fetchSageDiff {
85- base = "9.2";
86- name = "sagespawn-implicit-casting.patch";
87- rev = "2959ac792ebd6107fe87c9af1541083de5ba02d6";
88- sha256 = "sha256-bWIpEGir9Kawak5CJegBMNcHm/CqhWmdru+emeSsvO0=";
89- })
90-91- # fix intermittent errors in doctest/test.py: https://trac.sagemath.org/ticket/26912
92- (fetchSageDiff {
93- base = "9.3.beta8";
94- name = "set-cysignals-crash-ndebug.patch";
95- rev = "ca5257a5d0f32efc9f8f07e126020856270b1a18";
96- sha256 = "sha256-KViw63xE3O0eUiOYzoxNrr4NL+csql9GPJLDJCf/EZs=";
97- })
98 ];
99100 # Patches needed because of package updates. We could just pin the versions of
···111112 # ignore a deprecation warning for usage of `cmp` in the attrs library in the doctests
113 ./patches/ignore-cmp-deprecation.patch
114-115- # adapt sage's Image class to pillow 8.0.1 (https://trac.sagemath.org/ticket/30971)
116- (fetchSageDiff {
117- base = "9.3.beta2";
118- name = "pillow-8.0.1-update.patch";
119- rev = "f05f2d0aac9c4b5abe68105cee2cc7f2c8461847";
120- sha256 = "sha256-uY2UlgSd5hhOUUukB4Xc3Gjy0/e7p/qyq9jdvz10IOs=";
121- })
122-123- # don't use deprecated numpy type aliases (https://trac.sagemath.org/ticket/31364)
124- (fetchSageDiff {
125- base = "9.3.beta7";
126- name = "dont-use-deprecated-numpy-type-aliases.patch";
127- rev = "dfdef60515d4a4269e82d91280f76a7fdf10bf97";
128- sha256 = "sha256-77/3LkT5J7DQN8IPlGJKB6ZcJPaF7xwje06JNns+0AE=";
129- })
130-131- # fix test output with sympy 1.7 (https://trac.sagemath.org/ticket/30985)
132- ./patches/sympy-1.7-update.patch
133-134- # workaround until we use sage's fork of threejs, which contains a "version" file
135- ./patches/dont-grep-threejs-version-from-minified-js.patch
136-137- # updated eclib output has punctuation changes and tidier whitespace
138- ./patches/eclib-20210223-test-formatting.patch
139-140- # upgrade arb to 2.18.1 (https://trac.sagemath.org/ticket/28623)
141- (fetchSageDiff {
142- base = "9.3.beta3";
143- name = "arb-2.18.1-update.patch";
144- rev = "0c9c4ed35c2eaf34ae0d19387c07b7f460e4abce";
145- sha256 = "sha256-CjOJIsyyVCziAfvE6pWSihPO35IZMcY2/taXAsqhPLY=";
146- })
147-148- # giac 1.6.0-47 update (https://trac.sagemath.org/ticket/30537)
149- (fetchSageDiff {
150- base = "9.3.beta7";
151- name = "giac-1.6.0-47-update.patch";
152- rev = "f05720bf63dfaf33a4e3b6d3ed2c2c0ec46b5d31";
153- sha256 = "sha256-gDUq+84eXd5GxLBWUSI61GMJpBF2KX4LBVOt3mS1NF8=";
154- })
155-156- # Make gcd/lcm interact better with pari and gmpy2 (https://trac.sagemath.org/ticket/30849)
157- # needed for pari 2.13.1 update, which we will do in the future
158- (fetchSageDiff {
159- base = "9.3.beta0";
160- name = "make-gcd-lcm-interact-better-with-pari-and-gmpy2.patch";
161- rev = "75c1516f0abb9e6f8c335e38e4031f6ef674ed30";
162- sha256 = "sha256-RukkieIZcXNrju904H2oyGKdtpdE+9vNzvyjN2IBNg0=";
163- })
164-165- # cypari 2.1.2 update (https://trac.sagemath.org/ticket/31029)
166- (fetchSageDiff {
167- base = "9.3.beta3";
168- name = "cypari-2.1.2-update.patch";
169- rev = "b9aadfd08e81d74ca7c229bb80eb853b592887d0";
170- sha256 = "sha256-eKaMy7kpu+YKdL8bPStgocxBCTfc2Z/10RrGy2LENFw=";
171- })
172 ];
173174 patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
175176 postPatch = ''
177- # make sure shebangs etc are fixed, but sage-python23 still works
178- find . -type f -exec sed \
179- -e 's/sage-python23/python3/g' \
180- -i {} \;
181-182- echo '#!${runtimeShell}
183- python3 "$@"' > build/bin/sage-python23
184-185 # Make sure sage can at least be imported without setting any environment
186 # variables. It won't be close to feature complete though.
187 sed -i \
188- "s|var('SAGE_ROOT'.*|var('SAGE_ROOT', '$out')|" \
189 src/sage/env.py
190191- # Do not use sage-env-config (generated by ./configure).
192- # Instead variables are set manually.
193- echo '# do nothing' > src/bin/sage-env-config
194- '';
195-196- # Test src/doc/en/reference/spkg/conf.py will fail if
197- # src/doc/en/reference/spkg/index.rst is not generated. It is
198- # generated by src/doc/bootstrap, so I've copied the relevant part
199- # here. An alternative would be to create an empty
200- # src/doc/en/reference/spkg/index.rst file.
201- configurePhase = ''
202- OUTPUT_DIR="src/doc/en/reference/spkg"
203- mkdir -p "$OUTPUT_DIR"
204- OUTPUT_INDEX="$OUTPUT_DIR"/index.rst
205- cat > "$OUTPUT_INDEX" <<EOF
206207- External Packages
208- =================
209-210- .. toctree::
211- :maxdepth: 1
212-213- EOF
214- for PKG_SCRIPTS in build/pkgs/*; do
215- if [ -d "$PKG_SCRIPTS" ]; then
216- PKG_BASE=$(basename "$PKG_SCRIPTS")
217- if [ -f "$PKG_SCRIPTS"/SPKG.rst ]; then
218- # Instead of just copying, we may want to call
219- # a version of sage-spkg-info to format extra information.
220- cp "$PKG_SCRIPTS"/SPKG.rst "$OUTPUT_DIR"/$PKG_BASE.rst
221- echo >> "$OUTPUT_INDEX" " $PKG_BASE"
222- fi
223- fi
224- done
225- cat >> "$OUTPUT_INDEX" <<EOF
226- .. include:: ../footer.txt
227- EOF
228 '';
229230 buildPhase = "# do nothing";
···24 );
25in
26stdenv.mkDerivation rec {
27+ version = "9.3.rc4";
28 pname = "sage-src";
2930 src = fetchFromGitHub {
31 owner = "sagemath";
32 repo = "sage";
33 rev = version;
34+ sha256 = "sha256-LDY07By2j6JagkgT9zeDJ93+m2/oXXEnDRTDzmR8ftk=";
35 };
3637 # Patches needed because of particularities of nix or the way this is packaged.
···53 # Parallelize docubuild using subprocesses, fixing an isolation issue. See
54 # https://groups.google.com/forum/#!topic/sage-packaging/YGOm8tkADrE
55 ./patches/sphinx-docbuild-subprocesses.patch
0000000056 ];
5758 # Since sage unfortunately does not release bugfix releases, packagers must
···62 # To help debug the transient error in
63 # https://trac.sagemath.org/ticket/23087 when it next occurs.
64 ./patches/configurationpy-error-verbose.patch
000000000000000000000000065 ];
6667 # Patches needed because of package updates. We could just pin the versions of
···7879 # ignore a deprecation warning for usage of `cmp` in the attrs library in the doctests
80 ./patches/ignore-cmp-deprecation.patch
000000000000000000000000000000000000000000000000000000000081 ];
8283 patches = nixPatches ++ bugfixPatches ++ packageUpgradePatches;
8485 postPatch = ''
0000000086 # Make sure sage can at least be imported without setting any environment
87 # variables. It won't be close to feature complete though.
88 sed -i \
89+ "s|var(\"SAGE_ROOT\".*|var(\"SAGE_ROOT\", \"$out\")|" \
90 src/sage/env.py
9192+ # src/doc/en/reference/spkg/conf.py expects index.rst in its directory,
93+ # a list of external packages in the sage distribution (build/pkgs)
94+ # generated by the bootstrap script (which we don't run). this is not
95+ # relevant for other distributions, so remove it.
96+ rm src/doc/en/reference/spkg/conf.py
97+ sed -i "/spkg/d" src/doc/en/reference/index.rst
0000000009899+ # the bootstrap script also generates installation instructions for
100+ # arch, debian, fedora, cygwin and homebrew using data from build/pkgs.
101+ # we don't run the bootstrap script, so disable including the generated
102+ # files. docbuilding fails otherwise.
103+ sed -i "/literalinclude/d" src/doc/en/installation/source.rst
0000000000000000104 '';
105106 buildPhase = "# do nothing";
···1-{ stdenv, fetchurl, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
2, lib
3, fetchpatch
4, autoreconfHook
05, file
6, flint
7, ntl
8, cddlib
9-, enableFactory ? true
00000000010, enableGfanlib ? true
11}:
1213stdenv.mkDerivation rec {
14 pname = "singular";
15- version = "4.1.1p2";
00000001617- src = let
18- # singular sorts its tarballs in directories by base release (without patch version)
19- # for example 4.1.1p1 will be in the directory 4-1-1
20- baseVersion = builtins.head (lib.splitString "p" version);
21- urlVersion = builtins.replaceStrings [ "." ] [ "-" ] baseVersion;
22- in
23- fetchurl {
24- url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${urlVersion}/singular-${version}.tar.gz";
25- sha256 = "07x9kri8vl4galik7lr6pscq3c51n8570pyw64i7gbj0m706f7wf";
00000026 };
2700000000000000000000028 configureFlags = [
29 "--with-ntl=${ntl}"
30- ] ++ lib.optionals enableFactory [
31- "--enable-factory"
032 ] ++ lib.optionals enableGfanlib [
33 "--enable-gfanlib"
34 ];
3536- postUnpack = ''
00037 patchShebangs .
00038 '';
39-40- patches = [
41- # NTL error handler was introduced in the library part, preventing users of
42- # the library from implementing their own error handling
43- # https://www.singular.uni-kl.de/forum/viewtopic.php?t=2769
44- (fetchpatch {
45- name = "move_error_handler_out_of_libsingular.patch";
46- # rebased version of https://github.com/Singular/Sources/commit/502cf86d0bb2a96715be6764774b64a69c1ca34c.patch
47- url = "https://git.sagemath.org/sage.git/plain/build/pkgs/singular/patches/singular-ntl-error-handler.patch?h=50b9ae2fd233c30860e1cbb3e63a26f2cc10560a";
48- sha256 = "0vgh4m9zn1kjl0br68n04j4nmn5i1igfn28cph0chnwf7dvr9194";
49- })
50- ];
5152 # For reference (last checked on commit 75f460d):
53- # https://github.com/Singular/Sources/blob/spielwiese/doc/Building-Singular-from-source.md
54- # https://github.com/Singular/Sources/blob/spielwiese/doc/external-packages-dynamic-modules.md
55 buildInputs = [
56 # necessary
57 gmp
···60 readline
61 ntl
62 flint
0063 ] ++ lib.optionals enableGfanlib [
64 cddlib
65 ];
···68 perl
69 pkg-config
70 autoreconfHook
00000071 ];
7273 preAutoreconf = ''
···85 # do nothing
86 '';
870088 installPhase = ''
89 mkdir -p "$out"
90 cp -r Singular/LIB "$out/lib"
91 make install
92-000093 # Make sure patchelf picks up the right libraries
94 rm -rf libpolys factory resources omalloc Singular
95 '';
96000000000000097 # simple test to make sure singular starts and finds its libraries
98 doInstallCheck = true;
99 installCheckPhase = ''
0000100 "$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
101 if [ $? -ne 0 ]; then
102 echo >&2 "Error loading the freegb library in Singular."
103 exit 1
104 fi
0000000000000000105 '';
106107 enableParallelBuilding = true;
···110 description = "A CAS for polynomial computations";
111 maintainers = teams.sage.members;
112 # 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
0113 platforms = subtractLists platforms.i686 platforms.unix;
114 license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
115 homepage = "http://www.singular.uni-kl.de";
···1+{ stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config
2, lib
3, fetchpatch
4, autoreconfHook
5+, sharutils
6, file
7, flint
8, ntl
9, cddlib
10+, gfan
11+, lrcalc
12+, doxygen
13+, graphviz
14+# upstream generates docs with texinfo 4. later versions of texinfo
15+# use letters instead of numbers for post-appendix chapters, and we
16+# want it to match the upstream format because sage depends on it.
17+, texinfo4
18+, texlive
19+, enableDocs ? true
20, enableGfanlib ? true
21}:
2223stdenv.mkDerivation rec {
24 pname = "singular";
25+ version = "4.2.0p2";
26+27+ # since the tarball does not contain tests or documentation (and
28+ # there is no separate tests tarball for 4.2.0), we fetch from
29+ # GitHub.
30+ src = fetchFromGitHub {
31+ owner = "Singular";
32+ repo = "Singular";
3334+ # 4.2.0p2 is not tagged, but the tarball matches commit
35+ # 6f68939ddf612d96e3caaaaa8275f77613ac1da8. the commit below has
36+ # two extra fixes.
37+ rev = "3cda50c00a849455efa2502e56596955491a353a";
38+ sha256 = "sha256-OizPhGE6L2LTOrKfeDdDB6BSdvYkDVXvbbYjV14hnHM=";
39+40+ # if a release is tagged it will be in the format below.
41+ # rev = "Release${lib.replaceStrings ["."] ["-"] version}";
42+43+ # the repository's .gitattributes file contains the lines "/Tst/
44+ # export-ignore" and "/doc/ export-ignore" so some directories are
45+ # not included in the tarball downloaded by fetchzip. setting
46+ # fetchSubmodules works around this by using fetchgit instead of
47+ # fetchzip.
48+ fetchSubmodules = true;
49 };
5051+ patches = [
52+ # add aarch64 support to cpu-check.m4. copied from redhat.
53+ ./redhat-aarch64.patch
54+55+ # vspace causes hangs in modstd and other libraries on aarch64
56+ ./disable-vspace-on-aarch64.patch
57+58+ # the newest version of ax-prog-cc-for-build.m4 seems to trigger
59+ # linker errors. see
60+ # https://github.com/alsa-project/alsa-firmware/issues/3 for a
61+ # related issue.
62+ ./use-older-ax-prog-cc-for-build.patch
63+ ] ++ lib.optionals enableDocs [
64+ # singular supports building without 4ti2, bertini, normaliz or
65+ # topcom just fine, but the docbuilding does not skip manual pages
66+ # tagged as depending on those binaries (probably a bug in
67+ # doc2tex.pl::HandleLib, since it seems to ignore "-exclude"
68+ # argumens). skip them manually.
69+ ./disable-docs-for-optional-unpackaged-deps.patch
70+ ];
71+72 configureFlags = [
73 "--with-ntl=${ntl}"
74+ "--disable-pyobject-module"
75+ ] ++ lib.optionals enableDocs [
76+ "--enable-doc-build"
77 ] ++ lib.optionals enableGfanlib [
78 "--enable-gfanlib"
79 ];
8081+ prePatch = ''
82+ # don't let the tests depend on `hostname`
83+ substituteInPlace Tst/regress.cmd --replace 'mysystem_catch("hostname")' 'nix_test_runner'
84+85 patchShebangs .
86+ '' + lib.optionalString enableDocs ''
87+ # work around encoding problem
88+ sed -i -e 's/\xb7/@cdot{}/g' doc/decodegb.doc
89 '';
0000000000009091 # For reference (last checked on commit 75f460d):
92+ # https://github.com/Singular/Singular/blob/spielwiese/doc/Building-Singular-from-source.md
93+ # https://github.com/Singular/Singular/blob/spielwiese/doc/external-packages-dynamic-modules.md
94 buildInputs = [
95 # necessary
96 gmp
···99 readline
100 ntl
101 flint
102+ lrcalc
103+ gfan
104 ] ++ lib.optionals enableGfanlib [
105 cddlib
106 ];
···109 perl
110 pkg-config
111 autoreconfHook
112+ sharutils # needed for regress.cmd install checks
113+ ] ++ lib.optionals enableDocs [
114+ doxygen
115+ graphviz
116+ texinfo4
117+ texlive.combined.scheme-small
118 ];
119120 preAutoreconf = ''
···132 # do nothing
133 '';
134135+ doCheck = true; # very basic checks, does not test any libraries
136+137 installPhase = ''
138 mkdir -p "$out"
139 cp -r Singular/LIB "$out/lib"
140 make install
141+ '' + lib.optionalString enableDocs ''
142+ # Sage uses singular.hlp (which is not in the tarball)
143+ mkdir -p $out/share/info
144+ cp doc/singular.hlp $out/share/info
145+ '' + ''
146 # Make sure patchelf picks up the right libraries
147 rm -rf libpolys factory resources omalloc Singular
148 '';
149150+ # singular tests are a bit complicated, see
151+ # https://github.com/Singular/Singular/tree/spielwiese/Tst
152+ # https://www.singular.uni-kl.de/forum/viewtopic.php&t=2773
153+ testsToRun = [
154+ "Old/universal.lst"
155+ "Buch/buch.lst"
156+ "Plural/short.lst"
157+ "Old/factor.tst"
158+ ] ++ lib.optionals enableGfanlib [
159+ # tests that require gfanlib
160+ "Short/ok_s.lst"
161+ ];
162+163 # simple test to make sure singular starts and finds its libraries
164 doInstallCheck = true;
165 installCheckPhase = ''
166+ # Very basic sanity check to make sure singular starts and finds its libraries.
167+ # This is redundant with the below tests. It is only kept because the singular test
168+ # runner is a bit complicated. In case we decide to give up those tests in the future,
169+ # this will still be useful. It takes barely any time.
170 "$out/bin/Singular" -c 'LIB "freegb.lib"; exit;'
171 if [ $? -ne 0 ]; then
172 echo >&2 "Error loading the freegb library in Singular."
173 exit 1
174 fi
175+176+ # Run the test suite
177+ cd Tst
178+ perl ./regress.cmd \
179+ -s "$out/bin/Singular" \
180+ ${lib.concatStringsSep " " (map lib.escapeShellArg testsToRun)} \
181+ 2>"$TMPDIR/out-err.log"
182+183+ # unfortunately regress.cmd always returns exit code 0, so check stderr
184+ # https://www.singular.uni-kl.de/forum/viewtopic.php&t=2773
185+ if [[ -s "$TMPDIR/out-err.log" ]]; then
186+ cat "$TMPDIR/out-err.log"
187+ exit 1
188+ fi
189+190+ echo "Exit status $?"
191 '';
192193 enableParallelBuilding = true;
···196 description = "A CAS for polynomial computations";
197 maintainers = teams.sage.members;
198 # 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'`
199+ # https://www.singular.uni-kl.de:8002/trac/ticket/837
200 platforms = subtractLists platforms.i686 platforms.unix;
201 license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4
202 homepage = "http://www.singular.uni-kl.de";
···1+diff --git a/m4/cpu-check.m4 b/m4/cpu-check.m4
2+index 3cf0a7f08..12bb926ac 100644
3+--- a/m4/cpu-check.m4
4++++ b/m4/cpu-check.m4
5+@@ -37,6 +37,18 @@ if test "$ac_cv_singcpuname" = ppc; then
6+ AC_DEFINE(SI_CPU_PPC,1,"PPC")
7+ AC_SUBST(SI_CPU_PPC)
8+ fi
9++if test "$ac_cv_singcpuname" = arm -o "$ac_cv_singcpuname" = armel; then
10++ AC_DEFINE(SI_CPU_ARM,1,"ARM")
11++ AC_SUBST(SI_CPU_ARM)
12++fi
13++if test "$ac_cv_singcpuname" = aarch64; then
14++ AC_DEFINE(SI_CPU_AARCH64,1,"AARCH64")
15++ AC_SUBST(SI_CPU_AARCH64)
16++fi
17++if test "$ac_cv_singcpuname" = s390; then
18++ AC_DEFINE(SI_CPU_S390,1,"S390")
19++ AC_SUBST(SI_CPU_S390)
20++fi
21+22+ # UNAME and PATH
23+ AC_MSG_CHECKING(uname for Singular)
24+@@ -65,6 +77,14 @@ dnl testet on: ppc_Linux, 740/750 PowerMac G3, 512k L2 cache
25+ [powerpc*|ppc*], [AC_DEFINE(HAVE_GENERIC_MULT,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)],
26+ dnl the following settings seems to be better on arm processors
27+ [arm*], [],
28++dnl FIXME: need to run some tests
29++ [aarch64*], [
30++ AC_DEFINE(HAVE_MULT_MOD,1,multiplication is fast on the cpu: a*b is with mod otherwise using tables of logartihms)
31++ AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)
32++ AC_DEFINE(HAVE_DIV_MOD,1,division using extend euclidian algorithm otherwise using tables of logartihms)
33++ ],
34++dnl FIXME: need to run some tests
35++ [s390*], [AC_DEFINE(HAVE_GENERIC_ADD,1,use branch for addition in Z/p otherwise it uses a generic add)],
36+ []
37+ )
38+