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