Skip to content

Build with meson (meson-python) instead of setuptools + CMake - #49

Merged
spraharsh merged 7 commits into
masterfrom
meson-build
Sep 28, 2026
Merged

spraharsh merged 7 commits into
masterfrom
meson-build

Conversation

@spraharsh

Copy link
Copy Markdown
Collaborator

Replaces the setuptools + CMake build (setup.py, setup_with_cmake.py, CMakeLists.txt.in, cythonize.py, cpp_tests/source/CMakeLists.txt) with a single meson.build driven by meson-python, the build NumPy/SciPy use.

What changes

  • One build graph: pele_lib, the 37 Cython extensions (with .pxd dependency tracking) and the 16 f2py modules. No template file, no separate cythonize step, no copying libraries after the build.
  • C++ tests (GoogleTest) and benchmarks are built by the same meson.build, without Python:
    meson setup build-tests -Dpython=disabled -Dtests=true -Dbuildtype=debug
    meson test -C build-tests
    
  • Dependencies: SUNDIALS, Eigen and LAPACK come from the active conda env (or the system). The extern/sundials and extern/eigen submodules and extern/sun_inst.sh are removed. Extensions get an rpath to the env's lib, so conda's shared SUNDIALS is found at import.
  • LAPACK is required with CVODE: the mixed descent optimizers call dpotrf_/dpotrs_. A missing LAPACK now fails at configure time rather than at import.
  • Build options are meson options: PELE_BUILD_TYPE=Debug → -Csetup-args=-Dbuildtype=debug, PELE_WITH_CVODE=0 → -Dcvode=disabled, PELE_NATIVE=0 → -Dnative=false.
  • Development: pip install --no-build-isolation -e . gives an editable install that rebuilds changed C++/Cython/Fortran on the next import pele (only the affected targets).
  • Guards: configure stops with instructions if the C++ compiler is newer than the libstdc++ Python loads (previously an import-time CXXABI_x not found), or if clang is used on macOS (Homebrew gcc is needed for OpenMP and Fortran; setup.py used to pick it automatically).
  • CI, the conda recipe and the README are updated accordingly.

Testing

Not yet done

  • mcpele, PyCG_DESCENT and basinvolume still look for SUNDIALS in <pele>/extern/install; they need follow-up changes to use conda's SUNDIALS. Existing local extern/install directories keep working until then.

🤖 Generated with Claude Code

spraharsh and others added 6 commits September 27, 2026 17:20
meson.build compiles pele_lib, the Cython extensions (with .pxd dependency tracking) and the f2py modules in one ninja graph and installs the package, replacing setup.py, the CMakeLists.txt.in template and cythonize.py.

Options: -Dcvode=disabled (was PELE_WITH_CVODE=0), -Dnative=false (was PELE_NATIVE=0), -Dbuildtype=debug (was PELE_BUILD_TYPE=Debug), passed as pip -Csetup-args=....

Configure fails with a clear message when the C++ compiler is newer than the libstdc++ that Python loads, instead of the extensions failing at import with CXXABI_x not found.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cpp_tests/meson.build builds test_main (GoogleTest from the submodule, or the system one) and the benchmarks against the same pele_lib as the Python package, replacing the separate CMake project. The Python parts of meson.build are now optional:

  meson setup build -Dpython=disabled -Dtests=true -Dbuildtype=debug -Db_sanitize=address
  meson test -C build

Test output files now go to the build directory instead of the source tree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mixed descent optimizers call dpotrf_/dpotrs_. A missing LAPACK now fails at configure time instead of at import. Looks in extern/install and the conda env first, then pkg-config lapack or openblas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
C++ job: meson setup -Dpython=disabled -Dtests=true, meson test, lcov on the build dir. Python job: editable meson-python install for pytest/coverage on the source tree. macOS uses homebrew gcc-15 via CC/CXX/FC (setup.py used to pick it). PELE_NATIVE=0 becomes -Csetup-args=-Dnative=false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rn/install

Remove the extern/sundials and extern/eigen submodules and extern/sun_inst.sh. meson.build looks in $CONDA_PREFIX, then the system, and gives the extensions and C++ tests an rpath to the env's lib directory so its shared libraries (SUNDIALS, LAPACK) are found at import/run time.

CI creates a conda-forge env with sundials, eigen and blas-devel for both the C++ and Python parts. macOS jobs build with homebrew gcc-15 (setup.py used to pick it); meson.build now fails early with that advice when given clang on macOS.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

pele calls the Fortran LAPACK routines dpotrf_/dpotrs_ (liblapack) and never the LAPACKE_* C interface, so liblapacke is not linked. It does need lapack.h for their prototypes, which Debian/Ubuntu ship only in liblapacke-dev (conda: openblas, via blas-devel). meson.build now checks for it with that advice instead of failing mid-compile.

extended_mixed_descent.hpp includes lapack.h instead of lapacke.h; newton.cpp and newton_with_extension.cpp included lapacke.h without using it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@spraharsh
spraharsh merged commit 36a3d73 into master Sep 28, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant