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