Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 923064 - [sage-on-gentoo overlay] sci-mathematics/sage-10.2 fails to compile with cython compile error
Summary: [sage-on-gentoo overlay] sci-mathematics/sage-10.2 fails to compile with cyth...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Overlays (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: François Bissey
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-01-27 23:33 UTC by Mark-Joe
Modified: 2024-02-08 20:02 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
output of `emerge --info '=sci-mathematics/sage-10.2::sage-on-gentoo'` (sagecompileerror.txt,7.76 KB, text/plain)
2024-01-27 23:33 UTC, Mark-Joe
Details
content of /var/tmp/portage/sci-mathematics/sage-10.2/temp/build.log (sagebuildlog.zip,148.59 KB, application/zip)
2024-01-27 23:40 UTC, Mark-Joe
Details
output of "equery f sage" (equerysage.zip,109.21 KB, application/zip)
2024-02-04 02:38 UTC, Mark-Joe
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark-Joe 2024-01-27 23:33:03 UTC
Created attachment 883334 [details]
output of `emerge --info '=sci-mathematics/sage-10.2::sage-on-gentoo'`

Compilation of sci-mathematics/sage-10.2 failes with 
Cython.Compiler.Errors.CompileError: sage/algebras/fusion_rings/shm_managers.pyx
Comment 1 Mark-Joe 2024-01-27 23:40:20 UTC
Created attachment 883335 [details]
content of /var/tmp/portage/sci-mathematics/sage-10.2/temp/build.log

This is the build log of sage-10.2
Comment 2 François Bissey 2024-01-30 22:05:38 UTC
Thanks Mark-Joe for the report. I must say I have been unable to reproduce the error so far. I will confess that I have not done a build with python 3.10 in ages and it is not even on my current Gentoo systems anymore.

For now, my leading theory is that building with 3.10 has issues, and I may just drop it if it is confirmed. 

Does the build succeed with python 3.11?
Which version of cython do you have installed?
Comment 3 François Bissey 2024-02-02 06:46:29 UTC
I could successfully build sage in a gentoo container with python 3.10 from scratch. So I suspect there is something else going on in your environment.
Comment 4 Mark-Joe 2024-02-02 23:08:54 UTC
I switched to python 3.11 and then from cython 3.0.6 to cython 3.0.8
Every time compilation failed with the error

Cython.Compiler.Errors.CompileError: sage/algebras/fusion_rings/shm_managers.pyx

What else could I try?
Comment 5 François Bissey 2024-02-03 00:21:15 UTC
Error compiling Cython file:
------------------------------------------------------------
...
from cysignals.memory cimport sig_malloc
from multiprocessing import shared_memory
from sage.algebras.fusion_rings.poly_tup_engine cimport poly_to_tup, tup_fixes_sq, _flatten_coeffs
from sage.rings.integer cimport Integer
from sage.rings.rational cimport Rational
from sage.rings.polynomial.multi_polynomial cimport MPolynomial_libsingular
^
------------------------------------------------------------

sage/algebras/fusion_rings/shm_managers.pyx:25:0: 'sage/rings/polynomial/multi_polynomial/MPolynomial_libsingular.pxd' not found

Error compiling Cython file:
------------------------------------------------------------
...
        else:
            self.fvars = np.ndarray((self.ngens, ), dtype=self.fvars_t)
            self.child_id = 0
        # Populate with initialziation data
        for sextuple, fvar in init_data.items():
            if isinstance(fvar, MPolynomial_libsingular):
                                ^
------------------------------------------------------------

sage/algebras/fusion_rings/shm_managers.pyx:505:32: 'MPolynomial_libsingular' is not a constant, variable or function identifier
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1350, in cythonize_one_helper
    return cythonize_one(*m)
  File "/usr/lib/python3.10/site-packages/Cython/Build/Dependencies.py", line 1326, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: sage/algebras/fusion_rings/shm_managers.pyx


This is very strange. Why does it look for sage/rings/polynomial/multi_polynomial/MPolynomial_libsingular.pxd which does not exist? The definition is available in sage/rings/polynomial/multi_polynomial.p{xd,yx}.

You do not happen to have some special cython flags setup globally? I do not know what that would look like but it is the only thing I can think of.

One thing that could be tried is change the failing "from" import to
from sage.rings.polynomial.multi_polynomial_libsingular cimport MPolynomial_libsingular

I could give you a patch to try.
Comment 6 François Bissey 2024-02-03 00:28:33 UTC
Also, is this your first time building sage or did you have success building it before?
Comment 7 Mark-Joe 2024-02-03 23:24:13 UTC
Thanks, looking into the previous installation of sage was helpful. I had sage 9.8 installed and wanted to upgrade. As long as sage 9.8 was still existing on my PC, I could not compile sage 10.2. After uninstalling sage 9.8 and python 3.10 I could compile sage 10.2. 

Unfortunately, sage 10.2 does not work fully, yet, though. When I run it in a terminal, I get the following:

SageMath version 10.2, Release Date: 2023-12-03                    │
│ Using Python 3.12.1. Type "help()" for help.   

Warning: sage.all is not available; this is a limited REPL.   


I am wondering what to do to make the warning disappear and have sage.all available.
Comment 8 François Bissey 2024-02-03 23:47:21 UTC
I see, the old install was in the way. I may have to look into putting hard blockers on older versions of sage to force cleaning before install.

Can you check you have the same problem when running sage with other python?
Like

EPYTHON=python3.11 sage

for example?
Comment 9 Mark-Joe 2024-02-04 01:31:12 UTC
Thanks. I tried 

EPYTHON=python3.11 sage 

but it gives the same warning that sage.all is missing.
Comment 10 Mark-Joe 2024-02-04 01:32:20 UTC
I try to reinstall all python packages needed for sage, like numpy, etc. and see whether that helps.
Comment 11 François Bissey 2024-02-04 02:01:56 UTC
If that does not fix it, can you send the result of 
equery f sage

equery should be in gentoolkit if you do not have it installed.
Comment 12 Mark-Joe 2024-02-04 02:38:27 UTC
Created attachment 884160 [details]
output of "equery f sage"

Reinstalling the python packages for sage did not help. I attach the output from 

equery f sage 

Thanks
Comment 13 François Bissey 2024-02-04 02:59:51 UTC
OK, sage.all is definitely there. I also do not have an issue on my current stable machine. But I will do a rebuild just in case something changed since the last install.
Comment 14 François Bissey 2024-02-04 06:37:07 UTC
OK, I updated everything to make sure it was not a new behavior from ipython but no. I do not run into that problem. I am thinking there may be some settings in .sage or .ipython that are responsible.

So, let's see what happens when you run
sage --nodotsage
?
From the python shell type 
import sage
?
Same thing but from ipython rather than python?
Comment 15 Mark-Joe 2024-02-05 00:46:26 UTC
sage --nodotsage shows the same:
 
Warning: sage.all is not available; this is a limited REPL.     
The command 

import sage

in either the python or the ipython shell does not give a warning.

I try to recompile all scientific libraries and see what happens.
Comment 16 François Bissey 2024-02-05 01:00:04 UTC
I am fairly sure that's a waste of time. I'll try to dig the error code to see if I can find a clue.
Comment 17 François Bissey 2024-02-05 01:08:40 UTC
It was easier to find than I expected. It is coming from sage/misc/banner.py. It should only happen if an import of sage.all does fail.

Can you start sage with
SAGE_BANNER="no" sage

and then try
import sage.all
Comment 18 François Bissey 2024-02-05 01:19:50 UTC
Just digged around sage's start up scripts.
Basically sage is started from python and the first python commands are

from sage.misc.banner import banner
banner()

and the message comes from banner_text which is called by banner(). What does it says when run from python directly?
Comment 19 Mark-Joe 2024-02-06 14:39:39 UTC
Under ipython and python I tried

from sage.misc.banner import banner
banner()


and always got the warning "sage.all is not available" back. Calling

import sage.all

results in the following:

ImportError: /usr/lib/python3.12/site-packages/sage/matrix/matrix_modn_dense_float.cpython-312-x86_64-linux-gnu.so: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev


Under some google group 
https://groups.google.com/g/sage-support/c/we-BvSt6WRk
I found that that indicates a linking error and that probably files from some old sage installation are picked up. That is also my impression but I can't figure out which files/libraries these are. I removed the old sage 9.8 but it seems some stuff is still there. 

On another machine with a rather new gentoo installation and no old sage installation I could install sage 10.2 without any problem.
Comment 20 Mark-Joe 2024-02-07 15:18:34 UTC
After having recompiled gcc-12, deleted old instances of gcc and after recompilation of all packages needed for sage  with gcc-12 it now works. 
There is no warning about a missing sage.all 

I could not figure out exactly what the reason was, but there was some indication that it could have to do with an old libstdc++ .

Thanks for the help.
Comment 21 François Bissey 2024-02-08 20:02:20 UTC
I meant to answer earlier but I am at a conference and quite busy. From the output, the faulty package would have been givaro (and yes it is C++ and a change of C++ abi causing that kind of error is not a first).
In the case of givaro it is part of a stack that needs to be rebuild together:
givaro/fflas-ffpack/linbox.