1{
2 lib,
3 stdenv,
4 fetchPypi,
5 buildPythonPackage,
6 pythonOlder,
7 blosc2,
8 bzip2,
9 c-blosc,
10 cython,
11 hdf5,
12 lzo,
13 numpy,
14 numexpr,
15 packaging,
16 setuptools,
17 sphinx,
18 typing-extensions,
19 # Test inputs
20 python,
21 pytest,
22 py-cpuinfo,
23}:
24
25buildPythonPackage rec {
26 pname = "tables";
27 version = "3.10.2";
28 format = "setuptools";
29
30 disabled = pythonOlder "3.8";
31
32 src = fetchPypi {
33 inherit pname version;
34 hash = "sha256-JUSBKnGG+tuoMdbdNOtJzNeI1qg/TkwrQxuDW2eWyRA=";
35 };
36
37 build-system = [
38 blosc2
39 cython
40 setuptools
41 sphinx
42 ];
43
44 buildInputs = [
45 bzip2
46 c-blosc
47 blosc2.c-blosc2
48 hdf5
49 lzo
50 ];
51
52 dependencies = [
53 blosc2
54 py-cpuinfo
55 numpy
56 numexpr
57 packaging # uses packaging.version at runtime
58 typing-extensions
59 ];
60
61 # When doing `make distclean`, ignore docs
62 postPatch = ''
63 # Force test suite to error when unittest runner fails
64 substituteInPlace tables/tests/test_suite.py \
65 --replace-fail "return 0" "assert result.wasSuccessful(); return 0" \
66 --replace-fail "return 1" "assert result.wasSuccessful(); return 1"
67 substituteInPlace tables/__init__.py \
68 --replace-fail 'find_library("blosc2")' '"${lib.getLib c-blosc}/lib/libblosc${stdenv.hostPlatform.extensions.sharedLibrary}"' '';
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 export HOME=$(mktemp -d)
87 cd ..
88 '';
89
90 # Runs the light (yet comprehensive) subset of the test suite.
91 # The whole "heavy" test suite supposedly takes ~4 hours to run.
92 checkPhase = ''
93 runHook preCheck
94 ${python.interpreter} -m tables.tests.test_all
95 runHook postCheck
96 '';
97
98 pythonImportsCheck = [ "tables" ];
99
100 meta = with lib; {
101 description = "Hierarchical datasets for Python";
102 homepage = "https://www.pytables.org/";
103 changelog = "https://github.com/PyTables/PyTables/releases/tag/v${version}";
104 license = licenses.bsd2;
105 maintainers = with maintainers; [ drewrisinger ];
106 };
107}