Updating DifferentialAlgebra (issue 13268)

80 views
Skip to first unread message

Brent W. Baccala

unread,
Mar 15, 2023, 9:56:32 PM3/15/23
to sage-devel
Hi -

I'm trying to get the DifferentialAlgebra package in issue 13268 running (it has a github branch that was imported from trac).

Last time I had it running was 9.0 (I think), and now I'm trying to build it on 9.8.

It seems to build fine, but can't access functions in the shared library that was built from upstream's C code.

It does this:

baccala@samsung:~/src/sage-rg$ ./sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.8, Release Date: 2023-02-11                     │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: import sage.calculus.DifferentialAlgebra
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In [1], line 1
----> 1 import sage.calculus.DifferentialAlgebra

ImportError: /home/baccala/src/sage-rg/src/sage/calculus/DifferentialAlgebra.cpython-311-x86_64-linux-gnu.so: undefined symbol: bmi_sage_is_constant
sage:


The function is cimported in DifferentialAlgebra.pyx:

cimport sage.libs.bmi_c as bmi_c

bmi_c.pxd is in src/sage/libs and contains lines like this:

cdef extern from "bmi.h":
    ...
    ctypedef bmi_balsa_object_string* ALGEB_string
    ALGEB_string bmi_sage_is_constant (
                char*, char*, ALGEB, char*, char*, ba0_int_p, ba0_int_p)


The symbol exists in a shared library in local/lib:

baccala@samsung:~/src/sage-rg$ ls -l local/lib/libbmi.so.0.0.0
-rwxr-xr-x 1 baccala baccala 973584 Mar 15 16:17 local/lib/libbmi.so.0.0.0
baccala@samsung:~/src/sage-rg$ nm local/lib/libbmi.so.0.0.0 | grep bmi_sage_is_constant
000000000000c140 T bmi_sage_is_constant


Any idea what needs to be done to access this shared library from Sage?

It may be related to something that changed since Sage 9.0.

Thanks for any help you can provide!

    agape
    brent

Matthias Koeppe

unread,
Mar 16, 2023, 4:07:02 AM3/16/23
to sage-devel
Looking at the branch I see a change to "src/module_list.py". This file is not a thing any more in Sage. See https://wiki.sagemath.org/ReleaseTours/sage-9.2#For_developers:_Changes_to_the_build_system_of_sagelib

Dima Pasechnik

unread,
Mar 16, 2023, 6:23:44 AM3/16/23
to sage-...@googlegroups.com
On Thu, Mar 16, 2023 at 8:07 AM Matthias Koeppe
<matthia...@gmail.com> wrote:
>
> Looking at the branch I see a change to "src/module_list.py". This file is not a thing any more in Sage. See https://wiki.sagemath.org/ReleaseTours/sage-9.2#For_developers:_Changes_to_the_build_system_of_sagelib

This is somewhat outdated, it seems. I've edited the links there to
point to sources on github, but there is nothing about sage-tdlib in
setup.py any more.
There is sagemath-tdlib in src/sage/misc/package_dir.py, etc...

probably it's best to be edited further not by me, but by someone who
knows details.
> --
> You received this message because you are subscribed to the Google Groups "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-devel/5363374f-dceb-4176-8e69-f1402d2cb8f2n%40googlegroups.com.

Brent W. Baccala

unread,
Mar 16, 2023, 4:10:47 PM3/16/23
to sage-devel
Thank you, Matthias and Dima, for those pointers.

Reading over that, it seems like it should just find the files on its own.  "src/module_list.py" was not replaced with anything other than improved logic to find Cython files.

How does it know which shared libraries to load?  It seems like that's where it's failing - not when it compiles the Cython, but when it tries to run it and call a function in the shared library.

    agape
    brent

Matthias Koeppe

unread,
Mar 16, 2023, 4:36:36 PM3/16/23
to sage-devel
Third paragraph in the linked article:
Some Cython modules need specific compiler and linker flags. Sage 9.2 has moved all of these flags from Extension options in src/module_list.py to distutils: directives in the individual .pyx source files, see #29706 and Cython documentation.

Brent W. Baccala

unread,
Mar 16, 2023, 9:38:45 PM3/16/23
to sage-devel
It's starting to make sense.  Looks like I need "distutils: libraries = bmi" at the beginning of bmi_c.pxd

I think it would be useful to have all of the distutils: directives documented in one place.

    agape
    brent

Matthias Koeppe

unread,
Mar 16, 2023, 9:43:49 PM3/16/23
to sage-devel
I agree - our developer guide (https://doc.sagemath.org/html/en/developer/coding_in_cython.html) does not explain any of this.
Reply all
Reply to author
Forward
0 new messages