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