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