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 patches = [
34 (fetchpatch {
35 name = "numpy-1.25-compatibility.patch";
36 url = "https://github.com/PyTables/PyTables/commit/337792561e5924124efd20d6fea6bbbd2428b2aa.patch";
37 hash = "sha256-pz3A/jTPWXXlzr+Yl5PRUvdSAinebFsoExfek4RUHkc=";
38 })
39 (fetchpatch {
40 name = "numexpr-2.8.5-compatibility.patch";
41 url = "https://github.com/PyTables/PyTables/commit/1a235490ebe1a138da1139cfa19829b5f0a2af37.patch";
42 includes = [ "tables/tests/test_queries.py" ];
43 hash = "sha256-uMS+Z2Zcz68ILMQaBdIDMnCyasozCaCGOiGIyw0+Evc=";
44 })
45 ];
46
47 nativeBuildInputs = [
48 blosc2
49 cython
50 sphinx
51 ];
52
53 buildInputs = [
54 bzip2
55 c-blosc
56 hdf5
57 lzo
58 ];
59
60 propagatedBuildInputs = [
61 blosc2
62 py-cpuinfo
63 numpy
64 numexpr
65 packaging # uses packaging.version at runtime
66 ];
67
68 # When doing `make distclean`, ignore docs
69 postPatch = ''
70 substituteInPlace Makefile --replace "src doc" "src"
71 # Force test suite to error when unittest runner fails
72 substituteInPlace tables/tests/test_suite.py \
73 --replace "return 0" "assert result.wasSuccessful(); return 0" \
74 --replace "return 1" "assert result.wasSuccessful(); return 1"
75 substituteInPlace requirements.txt \
76 --replace "cython>=0.29.21" "" \
77 --replace "blosc2~=2.0.0" "blosc2"
78 '';
79
80 # Regenerate C code with Cython
81 preBuild = ''
82 make distclean
83 '';
84
85 setupPyBuildFlags = [
86 "--hdf5=${lib.getDev hdf5}"
87 "--lzo=${lib.getDev lzo}"
88 "--bzip2=${lib.getDev bzip2}"
89 "--blosc=${lib.getDev c-blosc}"
90 ];
91
92 nativeCheckInputs = [
93 pytest
94 ];
95
96 preCheck = ''
97 cd ..
98 '';
99
100 # Runs the light (yet comprehensive) subset of the test suite.
101 # The whole "heavy" test suite supposedly takes ~4 hours to run.
102 checkPhase = ''
103 runHook preCheck
104 ${python.interpreter} -m tables.tests.test_all
105 runHook postCheck
106 '';
107
108 pythonImportsCheck = [ "tables" ];
109
110 meta = with lib; {
111 description = "Hierarchical datasets for Python";
112 homepage = "https://www.pytables.org/";
113 changelog = "https://github.com/PyTables/PyTables/releases/tag/v${version}";
114 license = licenses.bsd2;
115 maintainers = with maintainers; [ drewrisinger ];
116 };
117}