2021-02-05 17:12:51 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-09-25 04:45:31 +00:00
|
|
|
, buildPythonPackage
|
2023-10-09 19:29:22 +00:00
|
|
|
, fetchpatch
|
2020-09-25 04:45:31 +00:00
|
|
|
, python
|
2020-04-24 23:36:52 +00:00
|
|
|
, numba
|
|
|
|
, ndtypes
|
|
|
|
, xnd
|
|
|
|
, libndtypes
|
|
|
|
, libxnd
|
|
|
|
, libgumath
|
|
|
|
, isPy27
|
|
|
|
}:
|
|
|
|
|
|
|
|
buildPythonPackage {
|
|
|
|
pname = "gumath";
|
2023-10-09 19:29:22 +00:00
|
|
|
format = "setuptools";
|
2020-04-24 23:36:52 +00:00
|
|
|
disabled = isPy27;
|
|
|
|
inherit (libgumath) src version meta;
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
patches = [
|
|
|
|
# https://github.com/xnd-project/gumath/pull/42
|
|
|
|
(fetchpatch {
|
|
|
|
name = "remove-np-warnings-call.patch";
|
|
|
|
url = "https://github.com/xnd-project/gumath/commit/83ab3aa3b07d55654b4e6e75e5ec6be8190fca97.patch";
|
|
|
|
hash = "sha256-7lUXNVH5M+Go1iEu0bud03XI8cyGbdLNdLraMZplDaM=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
name = "remove-np-1.25-bartlett-test-assertion.patch";
|
|
|
|
url = "https://github.com/xnd-project/gumath/commit/8741e31f2967ded08c96a7f0631e1e38fe813870.patch";
|
|
|
|
hash = "sha256-flltk3RNPHalbcIV0BrkxWuhqqJBrycos7Fyv3P3mWg=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ numba ];
|
2023-10-09 19:29:22 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
propagatedBuildInputs = [ ndtypes xnd ];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace 'add_include_dirs = [".", "libgumath", "ndtypes/python/ndtypes", "xnd/python/xnd"] + INCLUDES' \
|
|
|
|
'add_include_dirs = [".", "${libndtypes}/include", "${libxnd}/include", "${libgumath}/include"]' \
|
|
|
|
--replace 'add_library_dirs = ["libgumath", "ndtypes/libndtypes", "xnd/libxnd"] + LIBS' \
|
|
|
|
'add_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]' \
|
|
|
|
--replace 'add_runtime_library_dirs = ["$ORIGIN"]' \
|
|
|
|
'add_runtime_library_dirs = ["${libndtypes}/lib", "${libxnd}/lib", "${libgumath}/lib"]'
|
|
|
|
'';
|
2020-09-25 04:45:31 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
postInstall = lib.optionalString stdenv.isDarwin ''
|
2020-09-25 04:45:31 +00:00
|
|
|
install_name_tool -add_rpath ${libgumath}/lib $out/${python.sitePackages}/gumath/_gumath.*.so
|
|
|
|
'';
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
pushd python
|
|
|
|
mv gumath _gumath
|
|
|
|
# minor precision issues
|
|
|
|
substituteInPlace test_gumath.py --replace 'test_sin' 'dont_test_sin'
|
|
|
|
python test_gumath.py
|
|
|
|
python test_xndarray.py
|
|
|
|
popd
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
2020-09-25 04:45:31 +00:00
|
|
|
|