1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 mpi4py,
7 pytest,
8 pytestCheckHook,
9 mpiCheckPhaseHook,
10}:
11
12buildPythonPackage rec {
13 pname = "mpi-pytest";
14 version = "2025.4.0";
15 pyproject = true;
16
17 src = fetchFromGitHub {
18 owner = "firedrakeproject";
19 repo = "mpi-pytest";
20 tag = "v${version}";
21 hash = "sha256-r9UB5H+qAJc6k2SVAiOCI2yRDLNv2zKRmfrAan+cX9I=";
22 };
23
24 # A temporary fixup to support fork mode with openmpi implemention
25 # See https://github.com/firedrakeproject/mpi-pytest/pull/17
26 postPatch = lib.optionalString (mpi4py.mpi.pname == "openmpi") ''
27 substituteInPlace pytest_mpi/plugin.py \
28 --replace-fail '"-genv", CHILD_PROCESS_FLAG, "1"' '"-x", f"{CHILD_PROCESS_FLAG}=1"'
29 '';
30
31 build-system = [
32 setuptools
33 ];
34
35 dependencies = [
36 mpi4py
37 pytest
38 ];
39
40 pythonImportsCheck = [
41 "pytest_mpi"
42 ];
43
44 nativeCheckInputs = [
45 pytestCheckHook
46 mpiCheckPhaseHook
47 mpi4py.mpi
48 ];
49
50 __darwinAllowLocalNetworking = true;
51
52 meta = {
53 homepage = "https://github.com/firedrakeproject/mpi-pytest";
54 description = "Pytest plugin that lets you run tests in parallel with MPI";
55 changelog = "https://github.com/firedrakeproject/mpi-pytest/releases/tag/${src.tag}";
56 license = lib.licenses.gpl3Only;
57 maintainers = with lib.maintainers; [ qbisi ];
58 };
59}