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