Skip to content

add python-mumps recipe #3152

Draft
williampiat3 wants to merge 4 commits intospack:developfrom
williampiat3:develop
Draft

add python-mumps recipe #3152
williampiat3 wants to merge 4 commits intospack:developfrom
williampiat3:develop

Conversation

@williampiat3
Copy link
Contributor

No description provided.

@williampiat3
Copy link
Contributor Author

this is the missing recipe for using python-mumps in our spack workflows

@jcortial-safran
Copy link
Contributor

I use https://people.freedesktop.org/~dbn/pkg-config-guide.html as reference.

A couple remarks:

  • The generated files are weirdly formatted
  • It should be possible to factor them better using ${prefix} and ${exec-prefix} to define includedir and libdir
  • Only trivial information is included in the generated file. For instance, no flags relative to dependencies (such as scotch) are added. Is this actually useful ?

@williampiat3
Copy link
Contributor Author

williampiat3 commented Jan 28, 2026

Thank you for your remarks, for context I tried to replicate the pkg_config in the conda recipe (https://github.com/conda-forge/mumps-feedstock/blob/main/recipe/make_pkg_config.py) This reference may be plagued with the same issues that you are raising, thus:

  • I changed the description of the pkg_config to include all orderings compiled in the spec
  • I changed the includedir and libdir as requested
  • I am not sure if adding flags to dependencies is useful, as far as my testing goes I haven't felt it was needed. But I am not an expert.

These pkg_config files are necessary for the MesonBuilder to detect MUMPS: meson detects packages using pkg_config files

@williampiat3 williampiat3 force-pushed the develop branch 2 times, most recently from 46b0d72 to 1848fee Compare February 1, 2026 16:29
@tldahlgren tldahlgren added the question Further information is requested label Feb 24, 2026
Copy link
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments for missing copyright, dependency constraints, and questions.

"""Python wrapper for the MUMPS solver (python_mumps)."""

homepage = "https://gitlab.kwant-project.org/kwant/python-mumps"
url = "https://pypi.org/packages/source/p/python-mumps/python_mumps-0.0.6.tar.gz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why specify the URL instead of using the pypi property (https://spack.readthedocs.io/en/latest/build_systems/pythonpackage.html#id2)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines 23 to 28
depends_on("meson")
depends_on("ninja")
depends_on("py-meson-python")
depends_on("py-setuptools")
depends_on("py-setuptools-scm")
depends_on("py-cython")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://gitlab.kwant-project.org/kwant/python-mumps/-/blob/v0.0.6/pyproject.toml?ref_type=tags, half of these need lower bounds:

Suggested change
depends_on("meson")
depends_on("ninja")
depends_on("py-meson-python")
depends_on("py-setuptools")
depends_on("py-setuptools-scm")
depends_on("py-cython")
depends_on("meson@1.8:")
depends_on("ninja")
depends_on("py-meson-python@0.18:")
depends_on("py-setuptools")
depends_on("py-setuptools-scm")
depends_on("py-cython@3.1.1:")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do the dependencies on py-setuptools and ninja come from? The former is a dependency of py-setuptools-scm but I'm not seeing the latter except as a pixi dependency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ninja is a meson builder dependency, see discussion below about MesonPackage


variant("mpi", default=True, description="Whether to have MPI support on python-mumps or not")

# build dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a dependency on python@3.12: however it may be a little bit too restrictive (see discussions here: conda-forge/python-mumps-feedstock#30). In a few words, python@3.10: are working therefore I will add python@3.10: rather than python@3.12:

with default_args(type=("build", "run")):
depends_on("py-numpy")
depends_on("py-mpi4py", when="+mpi")
depends_on("py-scipy")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the numpy dependency should be py-numpy@2: and scipy should be py-scipy@1.13:. See https://gitlab.kwant-project.org/kwant/python-mumps/-/blob/v0.0.6/pyproject.toml?ref_type=tags#L31.

Where is py-mpi4py coming from? If it's from the pixi dependency, then it is also constrained to py-mpi4py@4.1:4 along with a couple of others above it in https://gitlab.kwant-project.org/kwant/python-mumps/-/blob/v0.0.6/pyproject.toml?ref_type=tags#L135.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpi4py comes from the variant when mumps is built using MPI. python-mumps provides an interface for mumps compiled with MPI. The couple of others you are referring to are conda-dependent packages and are not applicable here

from spack.package import *


class PyPythonMumps(PythonPackage):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the dependencies on meson, should this inherit from MesonPackage instead (https://spack.readthedocs.io/en/latest/build_systems/mesonpackage.html)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used the PythonPackage inheritance naively because this is a python package and I thought this was the only option in that case.
I thought about inheriting from both MesonPackage and PythonPackage. However they both have an install phase. Not knowing what would be the outcome and to avoid having the hassle of handling the double inheritance I used directly the MesonBuilder within the recipe since only the setup phase from the MesonBuilder is needed.
I am open to suggestions on how to make it either a MesonPackage or a MesonPackage,PythonPackage, but I would like to keep the recipe as simple as possible

@tldahlgren tldahlgren self-assigned this Feb 24, 2026
@williampiat3
Copy link
Contributor Author

After a discussion with @jcortial-safran, the upcoming Mumps version should provide pkgconfig files directly without the need of creating them within the spack install. Therefore I will mark this PR as a draft since python-mumps is not about having all versions available but rather having mumps functionnalities in python.
Nonetheless, all your remarks @tldahlgren are still relevant since they refer to python-mumps config only and I do want to make this available via spack.

williampiat3 and others added 4 commits February 28, 2026 18:42
Co-authored-by: Tamara Dahlgren <35777542+tldahlgren@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants