about summary refs log tree commit diff
path: root/pkgs/development/python-modules/tables/default.nix
blob: 34e9ef087a9b12ab5579e3444a81ed056d4e013b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{ lib
, fetchPypi
, fetchurl
, fetchpatch
, buildPythonPackage
, pythonOlder
, python
, bzip2
, c-blosc
, cython
, hdf5
, lzo
, numpy
, numexpr
, setuptools
  # Test inputs
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "tables";
  version = "3.6.1";
  disabled = pythonOlder "3.5";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0j8vnxh2m5n0cyk9z3ndcj5n1zj5rdxgc1gb78bqlyn2lyw75aa9";
  };

  nativeBuildInputs = [ cython ];

  buildInputs = [
    bzip2
    c-blosc
    hdf5
    lzo
  ];
  propagatedBuildInputs = [
    numpy
    numexpr
    setuptools  # uses pkg_resources at runtime
  ];

  patches = [
    (fetchpatch {
      # Needed for numpy >= 1.20.0
      name = "tables-pr-862-use-lowercase-numpy-dtypes.patch";
      url = "https://github.com/PyTables/PyTables/commit/93a3272b8fe754095637628b4d312400e24ae654.patch";
      sha256 = "00czgxnm1dxp9763va9xw1nc7dd7kxh9hjcg9klim52519hkbhi4";
    })
  ];
  # When doing `make distclean`, ignore docs
  postPatch = ''
    substituteInPlace Makefile --replace "src doc" "src"
    # Force test suite to error when unittest runner fails
    substituteInPlace tables/tests/test_suite.py \
      --replace "return 0" "assert result.wasSuccessful(); return 0" \
      --replace "return 1" "assert result.wasSuccessful(); return 1"
  '';

  # Regenerate C code with Cython
  preBuild = ''
    make distclean
  '';

  setupPyBuildFlags = [
    "--hdf5=${lib.getDev hdf5}"
    "--lzo=${lib.getDev lzo}"
    "--bzip2=${lib.getDev bzip2}"
    "--blosc=${lib.getDev c-blosc}"
  ];

  checkInputs = [ pytestCheckHook ];
  preCheck = ''
    cd ..
  '';
  # Runs the test suite as one single test via unittest. The whole "heavy" test suite supposedly takes ~5 hours to run.
  pytestFlagsArray = [
    "--pyargs"
    "tables.tests.test_suite"
  ];

  pythonImportsCheck = [ "tables" ];

  meta = with lib; {
    description = "Hierarchical datasets for Python";
    homepage = "https://www.pytables.org/";
    license = licenses.bsd2;
    maintainers = with maintainers; [ drewrisinger ];
  };
}