1{ lib
2, fetchPypi
3, fetchpatch
4, buildPythonPackage
5, pythonOlder
6, blosc2
7, bzip2
8, c-blosc
9, cython
10, hdf5
11, lzo
12, numpy
13, numexpr
14, packaging
15, sphinx
16 # Test inputs
17, python
18, pytest
19, py-cpuinfo
20}:
21
22buildPythonPackage rec {
23 pname = "tables";
24 version = "3.8.0";
25
26 disabled = pythonOlder "3.8";
27
28 src = fetchPypi {
29 inherit pname version;
30 hash = "sha256-NPP6I2bOILGPHfVzp3wdJzBs4fKkHZ+e/2IbUZLqh4g=";
31 };
32
33 nativeBuildInputs = [
34 blosc2
35 cython
36 sphinx
37 ];
38
39 buildInputs = [
40 bzip2
41 c-blosc
42 hdf5
43 lzo
44 ];
45
46 propagatedBuildInputs = [
47 blosc2
48 py-cpuinfo
49 numpy
50 numexpr
51 packaging # uses packaging.version at runtime
52 ];
53
54 # When doing `make distclean`, ignore docs
55 postPatch = ''
56 substituteInPlace Makefile --replace "src doc" "src"
57 # Force test suite to error when unittest runner fails
58 substituteInPlace tables/tests/test_suite.py \
59 --replace "return 0" "assert result.wasSuccessful(); return 0" \
60 --replace "return 1" "assert result.wasSuccessful(); return 1"
61 substituteInPlace requirements.txt \
62 --replace "cython>=0.29.21" "" \
63 --replace "blosc2~=2.0.0" "blosc2"
64 '';
65
66 # Regenerate C code with Cython
67 preBuild = ''
68 make distclean
69 '';
70
71 setupPyBuildFlags = [
72 "--hdf5=${lib.getDev hdf5}"
73 "--lzo=${lib.getDev lzo}"
74 "--bzip2=${lib.getDev bzip2}"
75 "--blosc=${lib.getDev c-blosc}"
76 ];
77
78 nativeCheckInputs = [
79 pytest
80 ];
81
82 preCheck = ''
83 cd ..
84 '';
85
86 # Runs the light (yet comprehensive) subset of the test suite.
87 # The whole "heavy" test suite supposedly takes ~4 hours to run.
88 checkPhase = ''
89 runHook preCheck
90 ${python.interpreter} -m tables.tests.test_all
91 runHook postCheck
92 '';
93
94 pythonImportsCheck = [ "tables" ];
95
96 meta = with lib; {
97 description = "Hierarchical datasets for Python";
98 homepage = "https://www.pytables.org/";
99 changelog = "https://github.com/PyTables/PyTables/releases/tag/v${version}";
100 license = licenses.bsd2;
101 maintainers = with maintainers; [ drewrisinger ];
102 };
103}