Support pip install of PETSc/SLEPc; drop mpi4py from petsc extra#1362
Merged
Conversation
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>
This was referenced Jun 9, 2026
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>
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.
Changes
mpi4pyfrom thepetscextra (optional-dependencies.petsc = [ "petsc4py", "slepc4py" ]). pyGPCCA runs serially and never needsmpi4py; pinning it forced a system-MPI source build that madepip 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 addmpi4pythemselves.docs/installation.md: a new "PETSc and SLEPc (faster large-scale solvers)" subsection coveringpip install "cellrank[petsc]", the from-source compilation caveat, and the C-onlyPETSC_CONFIGURE_OPTIONSrecipe for systems without a Fortran/MPI toolchain.Bug fixes
Context
petsc4py/slepc4pyenable pyGPCCA's fastmethod='krylov'solver for macrostates and fate probabilities. Without them, pyGPCCA falls back tomethod='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 — oncempi4pyis out of the way.Verified
petsc3.25.2 +slepc3.25.1 compile from PyPI sdists on macOS arm64 with a C compiler only, usingPETSC_CONFIGURE_OPTIONS="--with-fc=0 --with-mpi=0 --with-debugging=0 --with-shared-libraries=1"(no Fortran, MPI, or system libs).petsc4py/slepc4pyimport and report versions.GPCCA(..., method='krylov').optimize()runs underwarnings.simplefilter('error')— i.e. thebrandts/densify fallback is gone — withoutmpi4pyinstalled.cellrank[petsc]resolves topetsc/petsc4py/slepc/slepc4pywith nompi4py.pre-commitpasses on the changed files.Notes for reviewers
installation.mdis intentionally unchanged (PETSc on Windows remains hard; WSL is still the recommendation).mpi4pyis bundled anymore — if any downstream tooling assumedcellrank[petsc]pulled inmpi4py, that is the one behavior change here.Related issues
Closes #
🤖 Generated with Claude Code