summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/ndtypes/default.nix
blob: 21b13ffee6828e017006c2d0af898e36a40a7a9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{
  lib,
  stdenv,
  buildPythonPackage,
  python,
  numpy,
  libndtypes,
  isPy27,
}:

buildPythonPackage {
  pname = "ndtypes";
  format = "setuptools";
  disabled = isPy27;
  inherit (libndtypes) version src meta;

  outputs = [
    "out"
    "dev"
  ];

  propagatedBuildInputs = [ numpy ];

  postPatch = ''
    substituteInPlace setup.py \
      --replace 'include_dirs = ["libndtypes"]' \
                'include_dirs = ["${libndtypes.dev}/include"]' \
      --replace 'library_dirs = ["libndtypes"]' \
                'library_dirs = ["${libndtypes}/lib"]' \
      --replace 'runtime_library_dirs = ["$ORIGIN"]' \
                'runtime_library_dirs = ["${libndtypes}/lib"]'
  '';

  postInstall = ''
    mkdir $out/include
    cp python/ndtypes/*.h $out/include
  ''
  + lib.optionalString stdenv.hostPlatform.isDarwin ''
    install_name_tool -add_rpath ${libndtypes}/lib $out/${python.sitePackages}/ndtypes/_ndtypes.*.so
  '';

  checkPhase = ''
    pushd python
    mv ndtypes _ndtypes
    python test_ndtypes.py
    popd
  '';
}