Skip to content

Support pip install of PETSc/SLEPc; drop mpi4py from petsc extra#1362

Merged
Marius1311 merged 1 commit into
mainfrom
petsc-pip-install
Jun 9, 2026
Merged

Support pip install of PETSc/SLEPc; drop mpi4py from petsc extra#1362
Marius1311 merged 1 commit into
mainfrom
petsc-pip-install

Conversation

@Marius1311

Copy link
Copy Markdown
Collaborator

Changes

  • Drop mpi4py from the petsc extra (optional-dependencies.petsc = [ "petsc4py", "slepc4py" ]). pyGPCCA runs serially and never needs mpi4py; pinning it forced a system-MPI source build that made pip install "cellrank[petsc]" fail on any machine without a system MPI library (e.g. stock macOS, minimal Linux). Users who genuinely want a distributed MPI build can still install a system MPI and add mpi4py themselves.
  • Document the pip install path for PETSc/SLEPc in docs/installation.md: a new "PETSc and SLEPc (faster large-scale solvers)" subsection covering pip install "cellrank[petsc]", the from-source compilation caveat, and the C-only PETSC_CONFIGURE_OPTIONS recipe for systems without a Fortran/MPI toolchain.

Bug fixes

  • Correct the inaccurate "conda-only" framing. The docs previously called PETSc/SLEPc "conda-only packages" and implied conda was the only way to get them. They are pip-installable from PyPI sdists; the conda section is reframed as the pre-built, no-compilation option, cross-linked with the new pip instructions.

Context

petsc4py/slepc4py enable pyGPCCA's fast method='krylov' solver for macrostates and fate probabilities. Without them, pyGPCCA falls back to method='brandts', which densifies the transition matrix and emits warnings (Unable to import petsc4py or slepc4py ... / Densifying). conda ships prebuilt binaries, but pip-from-source is viable and only needs a C compiler — no Fortran or MPI — once mpi4py is out of the way.

Verified

  • petsc 3.25.2 + slepc 3.25.1 compile from PyPI sdists on macOS arm64 with a C compiler only, using PETSC_CONFIGURE_OPTIONS="--with-fc=0 --with-mpi=0 --with-debugging=0 --with-shared-libraries=1" (no Fortran, MPI, or system libs).
  • petsc4py/slepc4py import and report versions.
  • pyGPCCA GPCCA(..., method='krylov').optimize() runs under warnings.simplefilter('error') — i.e. the brandts/densify fallback is gone — without mpi4py installed.
  • cellrank[petsc] resolves to petsc/petsc4py/slepc/slepc4py with no mpi4py.
  • pre-commit passes on the changed files.

Notes for reviewers

  • The from-source build was validated on macOS arm64; the configure flags are platform-agnostic, but a Linux CI confirmation would be a nice follow-up. The Windows note in installation.md is intentionally unchanged (PETSc on Windows remains hard; WSL is still the recommendation).
  • No mpi4py is bundled anymore — if any downstream tooling assumed cellrank[petsc] pulled in mpi4py, that is the one behavior change here.

Related issues

Closes #

🤖 Generated with Claude Code

petsc4py/slepc4py give pyGPCCA the fast method='krylov' solver, but the
docs framed PETSc/SLEPc as conda-only and the `petsc` extra pinned
mpi4py — which forces a system-MPI source build and makes
`pip install cellrank[petsc]` fail on machines without MPI.

pyGPCCA runs serially, so mpi4py is unnecessary. Drop it from the extra
and document the pip path in installation.md, including the C-only
configure flags for systems without a Fortran/MPI toolchain, plus a note
for users who do want a distributed MPI build.

Verified: PETSc 3.25.2 + SLEPc 3.25.1 build from PyPI sdists with a C
compiler only (no Fortran/MPI), petsc4py/slepc4py import, and pyGPCCA's
method='krylov' runs warning-free; `cellrank[petsc]` resolves without
mpi4py.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Marius1311 Marius1311 merged commit 34c2f43 into main Jun 9, 2026
10 checks passed
@Marius1311 Marius1311 deleted the petsc-pip-install branch June 9, 2026 15:21
Marius1311 added a commit to quadbio/cellmapper that referenced this pull request Jun 9, 2026
* Delegate gpcca-fast petsc backend to cellrank[petsc]>=2.3.1

cellrank 2.3.1 ships an mpi4py-free [petsc] extra (scverse/cellrank#1362),
so the gpcca-fast group can pull petsc4py/slepc4py from cellrank instead
of hardcoding them — CellRank now owns that list.

slepc is kept explicit as a workaround: slepc4py's published sdist
metadata omits its runtime dependency on the `slepc` library package (it
is added dynamically at build time), so uv won't install slepc from
cellrank[petsc] alone and slepc4py fails to import ("Library not loaded:
libslepc"). petsc4py declares `petsc` correctly, so petsc needs no such
workaround.

Verified: full lock resolves cellrank 2.3.1 + petsc/petsc4py/slepc/
slepc4py with no mpi4py; slepc4py imports only when the explicit slepc is
present (confirmed both ways in a throwaway venv).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* Fill changelog PR number for #82

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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