Repository navigation
Add a meson-python build: the Fortran solvers back on Python 3.12, bit-identical on 3.11 - #136
Open
hubertus65 wants to merge 3 commits into
Open
hubertus65 wants to merge 3 commits into
hubertus65 wants to merge 3 commits into
Conversation
…the numpy.distutils build) setup.py builds the Fortran solvers (Dopri5, RodasODE, Radau5/Radar5 Fortran, LSODAR, ODASSL, DASP3, GLIMDA) only when numpy.distutils imports, which is gone on Python >= 3.12 and broken by setuptools >= 70; the conda-forge package already ships without them. This adds a meson-python build next to setup.py (setup.py is unchanged and still works on Python 3.11): - meson.build / meson.options: options sundials-home, superlu-home, blas-home, lapack-home, fortran (feature), extra-fortran-flags; SUNDIALS version, index size, SuperLU_MT and rtol-vector support are read from sundials_config.h (tools/sundials_config.py) into Cython's compile-time environment exactly as setup.py does. - Cython: tools/cythonize_one.py drives Cython (a version tuple cannot be passed on cython's command line); build-support/ mirrors the sources under the package name in the build tree so that "from assimulo.ode cimport ODE" resolves and each module is compiled as assimulo.<name>, as setup.py's copy to build/assimulo/ did. - f2py: tools/f2py_generate.py runs f2py on each .pyf and creates the wrapper files meson expects when f2py does not emit them; fortranobject.c comes from numpy. DASP3 gets -fdefault-double-8 -fdefault-real-8, GLIMDA links BLAS/LAPACK, Radau5 (C) links SuperLU_MT when given. - Compiler flags match the numpy.distutils build (C: -O2 -fno-strict-aliasing -fwrapv -fno-merge-constants -msse -msse2 -msse3; Fortran: -O3 -funroll-loops -fno-second-underscore --std=legacy), so the numerics are the same: tools/dump_examples.py dumps the trajectories and statistics of all 45 examples, and tests/test_build_equivalence.py (env ASSIMULO_REFERENCE_RESULTS) compares two builds. On Linux/gcc 13 with conda-forge SUNDIALS 7.8 and SuperLU_MT all 136 arrays and statistics are bit-identical between the two builds; pytest: 330 passed, 5 skipped with either. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p
…without a symlink shim Verified on Python 3.12.14 (conda-forge gcc/gfortran, SUNDIALS 7.8): 330 tests pass and all 45 examples are bit-identical to the Python 3.11 numpy.distutils build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p
…ts in plain SuperLU) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p
Author
|
You can ping me at my email hubertus dot tummescheit at modelbased dot cloud if you want to know the background. The basic idea was that I wanted to do a thorough benchmark against the Julia solvers from diffeq.jl. The "good" news is: most of them suck. And the FMI infrastructure sucks too. This was just a necessary prep step, but it allows to use Python > 3.11 for Assimulo, whcih I think is useful no matter what. |
hubertus65
marked this pull request as ready for review
September 22, 2026 21:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
setup.pybuilds the f2py-wrapped Fortran solvers —Dopri5,RodasODE,Radau5ODE/Radar5ODE(Fortran),
LSODAR,ODASSL,DASP3ODE,GLIMDA— only whennumpy.distutilsimports(
have_nd), and drops them silently otherwise.numpy.distutilsis gone on Python ≥ 3.12 andbroken by
setuptools≥ 70, so on a current interpreter Assimulo builds with the SUNDIALS and Csolvers only. The conda-forge 3.8.0 package already ships that way.
Change
A
meson-pythonbuild next tosetup.py(three commits).setup.pyis not touched and stillworks on Python 3.11 — this adds a second, supported way to build, it does not replace the first.
meson.build/meson.options: optionssundials-home,superlu-home,blas-home,lapack-home,fortran(feature),extra-fortran-flags. The SUNDIALS version, index size,SuperLU_MT and rtol-vector support are read from
sundials_config.h(
tools/sundials_config.py) into Cython's compile-time environment exactly assetup.pydoes.tools/cythonize_one.pydrives Cython (a version tuple cannot be passed on Cython'scommand line);
build-support/mirrors the sources under the package name in the build tree sofrom assimulo.ode cimport ODEresolves and each module compiles asassimulo.<name>, assetup.py's copy intobuild/assimulo/did.tools/f2py_generate.pyruns f2py on each.pyfand creates the wrapper files mesonexpects when f2py does not emit them;
fortranobject.ccomes from numpy. DASP3 gets-fdefault-double-8 -fdefault-real-8, GLIMDA links BLAS/LAPACK, Radau5 (C) links SuperLU_MTwhen given.
include/superlu_mt/) without the symlink shimsetup.pyneeds, and is identified byslu_mt_ddefs.hrather thansupermatrix.h, whichplain SuperLU also ships.
Equivalence, and the test that asserts it
Compiler flags match the
numpy.distutilsbuild (C:-O2 -fno-strict-aliasing -fwrapv -fno-merge-constants -msse -msse2 -msse3; Fortran:-O3 -funroll-loops -fno-second-underscore --std=legacy), so the numerics are the same rather than merely close.tools/dump_examples.pydumps the trajectories and statistics of all 45 examples;tests/test_build_equivalence.py(envASSIMULO_REFERENCE_RESULTS) compares two builds.numpy.distutilsbuildpytest testsunder either build, 3.11numpy.distutilsreference — i.e. the Fortran solvers are back on 3.12Review notes
thirdparty/is changed.🤖 Generated with Claude Code
https://claude.ai/code/session_01PyrxGeWuwCmAH9LishMW6p