1{ lib
2, stdenv
3, buildPythonPackage
4, fetchpatch
5, python
6, numba
7, ndtypes
8, xnd
9, libndtypes
10, libxnd
11, libgumath
12, isPy27
13}:
14
15buildPythonPackage {
16 pname = "gumath";
17 format = "setuptools";
18 disabled = isPy27;
19 inherit (libgumath) src version meta;
20
21 patches = [
22 # https://github.com/xnd-project/gumath/pull/42
23 (fetchpatch {
24 name = "remove-np-warnings-call.patch";
25 url = "https://github.com/xnd-project/gumath/commit/83ab3aa3b07d55654b4e6e75e5ec6be8190fca97.patch";
26 hash = "sha256-7lUXNVH5M+Go1iEu0bud03XI8cyGbdLNdLraMZplDaM=";
27 })
28 (fetchpatch {
29 name = "remove-np-1.25-bartlett-test-assertion.patch";
30 url = "https://github.com/xnd-project/gumath/commit/8741e31f2967ded08c96a7f0631e1e38fe813870.patch";
31 hash = "sha256-flltk3RNPHalbcIV0BrkxWuhqqJBrycos7Fyv3P3mWg=";
32 })
33 ];
34
35 nativeCheckInputs = [ numba ];
36
37 propagatedBuildInputs = [ ndtypes xnd ];
38
39 postPatch = ''
40 substituteInPlace setup.py \
41 --replace 'add_include_dirs = [".", "libgumath", "ndtypes/python/ndtypes", "xnd/python/xnd"] + INCLUDES' \
42 'add_include_dirs = [".", "${libndtypes.dev}/include", "${libxnd}/include", "${libgumath}/include"]' \
43 --replace 'add_library_dirs = ["libgumath", "ndtypes/libndtypes", "xnd/libxnd"] + LIBS' \
44 'add_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]' \
45 --replace 'add_runtime_library_dirs = ["$ORIGIN"]' \
46 'add_runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]'
47 '';
48
49 postInstall = lib.optionalString stdenv.isDarwin ''
50 install_name_tool -add_rpath ${libgumath}/lib $out/${python.sitePackages}/gumath/_gumath.*.so
51 '';
52
53 checkPhase = ''
54 pushd python
55 mv gumath _gumath
56 # minor precision issues
57 substituteInPlace test_gumath.py --replace 'test_sin' 'dont_test_sin'
58 python test_gumath.py
59 python test_xndarray.py
60 popd
61 '';
62}
63