sagemath/sage

spkg-configure.m4 for polymake

mkoeppe opened this issue · 126 comments

Polymake is available on a number of systems (https://repology.org/project/polymake/versions) and also on Homebrew via a custom tap: https://polymake.org/doku.php/download/start#binary_releases

We add system package info and spkg-configure.m4

Fixing broken distribution packages is beyond the scope of the ticket.

Depends on #32605

CC: @videlec @jplab @kliem paffenholz@opt.tu-darmstadt.de @antonio-rojas @dimpase @orlitzky

Component: build: configure

Author: Matthias Koeppe

Branch/Commit: 03f17c9

Reviewer: Antonio Rojas, Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/31527

Dependencies: #31335

Commit: 2bbee93

New commits:

40996b3.homebrew-build-env: Use /usr/local/opt/polymake if it exists
2bbee93build/pkgs/polymake/spkg-configure.m4: New
comment:3

With polymake from Andreas's tap, need to do export PERL5LIB="/usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5/darwin-thread-multi-2level:/usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5" (this is done in the polymake script but we use the callable library through jupymake)

Changed commit from 2bbee93 to cd792c5

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

00b3109build/pkgs/sagelib/spkg-install: Set SETUPTOOLS_USE_DISTUTILS=local
fd23c0dbuild/pkgs/setuptools/patches: Add distutils patch from https://github.com/fxcoudert/cpython/commit/6511bf56.patch
3601c51Adapt the patch to apply to the vendored distutils
9ad84ccMerge branch 't/31344/homebrew__docbuild_crashes__libtcl_atforkprepare' into t/31335/homebrew__unused_packages__singular__pari_______in__usr_local_leak_into_sagelib_build
ae4ea55Merge branch 't/31344/homebrew__docbuild_crashes__libtcl_atforkprepare' into t/31335/homebrew__unused_packages__singular__pari_______in__usr_local_leak_into_sagelib_build
add7db4Merge tag '9.3.beta7' into t/31335/homebrew__unused_packages__singular__pari_______in__usr_local_leak_into_sagelib_build
4e777e7Merge tag '9.3.beta8' into t/31335/homebrew__unused_packages__singular__pari_______in__usr_local_leak_into_sagelib_build
e03c5acbuild/bin/sage-build-env: Set SETUPTOOLS_USE_DISTUTILS here, not in build/pkgs/sagelib/spkg-install
f125453Merge #31335
cd792c5build/pkgs/polymake/distros: Add more

Changed dependencies from #31335 to #31335, #31482

Changed commit from cd792c5 to 4fef65a

Branch pushed to git repo; I updated commit sha1. New commits:

55211fabuild/pkgs/latte_int: Upgrade to 1.7.6
78daa99build/pkgs/latte_int/dependencies: Make lrslib only an optional dependency
156fc9fMerge #31482
4fef65abuild/pkgs/polymake/dependencies: Make lrslib only an optional dependency

Branch pushed to git repo; I updated commit sha1. New commits:

35558b3build/pkgs/polymake/spkg-install.in: Only pass --with-lrs if it is installed

Changed commit from 4fef65a to 35558b3

comment:9

Replying to @mkoeppe:

With polymake from Andreas's tap, need to do export PERL5LIB="/usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5/darwin-thread-multi-2level:/usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5" (this is done in the polymake script but we use the callable library through jupymake)

Setting this globally unfortunately breaks autotools (aclocal) from homebrew:

Usage: DynaLoader::dl_find_symbol(libhandle, symbolname) at /usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5/darwin-thread-multi-2level/XSLoader.pm line 89.
Compilation failed in require at /usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5/File/Path.pm line 6.
BEGIN failed--compilation aborted at /usr/local/Cellar/polymake/4.3_1/libexec/perl5/lib/perl5/File/Path.pm line 6.
Compilation failed in require at /usr/local/bin/aclocal line 33.
BEGIN failed--compilation aborted at /usr/local/bin/aclocal line 33.

Too bad that polymake-config does not advertise the necessary Perl library path...

Branch pushed to git repo; I updated commit sha1. New commits:

93fcbd6build/pkgs/polymake/distros/debian.txt: Add libpolymake-dev

Changed commit from 35558b3 to 93fcbd6

Changed dependencies from #31335, #31482 to none

comment:12

Moving this ticket to 9.4, as it seems unlikely that it will be merged in 9.3, which is in the release candidate stage

comment:13

Saving the continuation:

JuPyMake/JuPyMake.cpp at master · sebasguts/JuPyMake
https://github.com/sebasguts/JuPyMake/blob/master/JuPyMake.cpp

jupyter-polymake/kernel.py at master · polymake/jupyter-polymake
https://github.com/polymake/jupyter-polymake/blob/master/jupyter_kernel_polymake/kernel.py

jupyter-kernel-polymake · PyPI
https://pypi.org/project/jupyter-kernel-polymake/

Failed to install on OSX Mojave Mac::SystemDirectory is not installed. · Issue #39 · sqitchers/homebrew-sqitch
sqitchers/homebrew-sqitch#39

tokuhirom/plenv: Perl binary manager
https://github.com/tokuhirom/plenv

polymake Downloads [polymake wiki]
https://polymake.org/doku.php/download/start

comment:14

Perlbrew
https://perlbrew.pl/

gugod/App-perlbrew: Manage perl installations in your $HOME
https://github.com/gugod/App-perlbrew

App::perlbrew - Manage perl installations in your $HOME - metacpan.org
https://metacpan.org/pod/App::perlbrew

polymake Downloads [polymake wiki]
https://polymake.org/doku.php/download/start#binary_releases

perl:mongodb package versions - Repology
https://repology.org/project/perl:mongodb/versions

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

b211f2a.homebrew-build-env: Use /usr/local/opt/polymake if it exists
27b4992build/pkgs/polymake/spkg-configure.m4: New
d30256bbuild/pkgs/polymake/spkg-configure.m4: If system polymake is in use, do not require Perl packages
6860f90build/pkgs/polymake/distros: Add more
f4eb33bbuild/pkgs/polymake/dependencies: Make lrslib only an optional dependency
d93788abuild/pkgs/polymake/spkg-install.in: Only pass --with-lrs if it is installed
9ad9e2fbuild/pkgs/polymake/distros/debian.txt: Add libpolymake-dev

Changed commit from 93fcbd6 to 9ad9e2f

Dependencies: #32605

comment:18

Replying to @mkoeppe:

With polymake from Andreas's tap, need to do export PERL5LIB="[...]" (this is done in the polymake script but we use the callable library through jupymake)

Fixed in latest version of the homebrew formula according to polymake/polybundle#19 (comment)

Changed commit from 9ad9e2f to 1832397

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

2576f86build/make/Makefile.in: If a script package has no spkg-install, run "sage -info" and exit with error
feb8de7build/pkgs/: Remove spkg-install scripts for dummy script packages
8f782c0.github/workflows/tox-{optional,experimental}.yml: Do not try to test dummy script packages
4b292bebuild/pkgs/perl_mongodb/spkg-install: Remove
a7b6352build/bin/sage-spkg-info: Fix display of system packages
e65b309bootstrap: Do not provide ./configure --enable-SPKG options for dummy optional packages
b485d46m4/sage_spkg_collect.m4: Do not advertise dummy optional packages as installable
8c8e1c4Merge #31163
015b899build/bin/sage-print-system-package-command: Handle cpan
1832397Merge #32605

Changed dependencies from #32605 to #32605, #30887

Changed commit from 1832397 to 83a98be

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

ea548d7sage.features.four_ti_2: New, use it in sage.interfaces.four_ti_2, sage.sandpiles
f826dedbuild/pkgs/4ti2/spkg-configure.m4: Check for executable's with prefix 4ti2_ too
56016ceuse AC_LINK_IFELSE instead of obsolete AC_TRY_LINK
2b45b77sage.feature.join_feature: New, factored out from LatteFeature; use it to implement FourTi2Feature
5c23cc9DocTestReporter: Fix 'sage -t --optional=all'
1b8634dsage.doctest.external: Add 4ti2
d9d4f99Merge tag '9.4.beta6' into t/30887/public/30887
646e182src/sage/features/four_ti_2.py: Move import of SAGE_ENV inside the `__init__` method, to remove confusion of sage.misc.dev_tools
b090dc0Merge #30887
83a98besrc/sage/features/polymake.py: New

Changed dependencies from #32605, #30887 to #32605, #30887, #32547

Branch pushed to git repo; I updated commit sha1. New commits:

ccd779a#32547 : replace nonexistent llvm-toolchain with clang as Debian alternative to llvm spkg
b2281faMerge #32547
d2cbfe7build/pkgs/polymake/distros/homebrew.txt: New

Changed commit from 83a98be to d2cbfe7

Author: Matthias Koeppe

comment:25

Tested successfully on homebrew

comment:27

Testing with tox -e docker-ubuntu-groovy-maximal, where configure accepts system polymake 4.1-4build1, gives many doctest failures of the form:

      File "/sage/local/lib/python3.8/site-packages/sage/interfaces/polymake.py", line 2598, in _start
        InitializePolymake()          # Can only be called once
    JuPyMake.PolymakeError: polymake::Main - /usr/lib/polymake/shared is not a symlink

Indeed:

ls -l /usr/lib/polymake/
total 12
-rw-r--r-- 1 root root 2024 Aug 17  2020 config.ninja
drwxr-xr-x 2 root root 4096 Oct  8 21:18 lib
drwxr-xr-x 3 root root 4096 Oct  8 21:18 perlx
comment:28

... so clearly we need to extend spkg-configure.m4 to test that libpolymake has not been debianized to death

Branch pushed to git repo; I updated commit sha1. New commits:

f1f362dbuild/pkgs/polymake/spkg-configure.m4: Actually use POLYMAKE_VERSION_MIN
c6b5f8cbuild/pkgs/polymake/spkg-configure.m4: Link and run a test program with libpolymake

Changed commit from d2cbfe7 to c6b5f8c

comment:30

Now correctly rejects polymake on this system (tox -e docker-ubuntu-groovy-maximal -- config.status)

comment:31

Same on ubuntu-impish-maximal (with system polymake 4.3)

comment:32

On fedora-34-maximal:

configure:34443: checking whether libpolymake works
configure:34479: g++ -o conftest  -I/usr/include/polymake/external -I/usr/include/arb -I/usr/include/eigen3 -I/usr/include/gfanlib -I/usr/include/nauty -I/usr/include -I/usr/include -DPOLYMAKE_VERSION=404 -fPIC -pipe -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused-local-typedefs -std=c++14 -ftemplate-depth-200 -fno-strict-aliasing -fopenmp -Wshadow -Wlogical-op -Wconversion -Wzero-as-null-pointer-constant -Wno-parentheses -Wno-error=unused-function -Wno-stringop-overflow -Wno-array-bounds -Wno-maybe-uninitialized -Wno-free-nonheap-object -DPOLYMAKE_WITH_FLINT -O2 -DPOLYMAKE_DEBUG=0   -Dlinux   -I/usr/include -lpolymake -Wl,-z,relro -Wl,--as-needed -lnormaliz -ldl -fuse-ld=gold -fopenmp -L/usr/lib64 -Wl,-E  conftest.cpp -lmpfi -lmpc -lm4rie -llrcalc -lnauty -lhomfly -liml -lgiac -lecm -lpari -lcurl -lcliquer -lcddgmp -lbz2 -lflint -lmpfr -lglpk -lgmp -lm  -lntl -lLfunction >&5
cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1plus: some warnings being treated as errors
comment:33

Same on fedora-35-maximal

So system polymake is rejected. This is correct because building jupymake would fail with the same error.

Branch pushed to git repo; I updated commit sha1. New commits:

d9fc03ebuild/pkgs/perl_cpan_polymake_prereq/distros/fedora.txt: perl-TermReadKey, not perl-Term-ReadKey

Changed commit from c6b5f8c to d9fc03e

Changed commit from d9fc03e to 777d1b8

Branch pushed to git repo; I updated commit sha1. New commits:

777d1b8build/pkgs/polymake/distros/nix.txt: New
comment:38

needs a rebase

Branch pushed to git repo; I updated commit sha1. New commits:

edce768Merge tag '9.5.beta3' into t/31527/spkg_configure_m4_for_polymake

Changed commit from 777d1b8 to edce768

Changed dependencies from #32605, #30887, #32547 to #32605

comment:41

gentoo's polymake is too old atm, it's 3.0_p2 there (and broken).

Changed commit from edce768 to 717f98b

Branch pushed to git repo; I updated commit sha1. New commits:

717f98bbuild/pkgs/polymake/distros/gentoo.txt: Remove
comment:43

Let's get this in please

comment:44

fails to recognize polymake on Fedora 34 with polymake package installed, due to
-Werror=format-security in g++ call from ./configure.

configure:36908: checking for polymake-config >= 3.5
configure:36984: result: /usr/bin/polymake-config
configure:36989: checking whether libpolymake works
configure:37025: g++ -o conftest  -I/usr/include/polymake/external -I/usr/include/arb -I/usr/include/eigen3 -I/usr/include/gfanlib -I/usr/include/nauty -I/usr/include -I/usr/include -DPOLYMAKE_VERSION=404 -fPIC -pipe -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused-local-typedefs -std=c++14 -ftemplate-depth-200 -fno-strict-aliasing -fopenmp -Wshadow -Wlogical-op -Wconversion -Wzero-as-null-pointer-constant -Wno-parentheses -Wno-error=unused-function -Wno-stringop-overflow -Wno-array-bounds -Wno-maybe-uninitialized -Wno-free-nonheap-object -DPOLYMAKE_WITH_FLINT -O2 -DPOLYMAKE_DEBUG=0   -Dlinux   -I/usr/include -lpolymake -Wl,-z,relro -Wl,--as-needed -lnormaliz -ldl -fuse-ld=gold -fopenmp -L/usr/lib64 -Wl,-E  conftest.cpp -lmpfi -lmpc -lm4rie -llrcalc -lnauty -lhomfly -liml -lgiac -lecm -lpari -lcurl -lcliquer -lcddgmp -lbz2 -lflint -lmpfr -lglpk -lgmp -lm  -lntl -lLfunction >&5
cc1plus: error: '-Wformat-security' ignored without '-Wformat' [-Werror=format-security]
cc1plus: some warnings being treated as errors

And Werror gets there from polymake-config --cflags call.

$ polymake-config --cflags
-DPOLYMAKE_VERSION=404 -fPIC -pipe -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused-local-typedefs -std=c++14 -ftemplate-depth-200 -fno-strict-aliasing -fopenmp -Wshadow -Wlogical-op -Wconversion -Wzero-as-null-pointer-constant -Wno-parentheses -Wno-error=unused-function -Wno-stringop-overflow -Wno-array-bounds -Wno-maybe-uninitialized -Wno-free-nonheap-object -DPOLYMAKE_WITH_FLINT -O2 -DPOLYMAKE_DEBUG=0
comment:45

If I clean up CPPFLAGS as follows

--- a/build/pkgs/polymake/spkg-configure.m4
+++ b/build/pkgs/polymake/spkg-configure.m4
@@ -20,6 +20,7 @@ SAGE_SPKG_CONFIGURE([polymake], [
            saved_LDFLAGS="$LDFLAGS"
            CXX="$($ac_cv_path_POLYMAKE_CONFIG --cc)"
            CPPFLAGS="$($ac_cv_path_POLYMAKE_CONFIG --includes) $($ac_cv_path_POLYMAKE_CONFIG --cflags) $CPPFLAGS"
+           CPPFLAGS=${CPPFLAGS//\-Werror=format\-security/}
            LDFLAGS="-lpolymake $($ac_cv_path_POLYMAKE_CONFIG --ldflags) $LDFLAGS"
            AC_RUN_IFELSE([AC_LANG_PROGRAM([[
                #include <polymake/Main.h>

then I still get

configure:36989: checking whether libpolymake works
configure:37026: g++ -o conftest  -I/usr/include/polymake/external -I/usr/include/arb -I/usr/include/eigen3 -I/usr/include/gfanlib -I/usr/include/nauty -I/usr/include -I/usr/include -DPOLYMAKE_VERSION=404 -fPIC -pipe -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe  -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-unused-local-typedefs -std=c++14 -ftemplate-depth-200 -fno-strict-aliasing -fopenmp -Wshadow -Wlogical-op -Wconversion -Wzero-as-null-pointer-constant -Wno-parentheses -Wno-error=unused-function -Wno-stringop-overflow -Wno-array-bounds -Wno-maybe-uninitialized -Wno-free-nonheap-object -DPOLYMAKE_WITH_FLINT -O2 -DPOLYMAKE_DEBUG=0   -Dlinux   -I/usr/include -lpolymake -Wl,-z,relro -Wl,--as-needed -lnormaliz -ldl -fuse-ld=gold -fopenmp -L/usr/lib64 -Wl,-E  conftest.cpp -lmpfi -lmpc -lm4rie -llrcalc -lnauty -lhomfly -liml -lgiac -lecm -lpari -lcurl -lcliquer -lcddgmp -lbz2 -lflint -lmpfr -lglpk -lgmp -lm  -lntl -lLfunction >&5
configure:37026: $? = 0
configure:37026: ./conftest
Can't locate Polymake/Main.pm in @INC (you may need to install the Polymake::Main module) (@INC contains: /share/polymake/perllib /lib64/polymake/perlx/5.32.1/x86_64-linux-thread-multi /lib64/polymake/perlx/5.32.1 /lib64/polymake/perlx /users/dimpase/perl5/lib/perl5/x86_64-linux-thread-multi /users/dimpase/perl5/lib/perl5 /usr/local/lib64/perl5/5.32 /usr/local/share/perl5/5.32 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) at /builddir/build/BUILD/polymake-4.4/lib/callable/src/perl/Main.cc line 146.
BEGIN failed--compilation aborted at /builddir/build/BUILD/polymake-4.4/lib/callable/src/perl/Main.cc line 146.
terminate called after throwing an instance of 'std::runtime_error'
  what():  could not initialize the perl interpreter
./configure: line 3495: 1808668 Aborted                 (core dumped) ./conftest$ac_exeext
configure:37026: $? = 134
configure: program exited with status 134
comment:46

Replying to @dimpase:

fails to recognize polymake on Fedora 34 with polymake package installed, due to
-Werror=format-security in g++ call from ./configure.

Yes, see comment:33.

Description changed:

--- 
+++ 
@@ -1,3 +1,5 @@
 Polymake is available on a number of systems (https://repology.org/project/polymake/versions) and also on Homebrew via a custom tap: https://polymake.org/doku.php/download/start#binary_releases
 
 We add system package info and `spkg-configure.m4`
+
+Fixing broken distribution packages is beyond the scope of the ticket.
comment:50

Is there any Linux distro with working for the purposes of this ticket Polymake package?

comment:51

I don't remember if I tested with arch, opensuse, or nix.

Reviewer: Antonio Rojas

comment:52

Works fine on Arch. Picks up system polymake, Jupymake spkg installs correctly and all tests pass in interfaces.polymake

comment:53

Thanks!

comment:54

Replying to @dimpase:

Is there any Linux distro with working for the purposes of this ticket Polymake package?

Gentoo with gentoo/gentoo#17925

sage -t --long --random-seed=0 src/sage/interfaces/polymake.py
    [54 tests, 0.63 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 0.7 seconds
    cpu time: 0.1 seconds
    cumulative wall time: 0.6 seconds
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.10/sage-runtests", line 159, in <module>
    exit_code_pytest = pytest.main(pytest_options + args)
TypeError: can only concatenate list (not "Namespace") to list
comment:55

Excellent!

comment:56

The present branch appears to need polymake explictly listed in the list --optional=, if it's not installed. On arch I have:

$ ./sage -tp  src/sage/geometry/polyhedron/backend_polymake.py
Running doctests with ID 2021-10-22-08-52-35-89300609.
Git branch: wip
Using --optional=arch,argcomplete,build,dochtml,jupymake,pip,sage,sage.rings.real_double,sage_spkg
Doctesting 1 file using 4 threads.
sage -t --warn-long 105.2 --random-seed=111795974516996210666725135263478181348 src/sage/geometry/polyhedron/backend_polymake.py
    [9 tests, 0.52 s]
----------------------------------------------------------------------
All tests passed!
----------------------------------------------------------------------
Total time for all tests: 0.6 seconds
    cpu time: 0.5 seconds
    cumulative wall time: 0.5 seconds
Pytest is not installed, skip checking tests that rely on it.

but

$ ./sage -tp --optional=arch,argcomplete,build,dochtml,pip,sage,sage.rings.real_double,sage_spkg,polymake src/sage/geometry/polyhedron/backend_polymake.py
Running doctests with ID 2021-10-22-08-52-45-3599c25d.
Git branch: wip
Using --optional=arch,argcomplete,build,dochtml,pip,polymake,sage,sage.rings.real_double,sage_spkg
Doctesting 1 file using 4 threads.
sage -t --warn-long 105.2 --random-seed=65107005796673777637867553513561507930 src/sage/geometry/polyhedron/backend_polymake.py
**********************************************************************
File "src/sage/geometry/polyhedron/backend_polymake.py", line 665, in sage.geometry.polyhedron.backend_polymake.Polyhedron_polymake.__setstate__
Failed example:
    print("Possible output"); P = polytopes.dodecahedron(backend='polymake')  # optional - polymake
Exception raised:
    Traceback (most recent call last):
      File "/home/dima/sagetrac-mirror/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/interfaces/interface.py", line 732, in __init__
        self._name = parent._create(value, name=name)
      File "/home/dima/sagetrac-mirror/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/interfaces/polymake.py", line 549, in _create
        self.set(name, value)
      File "/home/dima/sagetrac-mirror/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/interfaces/polymake.py", line 638, in set
        self.eval(cmd)
      File "/home/dima/sagetrac-mirror/local/var/lib/sage/venv-python3.9/lib/python3.9/site-packages/sage/interfaces/polymake.py", line 2712, in eval
        raise PolymakeError(error)
    sage.interfaces.polymake.PolymakeError: C++/perl Interface module compilation failed; most likely due to a type mismatch.
    Set the variable $Polymake::User::Verbose::cpp to a positive value and repeat for more details.


    During handling of the above exception, another exception occurred:
...
   TypeError: C++/perl Interface module compilation failed; most likely due to a type mismatch.
    Set the variable $Polymake::User::Verbose::cpp to a positive value and repeat for more details.

**********************************************************************
1 item had failures:
   1 of  21 in sage.geometry.polyhedron.backend_polymake.Polyhedron_polymake.__setstate__
    [106 tests, 1 failure, 13.32 s]
----------------------------------------------------------------------
sage -t --warn-long 105.2 --random-seed=65107005796673777637867553513561507930 src/sage/geometry/polyhedron/backend_polymake.py  # 1 doctest failed

there is a similar test failure in src/sage/geometry/polyhedron/base.py

comment:57

We see that tests mentioned in comment:54 were not complete, as polymake was not in --optional= - if it were, we'd see many more tests (this is on Arch, again):

$ ./sage -tp --optional=arch,argcomplete,build,dochtml,pip,sage,sage.rings.real_double,sage_spkg,polymake src/sage/interfaces/polymake.py                 
Running doctests with ID 2021-10-22-08-58-24-8cc8a0d8.
Git branch: wip
Using --optional=arch,argcomplete,build,dochtml,pip,polymake,sage,sage.rings.real_double,sage_spkg
Doctesting 1 file using 4 threads.
sage -t --warn-long 105.2 --random-seed=106731483408083137921384584724619392983 src/sage/interfaces/polymake.py
    [253 tests, 5.28 s]
----------------------------------------------------------------------
All tests passed!
comment:58

jupymake should be in build/pkgs/polymake/dependencies, as polymake tests fail if it's not installed.

As well, spkg-configure.m4 perhaps needs to at least print a warning if system's polymake it selected, or, better, use some (missing?) mechanism to trigger installation of jupymake in this case.

comment:59

Replying to @dimpase:

we'd see many more tests (this is on Arch, again):
[253 tests, 5.28 s]

yes, with that long --optional= I see all 253 tests passed too (on Gentoo)

comment:60

Replying to @dimpase:

jupymake should be in build/pkgs/polymake/dependencies, as polymake tests fail if it's not installed.

No, this makes no sense. jupymake depends (at compile time) on polymake.

comment:61

Replying to @dimpase:

use some (missing?) mechanism to trigger installation of jupymake in this case.

This is a valid wishlist item.

comment:62

then tag jupymake-dependent tests as such.

comment:63

The failure in comment:56,

   TypeError: C++/perl Interface module compilation failed; most likely due to a type mismatch.
    Set the variable $Polymake::User::Verbose::cpp to a positive value and repeat for more details.

has got nothing to do with jupymake vs. the polymake pexpect interface.

Looks to me like a packaging bug in arch.

comment:64

Replying to @mkoeppe:

Replying to @dimpase:

use some (missing?) mechanism to trigger installation of jupymake in this case.

This is a valid wishlist item.

I have opened #32741 for this.

comment:65

Replying to @dimpase:

gentoo's polymake is too old atm, it's 3.0_p2 there (and broken).

I've just updated it to polymake-4.5. Send bug reports if it's still broken.

comment:67

Replying to @mkoeppe:

Replying to @mkoeppe:

Replying to @dimpase:

use some (missing?) mechanism to trigger installation of jupymake in this case.

This is a valid wishlist item.

I have opened #32741 for this.

I explained there to how to fix this in this particular case - with jupymake getting spkg-configure.m4

comment:68

I hope #32741 is not preventing this ticket to get positive review. I mean all 253 tests passed on several systems.

comment:69

well, the reason for not giving it a positive review are doctests failing due to accidentally not having jupymake installed, which is not forced now.

comment:70

Dima, comment:63 -- since you tested on arch, could you please investigate the failure mode? These doctests are NOT dependent on jupymake.

comment:71

Let's move this forward please

comment:72

Replying to @orlitzky:

Replying to @dimpase:

gentoo's polymake is too old atm, it's 3.0_p2 there (and broken).

I've just updated it to polymake-4.5. Send bug reports if it's still broken.

# emerge --ask polymake

These are the packages that would be merged, in order:

Calculating dependencies -

!!! Problem resolving dependencies for sci-mathematics/polymake             ... done!

!!! The ebuild selected to satisfy "polymake" has unmet requirements.
- sci-mathematics/polymake-4.5::gentoo USE="cdd flint normaliz -bliss -libpolymake -lrs -nauty -ppl -singular"

  The following REQUIRED_USE flag constraints are unsatisfied:
    exactly-one-of ( bliss nauty )

comment:73

Replying to @mkoeppe:

Let's move this forward please

sorry, my arch lxc vm is gone (I guess I forgot to make it persistent?). Let me try "native" Gentoo instead.

comment:74

Time to work on #29283 (tox.ini: Add test environments using LXC)

comment:75

Replying to @dimpase:

Replying to @orlitzky:

Replying to @dimpase:

gentoo's polymake is too old atm, it's 3.0_p2 there (and broken).

I've just updated it to polymake-4.5. Send bug reports if it's still broken.

USE="cdd flint normaliz libpolymake lrs nauty ppl singular" emerge --ask polymake

doesn't work, there is a problem with lrs (and Sage installs polymake with lrs)
Apparently, it's known to Sage, as spkg-install.in has a comment:

# Since polymake v3.4, it does not find our lrs installation if we do not provide --with-lrs explicitly.

Once this is fixed in Gentoo (sorry, I don't grok its ebuilds), distros/gentoo.txt should be provided (with appropriate [..] options?).

comment:76

Replying to @dimpase:


  The following REQUIRED_USE flag constraints are unsatisfied:
    exactly-one-of ( bliss nauty )

You have to set USE=bliss or USE=nauty, but not both, to pick a backend for graph automorphism computations.

comment:77

Replying to @orlitzky:

Replying to @dimpase:


  The following REQUIRED_USE flag constraints are unsatisfied:
    exactly-one-of ( bliss nauty )

You have to set USE=bliss or USE=nauty, but not both, to pick a backend for graph automorphism computations.

sure, but the default USE flags shouldn't fail! As well, how about lrs?

comment:78

Replying to @dimpase:

sure, but the default USE flags shouldn't fail! As well, how about lrs?

They don't "fail," portage tells you to pick one because you have to pick one =P

If one is a significantly better choice than the other, we would normally enable that one by default, but I don't know enough about polymake to say that either is better.

What's wrong with lrs?

comment:79
USE="cdd flint normaliz libpolymake lrs nauty ppl singular" emerge --ask polymake

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sci-mathematics/polymake-4.5  USE="lrs*" 

Would you like to merge these packages? [Yes/No] 

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) sci-mathematics/polymake-4.5::gentoo
 * polymake-4.5-minimal.tar.bz2 BLAKE2B SHA512 size ;-) ...            [ ok ]
>>> Unpacking source...
>>> Unpacking polymake-4.5-minimal.tar.bz2 to /var/tmp/portage/sci-mathematics/polymake-4.5/work
>>> Source unpacked in /var/tmp/portage/sci-mathematics/polymake-4.5/work
>>> Preparing source in /var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5 ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5 ...
checking C++ compiler ... ok (x86_64-pc-linux-gnu-g++ is GCC 8.3.1)
checking C++ library ... ok (GNU libstdc++ 20190518, C++ 201402)
determining architecture ... ok (x86_64)
determining compiler flags ... ok
   CFLAGS=-march=native -O3 -fomit-frame-pointer -pipe
   CXXFLAGS=-march=native -O3 -fomit-frame-pointer -pipe -std=c++14 -ftemplate-depth-200 -fno-strict-aliasing -fopenmp -Wshadow -Wlogical-op -Wconversion -Wzero-as-null-pointer-constant -Wno-parentheses -Wno-error=unused-function
   LDFLAGS=-Wl,-O1 -Wl,--as-needed -fuse-ld=gold -fopenmp
checking gmp installation ... ok
checking mpfr installation ... ok
checking boost installation ... ok
checking perl module XML::SAX ... ok
checking perl module Term::ReadKey ... ok
checking perl module Term::ReadLine ... ok
checking perl module JSON ... ok
checking shared perl library ... ok

Configuring bundled extensions:
bundled extension java ... disabled by command-line
bundled extension javaview ... disabled by command-line
bundled extension scip ... disabled by command-line
bundled extension soplex ... disabled by command-line
bundled extension bliss ... disabled by command-line
bundled extension cdd ... ok (0.94m @ /usr)
bundled extension flint ... ok (ok (2.7.1 @ /usr))
bundled extension libnormaliz ... ok (3.8.1 @ /usr)
bundled extension lrs ... failed

ERROR:
The bundled extension lrs was explicitly requested but failed to configure.
Please recheck your argument (--with-lrs=/usr) and build/bundled.log .
You can also disable it by specifying --without-lrs instead.
 * ERROR: sci-mathematics/polymake-4.5::gentoo failed (configure phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line 127:  Called src_configure
 *   environment, line 1598:  Called die
 * The specific snippet of code:
 *       ./configure --prefix="${EPREFIX}/usr" --libdir="${EPREFIX}/usr/$(get_libdir)" --libexecdir="${EPREFIX}/usr/$(get_libdir)/polymake" $(usev !libpolymake "--without-callable") --without-java --without-javaview --without-native --without-scip --without-soplex $(use_with bliss bliss "${EPREFIX}/usr") $(use_with cdd cdd "${EPREFIX}/usr") $(use_with flint flint "${EPREFIX}/usr") $(use_with lrs lrs "${EPREFIX}/usr") $(use_with nauty nauty "${EPREFIX}/usr") $(use_with normaliz libnormaliz "${EPREFIX}/usr") $(use_with ppl ppl "${EPREFIX}/usr") $(use_with singular singular "${EPREFIX}/usr") || die
 * 
 * If you need support, post the output of `emerge --info '=sci-mathematics/polymake-4.5::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sci-mathematics/polymake-4.5::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sci-mathematics/polymake-4.5/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-mathematics/polymake-4.5/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5'
 * S: '/var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5'

>>> Failed to emerge sci-mathematics/polymake-4.5, Log file:

>>>  '/var/tmp/portage/sci-mathematics/polymake-4.5/temp/build.log'

 * Messages for package sci-mathematics/polymake-4.5:

 * ERROR: sci-mathematics/polymake-4.5::gentoo failed (configure phase):
 *   (no error message)
 * 
 * Call stack:
 *     ebuild.sh, line 127:  Called src_configure
 *   environment, line 1598:  Called die
 * The specific snippet of code:
 *       ./configure --prefix="${EPREFIX}/usr" --libdir="${EPREFIX}/usr/$(get_libdir)" --libexecdir="${EPREFIX}/usr/$(get_libdir)/polymake" $(usev !libpolymake "--without-callable") --without-java --without-javaview --without-native --without-scip --without-soplex $(use_with bliss bliss "${EPREFIX}/usr") $(use_with cdd cdd "${EPREFIX}/usr") $(use_with flint flint "${EPREFIX}/usr") $(use_with lrs lrs "${EPREFIX}/usr") $(use_with nauty nauty "${EPREFIX}/usr") $(use_with normaliz libnormaliz "${EPREFIX}/usr") $(use_with ppl ppl "${EPREFIX}/usr") $(use_with singular singular "${EPREFIX}/usr") || die
 * 
 * If you need support, post the output of `emerge --info '=sci-mathematics/polymake-4.5::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=sci-mathematics/polymake-4.5::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/sci-mathematics/polymake-4.5/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-mathematics/polymake-4.5/temp/environment'.
 * Working directory: '/var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5'
 * S: '/var/tmp/portage/sci-mathematics/polymake-4.5/work/polymake-4.5'
hilbert /tmp # 

I guess one needs to do what's done in spkg-install to pass the lrs prefix more explicitly.

comment:80

I guess one needs to do what's done in spkg-install to pass the lrs prefix more explicitly.

You may need to upgrade to lrslib-071b or lrslib-071b-r1. Those versions (I added them to the tree along with polymake-4.5) fix a critical bug in v071. I don't know if v062 works because it doesn't even build anymore. Comically, we can't remove it though because it's "stable" and no one has stabilized v071b on x86 yet.

comment:81

Replying to @orlitzky:

I guess one needs to do what's done in spkg-install to pass the lrs prefix more explicitly.

You may need to upgrade to lrslib-071b or lrslib-071b-r1. Those versions (I added them to the tree along with polymake-4.5) fix a critical bug in v071. I don't know if v062 works because it doesn't even build anymore. Comically, we can't remove it though because it's "stable" and no one has stabilized v071b on x86 yet.

This does not take away the problem that polymake's configure fails, I cannot imagine it's due to lrs's version.

comment:82

Oops, I take it back - lrslib-071b-r1 allows configure to pass.

I don't know whether Gentoo has such a flexibility in configurations, but ideally it should refuse to even start building with an old lrs version.

comment:83

but I still have bad news, in Gentoo case in particular, but also
in general. Perl's MongoDB module is at EOL.

# emerge dev-perl/MongoDB
Calculating dependencies... done!

!!! All ebuilds that could satisfy "dev-perl/MongoDB" have been masked.
!!! One of the following masked packages is required to complete your request:
- dev-perl/MongoDB-1.8.0::gentoo (masked by: package.mask)
/usr/portage/profiles/package.mask:
# Sam James <sam@gentoo.org> (2021-10-25)
# Fails to build with glibc-2.30(!) and was abandoned upstream
# a few years ago. No reverse dependencies in tree.
# bug #728556. Removal on 2021-11-25.


For more information, see the MASKED PACKAGES section in the emerge
man page or refer to the Gentoo Handbook.

https://packages.gentoo.org/packages/dev-perl/MongoDB mentions version 2.2.2, and
https://metacpan.org/dist/MongoDB says

 Changes for version v2.2.2 - 2020-08-13

    !!! END OF LIFE NOTICE !!!
        As of August 13, 2020, the MongoDB Perl driver has reached end of life and is no longer supported by MongoDB.

comment:84

Shouldn't perl_cpan_polymake_prereq (and other deps?) be in SAGE_SPKG_DEPCHECK for polymake?

comment:85

MongoDB cannot deprive this ticket of positive review

comment:86

We should check that polymake is working, not only polymake-config.
(As some Perl deps might be broken - e.g. I ran into

$ polymake
Welcome to polymake version 4.5
Copyright (c) 1997-2021
Ewgenij Gawrilow, Michael Joswig, and the polymake team
Technische Universität Berlin, Germany
https://polymake.org

This is free software licensed under GPL; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Loading applications now...polymake:  ERROR: "/usr/share/polymake/apps/common/perllib/PolyDB.pm", line 23: Can't locate MongoDB.pm in @INC (you may need to install the MongoDB module) (@INC contains: Polymake::Core::Application=ARRAY(0x5589c39eea50) /usr/share/polymake/perllib /usr/lib64/polymake/perlx/5.34.0/x86_64-linux-thread-multi /usr/lib64/polymake/perlx/5.34.0 /usr/lib64/polymake/perlx /etc/perl /usr/local/lib64/perl5/5.34/x86_64-linux-thread-multi /usr/local/lib64/perl5/5.34 /usr/lib64/perl5/vendor_perl/5.34/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.34 /usr/lib64/perl5/5.34/x86_64-linux-thread-multi /usr/lib64/perl5/5.34 /usr/lib64/perl5/5.32 /usr/lib64/perl5/vendor_perl/5.32 /usr/lib64/perl5/vendor_perl/5.30.3 /usr/lib64/perl5/vendor_perl/5.30.0)
comment:87

I was able to install the missing perl module on Gentoo by doing as root

# emerge App-cpanminus
# cpanm MongoDB

this needs another ticket.

comment:88

Please see #32808 for Perl MongoDB package/spkg issues.

Work Issues: clarify Perl deps in spkg-configure.m4 (and elsewhere)

comment:90

See also #31830 (perl_cpan_polymake_prereq: Update install instructions).

comment:91

Replying to @dimpase:

Shouldn't perl_cpan_polymake_prereq (and other deps?) be in SAGE_SPKG_DEPCHECK for polymake?

perl_cpan_polymake_prereq does not make sense in SAGE_SPKG_DEPCHECK because it is a dummy script package -- we provide no spkg-install for it.

You can add SAGE_SPKG_DEPCHECK for bliss, cddlib, lrslib, readline, ppl, which bring shared libraries.

Changed commit from 717f98b to 03f17c9