1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 cython,
6 setuptools,
7 mpi,
8 toPythonModule,
9 pytestCheckHook,
10 mpiCheckPhaseHook,
11}:
12
13buildPythonPackage rec {
14 pname = "mpi4py";
15 version = "4.1.0";
16 pyproject = true;
17
18 src = fetchFromGitHub {
19 repo = "mpi4py";
20 owner = "mpi4py";
21 tag = version;
22 hash = "sha256-Hm+x79utOrjAbprud2MECgakyOzgShSwNuoyZUcTluQ=";
23 };
24
25 build-system = [
26 cython
27 setuptools
28 ];
29
30 nativeBuildInputs = [
31 mpi
32 ];
33
34 dependencies = [
35 # Use toPythonModule so that also the mpi executables will be propagated to
36 # generated Python environment.
37 (toPythonModule mpi)
38 ];
39
40 pythonImportsCheck = [ "mpi4py" ];
41
42 nativeCheckInputs = [
43 pytestCheckHook
44 mpiCheckPhaseHook
45 ];
46 disabledTestPaths = lib.optionals (mpi.pname == "mpich") [
47 # These tests from some reason cause pytest to crash, and therefor it is
48 # hard to debug them. Upstream mentions these tests to raise issues in
49 # https://github.com/mpi4py/mpi4py/issues/418 but the workaround suggested
50 # there (setting MPI4PY_RC_RECV_MPROBE=0) doesn't work.
51 "test/test_util_pool.py"
52 "demo/futures/test_futures.py"
53 ];
54
55 __darwinAllowLocalNetworking = true;
56
57 # skip spawn related tests for openmpi implemention
58 # see https://github.com/mpi4py/mpi4py/issues/545#issuecomment-2343011460
59 env.MPI4PY_TEST_SPAWN = if mpi.pname == "openmpi" then 0 else 1;
60
61 passthru = {
62 inherit mpi;
63 };
64
65 meta = {
66 description = "Python bindings for the Message Passing Interface standard";
67 homepage = "https://github.com/mpi4py/mpi4py";
68 changelog = "https://github.com/mpi4py/mpi4py/blob/${src.tag}/CHANGES.rst";
69 license = lib.licenses.bsd2;
70 maintainers = with lib.maintainers; [ doronbehar ];
71 };
72}