1{ lib
2, stdenv
3, buildPythonPackage
4, python
5, numba
6, ndtypes
7, xnd
8, libndtypes
9, libxnd
10, libgumath
11, isPy27
12}:
13
14buildPythonPackage {
15 pname = "gumath";
16 disabled = isPy27;
17 inherit (libgumath) src version meta;
18
19 checkInputs = [ numba ];
20 propagatedBuildInputs = [ ndtypes xnd ];
21
22 postPatch = ''
23 substituteInPlace setup.py \
24 --replace 'add_include_dirs = [".", "libgumath", "ndtypes/python/ndtypes", "xnd/python/xnd"] + INCLUDES' \
25 'add_include_dirs = [".", "${libndtypes}/include", "${libxnd}/include", "${libgumath}/include"]' \
26 --replace 'add_library_dirs = ["libgumath", "ndtypes/libndtypes", "xnd/libxnd"] + LIBS' \
27 'add_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]' \
28 --replace 'add_runtime_library_dirs = ["$ORIGIN"]' \
29 'add_runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]'
30 '';
31
32 postInstall = lib.optionalString stdenv.isDarwin ''
33 install_name_tool -add_rpath ${libgumath}/lib $out/${python.sitePackages}/gumath/_gumath.*.so
34 '';
35
36 checkPhase = ''
37 pushd python
38 mv gumath _gumath
39 # minor precision issues
40 substituteInPlace test_gumath.py --replace 'test_sin' 'dont_test_sin'
41 python test_gumath.py
42 python test_xndarray.py
43 popd
44 '';
45
46}
47