From e2467a1b37aaba37728b18c78d7dda614ea9a031 Mon Sep 17 00:00:00 2001 From: Ferran Brosa Planella Date: Sat, 31 Oct 2026 13:01:14 +0000 Subject: [PATCH 1/2] Build the solvers from PyBaMM main in the PyBaMM main job PyBaMM main holds the solvers too (packages/pybammsolvers), and their version is only bumped at a release, so the job took the PyPI wheel even when main needed newer solver code: every test failed once main called a solver function no release had. Check out PyBaMM main with its submodules and install both packages from it, as PyBaMM's own tests do. SUNDIALS and SuiteSparse, the slow part, are cached, keyed on the submodule pins and their build script. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/tests.yml | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 474d69c..8e31cf1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -102,15 +102,39 @@ jobs: continue-on-error: true steps: - uses: actions/checkout@v7 + # PyBaMM main is a uv workspace that also holds the solvers (packages/pybammsolvers). + # Their version is only bumped at a release, so the PyPI wheel cannot be told apart + # from main's source, which may need it (main called a solver function that no + # release had). So both are built from main's source, as PyBaMM's own tests do. + - uses: actions/checkout@v7 + with: + repository: pybamm-team/PyBaMM + ref: main + path: pybamm-main + submodules: recursive + persist-credentials: false - uses: astral-sh/setup-uv@v10.3.2 + # Building SUNDIALS and SuiteSparse takes most of the time. They are built into + # packages/pybammsolvers/.idaklu, which the solver module finds through an absolute + # RPATH, so that folder is cached, keyed on what it is built from: the submodule pins + # and the build script. On a cache hit only the solver module itself is compiled. + - name: Solver libraries cache key + id: solver-libraries + working-directory: pybamm-main/packages/pybammsolvers + run: >- + echo "key=idaklu-${{ runner.os }}-$(git rev-parse HEAD:./sundials + HEAD:./SuiteSparse HEAD:./install_KLU_Sundials.py | sha256sum | cut -c1-16)" + >> "$GITHUB_OUTPUT" + - uses: actions/cache@v6 + with: + path: pybamm-main/packages/pybammsolvers/.idaklu + key: ${{ steps.solver-libraries.outputs.key }} + # The compilers and BLAS that PyBaMM's tests install + - run: sudo apt-get update && sudo apt-get install -y gfortran libopenblas-dev - run: uv sync - # PyBaMM main is a uv workspace (packages/pybamm, packages/pybammsolvers, ...); install - # the pybamm package only. Its workspace source for pybammsolvers would compile the - # solvers (SuiteSparse, SUNDIALS, which need BLAS), so take pybammsolvers from PyPI - # instead. If main ever requires an unreleased pybammsolvers, build it with BLAS. - run: >- - uv pip install --no-sources-package pybammsolvers - "pybamm @ git+https://github.com/pybamm-team/PyBaMM.git@main#subdirectory=packages/pybamm" + uv pip install ./pybamm-main/packages/pybammsolvers + ./pybamm-main/packages/pybamm - run: uv run --no-sync pytest changelog: From 8f023e1b65fc90518032536dc3329507fb8e90cd Mon Sep 17 00:00:00 2001 From: Ferran Brosa Planella Date: Sat, 31 Oct 2026 13:11:38 +0000 Subject: [PATCH 2/2] Install the PyBaMM main packages without their workspace sources Through its workspace sources pybamm pulled in pybammsolvers as an editable install, which rebuilt itself with CMake on import, in an environment without pybind11. Install both without the sources, so the solvers are an ordinary install. Fetch PyBaMM's history (without file contents) so that pybamm gets its version from its tags. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/tests.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8e31cf1..0948be7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -112,6 +112,9 @@ jobs: ref: main path: pybamm-main submodules: recursive + # pybamm's version comes from its git tags: the history without file contents + fetch-depth: 0 + filter: blob:none persist-credentials: false - uses: astral-sh/setup-uv@v10.3.2 # Building SUNDIALS and SuiteSparse takes most of the time. They are built into @@ -132,8 +135,10 @@ jobs: # The compilers and BLAS that PyBaMM's tests install - run: sudo apt-get update && sudo apt-get install -y gfortran libopenblas-dev - run: uv sync + # Without the workspace sources: through them pybamm pulls in pybammsolvers as an + # editable install, which rebuilds itself on import, without its build tools - run: >- - uv pip install ./pybamm-main/packages/pybammsolvers + uv pip install --no-sources ./pybamm-main/packages/pybammsolvers ./pybamm-main/packages/pybamm - run: uv run --no-sync pytest