1{ stdenv, fetchPypi, python, buildPythonPackage, mpi, openssh, isPy3k, isPyPy }:
2
3buildPythonPackage rec {
4 pname = "mpi4py";
5 version = "2.0.0";
6 name = "${pname}-${version}";
7
8 src = fetchPypi {
9 inherit pname version;
10 sha256 = "10fb01595rg17ycz08a23v24akm25d13srsy2rnixam7a5ca0hv5";
11 };
12
13 passthru = {
14 inherit mpi;
15 };
16
17 # Rename libm.so -> libm.so.6 in test
18 # See: https://bitbucket.org/mpi4py/mpi4py/issues/28/test_dltestdl-test-failure
19 patches = [
20 ./tests.patch
21 ];
22
23 # The tests in the `test_spawn` module fail in the chroot build environment.
24 # However, they do pass in a pure, or non-pure nix-shell. Hence, we
25 # deactivate these particular tests.
26 # Unfortunately, the command-line arguments to `./setup.py test` are not
27 # correctly passed to the test-runner. Hence, these arguments are patched
28 # directly into `setup.py`.
29 prePatch = ''
30 sed 's/err = main(cmd.args or \[\])/err = main(cmd.args or ["-v", "-e", "test_spawn"])/' -i setup.py
31 '';
32
33 configurePhase = "";
34
35 installPhase = ''
36 mkdir -p "$out/lib/${python.libPrefix}/site-packages"
37 export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
38
39 ${python}/bin/${python.executable} setup.py install \
40 --install-lib=$out/lib/${python.libPrefix}/site-packages \
41 --prefix="$out"
42
43 # --install-lib:
44 # sometimes packages specify where files should be installed outside the usual
45 # python lib prefix, we override that back so all infrastructure (setup hooks)
46 # work as expected
47 '';
48
49 setupPyBuildFlags = ["--mpicc=${mpi}/bin/mpicc"];
50
51 buildInputs = [ mpi ];
52 # Requires openssh for tests. Tests of dependent packages will also fail,
53 # if openssh is not present. E.g. h5py with mpi support.
54 propagatedBuildInputs = [ openssh ];
55
56 disabled = isPy3k || isPyPy;
57
58 # Timing out communicating between processes when sandboxing enabled.
59 doCheck = false;
60
61 meta = {
62 description =
63 "Python bindings for the Message Passing Interface standard";
64 homepage = http://code.google.com/p/mpi4py/;
65 license = stdenv.lib.licenses.bsd3;
66 };
67}