From ceaf48fdb215b131a4c9deeafcdaaa1370238ea2 Mon Sep 17 00:00:00 2001 From: Timo Kaufmann Date: Fri, 3 Aug 2018 15:03:55 +0200 Subject: [PATCH] singular: 4.1.1p2 -> 4.2.0p2 Adds proper tests. Also removes the "enableFactory" option because singular actually enables factory by default and explicitly disabling it breaks the build. So the option was never really available. --- .../science/math/singular/default.nix | 139 ++++++++++++++---- ...le-docs-for-optional-unpackaged-deps.patch | 112 ++++++++++++++ 2 files changed, 219 insertions(+), 32 deletions(-) create mode 100644 pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch diff --git a/pkgs/applications/science/math/singular/default.nix b/pkgs/applications/science/math/singular/default.nix index fad05099a733..add89c95a0c1 100644 --- a/pkgs/applications/science/math/singular/default.nix +++ b/pkgs/applications/science/math/singular/default.nix @@ -1,57 +1,84 @@ -{ stdenv, fetchurl, gmp, bison, perl, ncurses, readline, coreutils, pkg-config +{ stdenv, fetchFromGitHub, gmp, bison, perl, ncurses, readline, coreutils, pkg-config , lib , fetchpatch -, autoreconfHook +, autoreconfHook269 +, sharutils , file , flint , ntl , cddlib -, enableFactory ? true +, gfan +, lrcalc +, doxygen +, graphviz +# upstream generates docs with texinfo 4. later versions of texinfo +# use letters instead of numbers for post-appendix chapters, and we +# want it to match the upstream format because sage depends on it. +, texinfo4 +, texlive +, enableDocs ? true , enableGfanlib ? true }: stdenv.mkDerivation rec { pname = "singular"; - version = "4.1.1p2"; + version = "4.2.0p2"; - src = let - # singular sorts its tarballs in directories by base release (without patch version) - # for example 4.1.1p1 will be in the directory 4-1-1 - baseVersion = builtins.head (lib.splitString "p" version); - urlVersion = builtins.replaceStrings [ "." ] [ "-" ] baseVersion; - in - fetchurl { - url = "http://www.mathematik.uni-kl.de/ftp/pub/Math/Singular/SOURCES/${urlVersion}/singular-${version}.tar.gz"; - sha256 = "07x9kri8vl4galik7lr6pscq3c51n8570pyw64i7gbj0m706f7wf"; + # since the tarball does not contain tests or documentation (and + # there is no separate tests tarball for 4.2.0), we fetch from + # GitHub. + src = fetchFromGitHub { + owner = "Singular"; + repo = "Singular"; + + # 4.2.0p2 is not tagged, but the tarball matches commit + # 6f68939ddf612d96e3caaaaa8275f77613ac1da8. the commit below has + # two extra fixes. + rev = "3cda50c00a849455efa2502e56596955491a353a"; + sha256 = "sha256-OizPhGE6L2LTOrKfeDdDB6BSdvYkDVXvbbYjV14hnHM="; + + # if a release is tagged it will be in the format below. + # rev = "Release${lib.replaceStrings ["."] ["-"] version}"; + + # the repository's .gitattributes file contains the lines "/Tst/ + # export-ignore" and "/doc/ export-ignore" so some directories are + # not included in the tarball downloaded by fetchzip. setting + # fetchSubmodules works around this by using fetchgit instead of + # fetchzip. + fetchSubmodules = true; }; + patches = lib.optionals enableDocs [ + # singular supports building without 4ti2, bertini, normaliz or + # topcom just fine, but the docbuilding does not skip manual pages + # tagged as depending on those binaries (probably a bug in + # doc2tex.pl::HandleLib, since it seems to ignore "-exclude" + # argumens). skip them manually. + ./disable-docs-for-optional-unpackaged-deps.patch + ]; + configureFlags = [ "--with-ntl=${ntl}" - ] ++ lib.optionals enableFactory [ - "--enable-factory" + "--disable-pyobject-module" + ] ++ lib.optionals enableDocs [ + "--enable-doc-build" ] ++ lib.optionals enableGfanlib [ "--enable-gfanlib" ]; - postUnpack = '' + prePatch = '' + # don't let the tests depend on `hostname` + substituteInPlace Tst/regress.cmd --replace 'mysystem_catch("hostname")' 'nix_test_runner' + patchShebangs . + '' + lib.optionalString enableDocs '' + # work around encoding problem + sed -i -e 's/\xb7/@cdot{}/g' doc/decodegb.doc ''; - patches = [ - # NTL error handler was introduced in the library part, preventing users of - # the library from implementing their own error handling - # https://www.singular.uni-kl.de/forum/viewtopic.php?t=2769 - (fetchpatch { - name = "move_error_handler_out_of_libsingular.patch"; - # rebased version of https://github.com/Singular/Sources/commit/502cf86d0bb2a96715be6764774b64a69c1ca34c.patch - url = "https://git.sagemath.org/sage.git/plain/build/pkgs/singular/patches/singular-ntl-error-handler.patch?h=50b9ae2fd233c30860e1cbb3e63a26f2cc10560a"; - sha256 = "0vgh4m9zn1kjl0br68n04j4nmn5i1igfn28cph0chnwf7dvr9194"; - }) - ]; - # For reference (last checked on commit 75f460d): - # https://github.com/Singular/Sources/blob/spielwiese/doc/Building-Singular-from-source.md - # https://github.com/Singular/Sources/blob/spielwiese/doc/external-packages-dynamic-modules.md + # https://github.com/Singular/Singular/blob/spielwiese/doc/Building-Singular-from-source.md + # https://github.com/Singular/Singular/blob/spielwiese/doc/external-packages-dynamic-modules.md buildInputs = [ # necessary gmp @@ -60,6 +87,8 @@ stdenv.mkDerivation rec { readline ntl flint + lrcalc + gfan ] ++ lib.optionals enableGfanlib [ cddlib ]; @@ -67,7 +96,13 @@ stdenv.mkDerivation rec { bison perl pkg-config - autoreconfHook + autoreconfHook269 + sharutils # needed for regress.cmd install checks + ] ++ lib.optionals enableDocs [ + doxygen + graphviz + texinfo4 + texlive.combined.scheme-small ]; preAutoreconf = '' @@ -85,23 +120,62 @@ stdenv.mkDerivation rec { # do nothing ''; + doCheck = true; # very basic checks, does not test any libraries + installPhase = '' mkdir -p "$out" cp -r Singular/LIB "$out/lib" make install - + '' + lib.optionalString enableDocs '' + # Sage uses singular.hlp (which is not in the tarball) + mkdir -p $out/share/info + cp doc/singular.hlp $out/share/info + '' + '' # Make sure patchelf picks up the right libraries rm -rf libpolys factory resources omalloc Singular ''; + # singular tests are a bit complicated, see + # https://github.com/Singular/Singular/tree/spielwiese/Tst + # https://www.singular.uni-kl.de/forum/viewtopic.php&t=2773 + testsToRun = [ + "Old/universal.lst" + "Buch/buch.lst" + "Plural/short.lst" + "Old/factor.tst" + ] ++ lib.optionals enableGfanlib [ + # tests that require gfanlib + "Short/ok_s.lst" + ]; + # simple test to make sure singular starts and finds its libraries doInstallCheck = true; installCheckPhase = '' + # Very basic sanity check to make sure singular starts and finds its libraries. + # This is redundant with the below tests. It is only kept because the singular test + # runner is a bit complicated. In case we decide to give up those tests in the future, + # this will still be useful. It takes barely any time. "$out/bin/Singular" -c 'LIB "freegb.lib"; exit;' if [ $? -ne 0 ]; then echo >&2 "Error loading the freegb library in Singular." exit 1 fi + + # Run the test suite + cd Tst + perl ./regress.cmd \ + -s "$out/bin/Singular" \ + ${lib.concatStringsSep " " (map lib.escapeShellArg testsToRun)} \ + 2>"$TMPDIR/out-err.log" + + # unfortunately regress.cmd always returns exit code 0, so check stderr + # https://www.singular.uni-kl.de/forum/viewtopic.php&t=2773 + if [[ -s "$TMPDIR/out-err.log" ]]; then + cat "$TMPDIR/out-err.log" + exit 1 + fi + + echo "Exit status $?" ''; enableParallelBuilding = true; @@ -110,6 +184,7 @@ stdenv.mkDerivation rec { description = "A CAS for polynomial computations"; maintainers = teams.sage.members; # 32 bit x86 fails with some link error: `undefined reference to `__divmoddi4@GCC_7.0.0'` + # https://www.singular.uni-kl.de:8002/trac/ticket/837 platforms = subtractLists platforms.i686 platforms.unix; license = licenses.gpl3; # Or GPLv2 at your option - but not GPLv4 homepage = "http://www.singular.uni-kl.de"; diff --git a/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch b/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch new file mode 100644 index 000000000000..46d92922f3ce --- /dev/null +++ b/pkgs/applications/science/math/singular/disable-docs-for-optional-unpackaged-deps.patch @@ -0,0 +1,112 @@ +commit 9e8b044d982e132cf35a106a1cc0cf7e77b27f7c +Author: Mauricio Collares +Date: Thu Apr 15 20:33:21 2021 -0300 + + Disable manual sections using optional packages not yet in Nixpkgs + + * normaliz.lib depends on normaliz. + * polymake.lib depends on topcom. + * recover.lib depends on bertini. + * sing4ti2.lib depends on 4ti2. + * tateProdCplxNegGrad.lib uses multigrading.lib, which depends on 4ti2. + +diff --git a/doc/singular.doc b/doc/singular.doc +index 64b969d39..e704f95f0 100644 +--- a/doc/singular.doc ++++ b/doc/singular.doc +@@ -407,7 +407,6 @@ LIB "all.lib"; + * nfmodsyz_lib:: Syzygy modules of submodules of free modules over algebraic number fields + * noether_lib:: Noether normalization of an ideal + * normal_lib:: procedure for normalization +-* normaliz_lib:: integral closure, normalization for monomial ideals, toric ideals + * pointid_lib:: factorized lex GB of the vanishing ideal of a set of points + * primdec_lib:: procedures for primary decomposition + * primdecint_lib:: primary decomposition over the integers +@@ -416,7 +415,6 @@ LIB "all.lib"; + * reesclos_lib:: Rees Algebra and integral closure of an ideal + * rstandard_lib:: Janet bases and border bases for ideals + * sagbi_lib:: Subalgebras bases Analogous to Groebner bases for ideals +-* sing4ti2_lib:: interface to program 4ti2 + * symodstd_lib:: Groebner bases for symmetric ideals + * toric_lib:: toric ideals + @end menu +@@ -521,10 +519,6 @@ LIB "all.lib"; + @node normal_lib + @subsection normal_lib + @c lib normal.lib +-@c --------------------------------------------------------- +-@node normaliz_lib +-@subsection normaliz_lib +-@c lib normaliz.lib tag:normaliz + @c ---------------------------------------------------------- + @node pointid_lib + @subsection pointid_lib +@@ -558,10 +552,6 @@ LIB "all.lib"; + @subsection sagbi_lib + @c lib sagbi.lib + @c --------------------------------------------------------- +-@node sing4ti2_lib +-@subsection sing4ti2_lib +-@c lib sing4ti2.lib tag:sing4ti2 +-@c ---------------------------------------------------------- + @node symodstd_lib + @subsection symodstd_lib + @c lib symodstd.lib +@@ -873,7 +863,6 @@ iniD, reslist, sumlist, dividelist, createlist + * solve_lib:: procedures to solve polynomial systems + * triang_lib:: procedures for decomposing zero-dimensional ideals + * ntsolve_lib:: one real solution of polynomial systems (Newton iteration) +-* recover_lib:: Hybrid numerical/symbolical algorithms + * rootisolation_lib:: real root isolation with intervals + * signcond_lib:: computing realizable sign conditions + * zeroset_lib:: procedures for roots and factorization +@@ -904,10 +893,6 @@ iniD, reslist, sumlist, dividelist, createlist + @subsection ntsolve_lib + @c lib ntsolve.lib + @c --------------------------------------------------------- +-@node recover_lib +-@subsection recover_lib +-@c lib recover.lib tag:bertini +-@c ---------------------------------------------------------- + @node rootisolation_lib + @subsection rootisolation_lib + @c lib rootisolation.lib +@@ -1108,7 +1093,6 @@ but not for serious computations. + * cimonom_lib:: complete intersection for toric ideals + * gfan_lib:: A gfanlib interface for Singular + * gitfan_lib:: Compute GIT-fans +-* polymake_lib:: interface to TOPCOM + * realizationMatroids_lib:: Realizability for Tropical Fan Curves + * tropical_lib:: interface to gfan + * tropicalNewton_lib:: Newton polygons in tropical geometry +@@ -1125,10 +1109,7 @@ but not for serious computations. + @node gitfan_lib + @subsection gitfan_lib + @c lib gitfan.lib +-@c ---------------------------------------------------------- +-@node polymake_lib +-@subsection polymake_lib +-@c lib polymake.lib tag:topcom ++ + @c ---------------------------------------------------------- + @node realizationMatroids_lib + @subsection realizationMatroids_lib +@@ -1219,7 +1200,6 @@ Comments should be send to the author of the library directly. + * stanleyreisner_lib:: T1 and T2 for a general Stanley-Reiser ring + * swalk_lib:: Sagbi Walk Conversion Algorithm + * systhreads_lib:: multi-threaded objects +-* tateProdCplxNegGrad_lib:: sheaf cohomology on product of projective spaces + * VecField_lib:: vector fields + @end menu + @c ---------------------------------------------------------- +@@ -1310,10 +1290,6 @@ Todos/Issues: + @subsection systhreads_lib + @c lib systhreads.lib + @c --------------------------------------------------------- +-@node tateProdCplxNegGrad_lib +-@subsection tateProdCplxNegGrad_lib +-@c lib tateProdCplxNegGrad.lib +-@c --------------------------------------------------------- + @node VecField_lib + @subsection VecField_lib + @c lib VecField.lib