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