sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.47k stars 487 forks source link

Cython cannot be compiled when SageMath is built but not installed #39062

Open user202729 opened 2 days ago

user202729 commented 2 days ago

Steps To Reproduce

I built SageMath using instruction in https://doc-release--sagemath.netlify.app/html/en/installation/meson .

Then run

sage: cython('from sage.structure.parent cimport Parent; print(Parent);', verbose=1)

It raises error saying the pxd file is not found.

Additional Information

The cause is

@cached_function
def _standard_libs_libdirs_incdirs_aliases():
    r"""
    Return the list of libraries and library directories.

    EXAMPLES::

        sage: from sage.misc.cython import _standard_libs_libdirs_incdirs_aliases
        sage: _standard_libs_libdirs_incdirs_aliases()
        (['mpfr', 'gmp', 'gmpxx', 'pari', ...],
         [...],
         [...],
         {...})
    """
    aliases = cython_aliases()
    standard_libs = [
        'mpfr', 'gmp', 'gmpxx', 'pari', 'm',
        'ec', 'gsl',
    ] + aliases["CBLAS_LIBRARIES"] + [
        'ntl']
    standard_libdirs = []
    if SAGE_LOCAL:
        standard_libdirs.append(os.path.join(SAGE_LOCAL, "lib"))
    standard_libdirs.extend(aliases["CBLAS_LIBDIR"] + aliases["NTL_LIBDIR"])
    standard_incdirs = sage_include_directories() + aliases["CBLAS_INCDIR"] + aliases["NTL_INCDIR"]
    return standard_libs, standard_libdirs, standard_incdirs, aliases

def sage_include_directories(use_sources=False):

cython() compilation will always call sage_include_directories with use_sources=False, even if the pxd files are not copied to installation directory by meson.

Environment

Checklist

tobiasdiez commented 1 day ago

What do you mean by building without installing sagemath using meson?

user202729 commented 1 day ago

Actually reading the instruction again, there's no separate install part.

Anyway I could just use ./sage — can you reproduce the issue i.e. compile cython with sage include header in your computer?

Note that if you also have a globally installed sage (e.g. Arch Linux's SageMath package installs /usr/lib/python3.12/site-packages/sage/algebras/clifford_algebra_element.pxd) then that one will be found instead.