1{ lib
2, fetchPypi
3, fetchpatch
4, buildPythonPackage
5, pythonOlder
6, bzip2
7, c-blosc
8, cython
9, hdf5
10, lzo
11, numpy
12, numexpr
13, setuptools
14 # Test inputs
15, pytestCheckHook
16}:
17
18buildPythonPackage rec {
19 pname = "tables";
20 version = "3.6.1";
21 disabled = pythonOlder "3.5";
22
23 src = fetchPypi {
24 inherit pname version;
25 sha256 = "0j8vnxh2m5n0cyk9z3ndcj5n1zj5rdxgc1gb78bqlyn2lyw75aa9";
26 };
27
28 nativeBuildInputs = [ cython ];
29
30 buildInputs = [
31 bzip2
32 c-blosc
33 hdf5
34 lzo
35 ];
36 propagatedBuildInputs = [
37 numpy
38 numexpr
39 setuptools # uses pkg_resources at runtime
40 ];
41
42 patches = [
43 (fetchpatch {
44 # Needed for numpy >= 1.20.0
45 name = "tables-pr-862-use-lowercase-numpy-dtypes.patch";
46 url = "https://github.com/PyTables/PyTables/commit/93a3272b8fe754095637628b4d312400e24ae654.patch";
47 sha256 = "00czgxnm1dxp9763va9xw1nc7dd7kxh9hjcg9klim52519hkbhi4";
48 })
49 ];
50 # When doing `make distclean`, ignore docs
51 postPatch = ''
52 substituteInPlace Makefile --replace "src doc" "src"
53 # Force test suite to error when unittest runner fails
54 substituteInPlace tables/tests/test_suite.py \
55 --replace "return 0" "assert result.wasSuccessful(); return 0" \
56 --replace "return 1" "assert result.wasSuccessful(); return 1"
57 '';
58
59 # Regenerate C code with Cython
60 preBuild = ''
61 make distclean
62 '';
63
64 setupPyBuildFlags = [
65 "--hdf5=${lib.getDev hdf5}"
66 "--lzo=${lib.getDev lzo}"
67 "--bzip2=${lib.getDev bzip2}"
68 "--blosc=${lib.getDev c-blosc}"
69 ];
70
71 checkInputs = [ pytestCheckHook ];
72 preCheck = ''
73 cd ..
74 '';
75 # Runs the test suite as one single test via unittest. The whole "heavy" test suite supposedly takes ~5 hours to run.
76 pytestFlagsArray = [
77 "--pyargs"
78 "tables.tests.test_suite"
79 ];
80
81 pythonImportsCheck = [ "tables" ];
82
83 meta = with lib; {
84 description = "Hierarchical datasets for Python";
85 homepage = "https://www.pytables.org/";
86 license = licenses.bsd2;
87 maintainers = with maintainers; [ drewrisinger ];
88 };
89}