modelon-community / Assimulo

Assimulo is a simulation package for solving ordinary differential equations.
https://jmodelica.org/assimulo/index.html
GNU Lesser General Public License v3.0
70 stars 17 forks source link

Python 3.12: Fortran solvers not compiled #106

Open jmrohwer opened 5 months ago

jmrohwer commented 5 months ago

The latest release (3.5.2) compiles without error on Python 3.12, but the fortran based solvers are not compiled.

This is on Arch linux with SUNDIALS 6.7.0 and compilation per

python setup.py bdist_wheel --sundials-home=/usr --blas-home=/usr/lib --lapack-home=/usr/lib --extra-fortran-compile-flags="-fallow-argument-mismatch"

The wheel was installed manually afterwards in a Python 3.12 virtual environment.

Sundials-based solvers (e.g. CVODE) work without problem. Example of failing code:

➜ python dopri5_basic.py 
/home/jr/src/Assimulo-Assimulo-3.5.2/examples/dopri5_basic.py:42: SyntaxWarning: invalid escape sequence '\d'
  name = 'DOPRI5 Example: $\dot y = - y$')
Could not find cannot import name 'dopri5' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find cannot import name 'rodas' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find cannot import name 'odassl' from 'assimulo.lib' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib/__init__.py)
Could not find ODEPACK functions.
Could not find RADAR5
Could not find GLIMDA.
Traceback (most recent call last):
  File "/home/jr/src/Assimulo-Assimulo-3.5.2/examples/dopri5_basic.py", line 20, in <module>
    from assimulo.solvers import Dopri5
ImportError: cannot import name 'Dopri5' from 'assimulo.solvers' (/home/jr/.virtualenvs/pydev/lib/python3.12/site-packages/assimulo/solvers/__init__.py)
$ ls -l .virtualenvs/pydev/lib/python3.12/site-packages/assimulo/lib 
total 1048
drwxr-xr-x 1 jr jr     100 Jun 26 13:54 __pycache__
-rw-r--r-- 1 jr jr     687 Jun 26 13:54 __init__.py
-rwxr-xr-x 1 jr jr 1051464 Jun 26 13:54 radau5ode.cpython-312-x86_64-linux-gnu.so
-rw-r--r-- 1 jr jr   14112 Jun 26 13:54 radau_core.py

The Fortran-based .so files are missing.

PeterMeisrimelModelon commented 4 months ago

Hi jmrohwer,

this is a current limitation due to the deprecation of distutils in Python 3.12. This issue has not yet been solved for the Fortran based solvers.

If you want to use the Fortran based solvers, you need to stick to Python 3.11 for now.

/Peter