1{ stdenv, fetchPypi, fetchpatch, python, buildPythonPackage, mpi, openssh }:
2
3buildPythonPackage rec {
4 pname = "mpi4py";
5 version = "3.0.0";
6
7 src = fetchPypi {
8 inherit pname version;
9 sha256 = "1mzgd26dfv4vwbci8gq77ss9f0x26i9aqzq9b9vs9ndxhlnv0mxl";
10 };
11
12 passthru = {
13 inherit mpi;
14 };
15
16 patches = [
17 (fetchpatch {
18 # Disable tests failing with 3.1.x and MPI_THREAD_MULTIPLE (upstream patch)
19 url = "https://bitbucket.org/mpi4py/mpi4py/commits/c2b6b7e642a182f9b00a2b8e9db363214470548a/raw";
20 sha256 = "0n6bz3kj4vcqb6q7d0mlj5vl6apn7i2bvfc9mpg59vh3wy47119q";
21 })
22 (fetchpatch {
23 # Open MPI: Workaround removal of MPI_{LB|UB} (upstream patch)
24 url = "https://bitbucket.org/mpi4py/mpi4py/commits/39ca784226460f9e519507269ebb29635dc8bd90/raw";
25 sha256 = "02kxikdlsrlq8yr5hca42536mxbrq4k4j8nqv7p1p2r0q21a919q";
26 })
27
28 ];
29
30 postPatch = ''
31 substituteInPlace test/test_spawn.py --replace \
32 "unittest.skipMPI('openmpi(<3.0.0)')" \
33 "unittest.skipMPI('openmpi')"
34 '';
35
36 configurePhase = "";
37
38 installPhase = ''
39 mkdir -p "$out/lib/${python.libPrefix}/site-packages"
40 export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
41
42 ${python}/bin/${python.executable} setup.py install \
43 --install-lib=$out/lib/${python.libPrefix}/site-packages \
44 --prefix="$out"
45
46 # --install-lib:
47 # sometimes packages specify where files should be installed outside the usual
48 # python lib prefix, we override that back so all infrastructure (setup hooks)
49 # work as expected
50
51 # Needed to run the tests reliably. See:
52 # https://bitbucket.org/mpi4py/mpi4py/issues/87/multiple-test-errors-with-openmpi-30
53 export OMPI_MCA_rmaps_base_oversubscribe=yes
54 '';
55
56 setupPyBuildFlags = ["--mpicc=${mpi}/bin/mpicc"];
57
58 nativeBuildInputs = [ mpi openssh ];
59
60 meta = {
61 description =
62 "Python bindings for the Message Passing Interface standard";
63 homepage = http://code.google.com/p/mpi4py/;
64 license = stdenv.lib.licenses.bsd3;
65 };
66}