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