gh-36792: Use the system GAP
Resurrect https://github.com/sagemath/sage/issues/29644 and add an
`spkg-configure.m4` for GAP.
Some other changes were made to make this possible / nicer:
1. `GAP_LIB_DIR` and `GAP_SHARE_DIR` are merged into `GAP_ROOT_PATHS`.
This was suggested by @tornaria and is the right approach, especially
now that `GAP_SO` has been removed. Nothing else needs those two
directories and GAP itself doesn't care about them -- it only cares
about the package search path, i.e. `GAP_ROOT_PATHS`. So changing the
variable(s) brings us in line with the way GAP works.
2. We no longer pass the `-r` flag to GAP. Particularly when using the
system GAP, we do want the user to be able to install his own packages
and run his own initialization.
3. We begin to pass `-A` to GAP. This tells GAP not to autoload the big
set of "recommended" packages at start-up, which avoids the inevitable
error messages when those packages are not installed on the system GAP.
We could check for all of them in `spkg-configure.m4`, but it's a long
list, and loading them slows down GAP initialization for no benefit --
Sage itself uses only one such package. Users can autoload them via
gaprc or gap.ini in light of (2).
4. After adding `-A` to the initialization, we try to load the
PolyCyclic package if it's installed. This is the one "recommended"
package that Sage itself uses.
5. The "recommended" packages are all moved from the gap SPKG to
gap_packages because we no longer need them, except (maybe) for
PolyCyclic. Should keep polycyclic installed by default? The tests all
pass without it, but it is used a few places in sagelib.
6. Various stale doctest fixes.
7. The expected output from a few tests has changed. Where possible,
I've made the test more robust. In one case I had to drop the printing
of a matrix, because if you dig into the source code for GAP's
`NormalSubgroups()`, it chooses a `Representative()` inconsistently, and
that eventually affects the entries of the matrix.
All tests are passing afterwards... except one, a heisenbug:
```
sage -t --warn-long 187.7 --random-
seed=96688270013898650573232209016248663009
src/sage/groups/matrix_gps/finitely_generated_gap.py
**********************************************************************
File "src/sage/groups/matrix_gps/finitely_generated_gap.py", line 123,
in sage.groups.matrix_gps.finitely_generated_gap.FinitelyGeneratedMatrix
Group_gap.as_permutation_group
Failed example:
P == Psmaller
Expected:
False
Got:
True
**********************************************************************
```
If anyone knows what's going on there, I'd be grateful. The GAP docs for
`SmallerDegreePermutationRepresentation()` say,
> The methods used might involve the use of random elements and the
permutation representation (or even the degree of the representation) is
not guaranteed to be the same for different calls of
SmallerDegreePermutationRepresentation.
So maybe this isn't really a bug, but I would find it strange if that
randomness could mean that sometimes the smaller degree option just
wouldn't work at all.
Anyway, have at it, and let me know what you think.
URL: https://github.com/sagemath/sage/pull/36792
Reported by: Michael Orlitzky
Reviewer(s): Dima Pasechnik, François Bissey, Gonzalo Tornaría, Matthias Köppe, Michael Orlitzky, Tobias Diez