1{ lib
2, stdenv
3, buildPythonPackage
4, fetchFromGitHub
5, pythonOlder
6, mpmath
7, numpy
8, pybind11
9, pyfma
10, eigen
11, importlib-metadata
12, pytestCheckHook
13, matplotlib
14, dufte
15, perfplot
16}:
17
18buildPythonPackage rec {
19 pname = "accupy";
20 version = "0.3.6";
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "nschloe";
25 repo = pname;
26 rev = version;
27 sha256 = "0sxkwpp2xy2jgakhdxr4nh1cspqv8l89kz6s832h05pbpyc0n767";
28 };
29
30 nativeBuildInputs = [
31 pybind11
32 ];
33
34 buildInputs = [
35 eigen
36 ];
37
38 propagatedBuildInputs = [
39 mpmath
40 numpy
41 pyfma
42 ] ++ lib.optional (pythonOlder "3.8") importlib-metadata;
43
44 nativeCheckInputs = [
45 perfplot
46 pytestCheckHook
47 matplotlib
48 dufte
49 ];
50
51 postConfigure = ''
52 substituteInPlace setup.py \
53 --replace "/usr/include/eigen3/" "${eigen}/include/eigen3/"
54 '';
55
56 preBuild = ''
57 export HOME=$(mktemp -d)
58 '';
59
60 # This variable is needed to suppress the "Trace/BPT trap: 5" error in Darwin's checkPhase.
61 # Not sure of the details, but we can avoid it by changing the matplotlib backend during testing.
62 env.MPLBACKEND = lib.optionalString stdenv.isDarwin "Agg";
63
64 # performance tests aren't useful to us and disabling them allows us to
65 # decouple ourselves from an unnecessary build dep
66 preCheck = ''
67 for f in test/test*.py ; do
68 substituteInPlace $f --replace 'import perfplot' ""
69 done
70 '';
71 disabledTests = [ "test_speed_comparison1" "test_speed_comparison2" ];
72 pythonImportsCheck = [ "accupy" ];
73
74 meta = with lib; {
75 description = "Accurate sums and dot products for Python";
76 homepage = "https://github.com/nschloe/accupy";
77 license = licenses.mit;
78 maintainers = [ ];
79 };
80}