1{ lib
2, stdenv
3, buildPythonPackage
4, python
5, ndtypes
6, libndtypes
7, libxnd
8, isPy27
9}:
10
11buildPythonPackage {
12 pname = "xnd";
13 disabled = isPy27;
14 inherit (libxnd) version src meta;
15
16 propagatedBuildInputs = [ ndtypes ];
17
18 postPatch = ''
19 substituteInPlace setup.py \
20 --replace 'include_dirs = ["libxnd", "ndtypes/python/ndtypes"] + INCLUDES' \
21 'include_dirs = ["${libndtypes}/include", "${ndtypes}/include", "${libxnd}/include"]' \
22 --replace 'library_dirs = ["libxnd", "ndtypes/libndtypes"] + LIBS' \
23 'library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
24 --replace 'runtime_library_dirs = ["$ORIGIN"]' \
25 'runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib"]' \
26 '';
27
28 postInstall = ''
29 mkdir $out/include
30 cp python/xnd/*.h $out/include
31 '' + lib.optionalString stdenv.isDarwin ''
32 install_name_tool -add_rpath ${libxnd}/lib $out/${python.sitePackages}/xnd/_xnd.*.so
33 '';
34
35 checkPhase = ''
36 pushd python
37 mv xnd _xnd
38 python test_xnd.py
39 popd
40 '';
41}