# python-mumps -- the Python binding for MUMPS, the multifrontal sparse direct # solver. From the Kwant project, not to be confused with MUMPS itself (which # Fedora already ships as MUMPS 5.7.3). # # Why it is here: simnibs/simulation/fem.py does `import mumps` at module # scope, so without it `import simnibs` fails outright -- the FEM solver is # the core of SimNIBS, not an optional extra. This was the second missing # runtime dependency found while making simnibs work out of the box (the # first was python-cortech). %global pypi_name python-mumps %global mod_name mumps Name: python-mumps Version: 0.0.6 Release: 1%{?dist} Summary: Python bindings for the MUMPS sparse direct solver # LICENSE, BSD 2-Clause, "Copyright (c) 2018 Python-MUMPS Authors". # pyproject.toml also declares license: 'BSD-2-Clause' in the meson project(). License: BSD-2-Clause URL: https://gitlab.kwant-project.org/kwant/python-mumps Source0: %{pypi_source python_mumps %{version} tar.gz} # meson.build resolves MUMPS through pkg-config only, and Fedora's MUMPS ships # no .pc files, so the build aborts although the library is installed. Adds a # cc.find_library() fallback plus the mumps_common/pord/mpiseq pieces that # pkg-config would have pulled in transitively. Patch0: python-mumps-find-library-fallback.patch # Fedora's MUMPS is built for these; ExclusiveArch rather than BuildArch, # which rpmlint rightly flags as the wrong tag for restricting architectures. ExclusiveArch: x86_64 aarch64 BuildRequires: gcc BuildRequires: python3-devel BuildRequires: python3-Cython >= 3.1.1 BuildRequires: python3-numpy >= 2.0 BuildRequires: python3-scipy BuildRequires: python3-setuptools_scm BuildRequires: pyproject-rpm-macros BuildRequires: python3-meson-python BuildRequires: meson >= 1.1.0 BuildRequires: ninja-build BuildRequires: MUMPS-devel BuildRequires: openblas-devel BuildRequires: python3-pytest %global _description %{expand: Python bindings and a scipy-friendly interface to MUMPS, the MUltifrontal Massively Parallel sparse direct Solver. MUMPS factorises large sparse matrices and is a good fit for the linear systems that come out of finite element discretisations, where iterative solvers struggle with ill-conditioning. This is the sequential build against Fedora's MUMPS.} %description %_description %package -n python3-%{mod_name} Summary: %{summary} Requires: MUMPS %description -n python3-%{mod_name} %_description %prep %autosetup -p1 -n python_mumps-%{version} # setuptools_scm derives the version from git metadata, which an sdist has # none of; meson calls it with check: true, so it fails the configure step. # Pin the version from the tarball instead. sed -i "s|version: run_command('python3', '-m', 'setuptools_scm', check: true).stdout().strip(),|version: '%{version}',|" \ meson.build %generate_buildrequires # meson-python cannot produce metadata before the build, so read the deps # from the [project] table instead (the -p flag). %pyproject_buildrequires -p %build %pyproject_wheel %install %pyproject_install %pyproject_save_files %{mod_name} %check %pyproject_check_import # An import proves it linked; solving proves it works. MUMPS is a numerical # library, so factorise a small system and check the answer. The API is # Context.factor/.solve -- the same calls SimNIBS's fem.py makes # (self.ctx = mumps.Context()) -- and the class documents complex support # only, so the test uses a complex matrix as upstream's own docstring does. PYTHONPATH=%{buildroot}%{python3_sitearch} %{python3} - <<'EOF' import numpy as np import scipy.sparse as sp import mumps A = sp.coo_array(np.array([[4.0, 1.0, 0.0], [1.0, 3.0, 1.0], [0.0, 1.0, 2.0]], dtype=complex)) x_exact = np.array([1.0, -2.0, 3.0], dtype=complex) b = A.toarray() @ x_exact ctx = mumps.Context() ctx.factor(A) x = ctx.solve(b) assert np.allclose(x, x_exact, rtol=1e-10, atol=1e-12), (x, x_exact) # One factorisation, several right-hand sides: the pattern a FEM solver uses. rhs2 = A.toarray() @ np.ones(3, dtype=complex) assert np.allclose(ctx.solve(rhs2), np.ones(3), rtol=1e-10, atol=1e-12) print("mumps: factor/solve agrees with the exact solution to 1e-10") EOF %files -n python3-%{mod_name} -f %{pyproject_files} %license LICENSE %doc README.md AUTHORS.md %changelog * Sat Sep 26 2026 Morgan Hough - 0.0.6-1 - Initial package. simnibs/simulation/fem.py imports it at module scope, so `import simnibs` cannot succeed without it. Patched to find Fedora's MUMPS, which ships no pkg-config files.