1{
2 buildPythonPackage,
3 cython,
4 fetchFromGitHub,
5 isPy38,
6 lib,
7 lz4,
8 numpy,
9 pandas,
10 pytestCheckHook,
11 python-dateutil,
12 python-snappy,
13 pythonOlder,
14 zlib-ng,
15 zstandard,
16}:
17
18buildPythonPackage rec {
19 pname = "fastavro";
20 version = "1.9.4";
21 format = "setuptools";
22
23 disabled = pythonOlder "3.6";
24
25 src = fetchFromGitHub {
26 owner = pname;
27 repo = pname;
28 rev = "refs/tags/${version}";
29 hash = "sha256-UWvNEi6vzQknUws+b7UCFUajMUJkfnQkfBeCR0XfqQY=";
30 };
31
32 preBuild = ''
33 export FASTAVRO_USE_CYTHON=1
34 '';
35
36 nativeBuildInputs = [ cython ];
37
38 passthru.optional-dependencies = {
39 codecs = [
40 lz4
41 python-snappy
42 zstandard
43 ];
44 snappy = [ python-snappy ];
45 zstandard = [ zstandard ];
46 lz4 = [ lz4 ];
47 };
48
49 nativeCheckInputs = [
50 numpy
51 pandas
52 pytestCheckHook
53 python-dateutil
54 zlib-ng
55 ] ++ lib.flatten (lib.attrValues passthru.optional-dependencies);
56
57 # Fails with "AttributeError: module 'fastavro._read_py' has no attribute
58 # 'CYTHON_MODULE'." Doesn't appear to be serious. See https://github.com/fastavro/fastavro/issues/112#issuecomment-387638676.
59 disabledTests = [ "test_cython_python" ];
60
61 # CLI tests are broken on Python 3.8. See https://github.com/fastavro/fastavro/issues/558.
62 disabledTestPaths = lib.optionals isPy38 [ "tests/test_main_cli.py" ];
63
64 pythonImportsCheck = [ "fastavro" ];
65
66 meta = with lib; {
67 description = "Fast read/write of AVRO files";
68 mainProgram = "fastavro";
69 homepage = "https://github.com/fastavro/fastavro";
70 changelog = "https://github.com/fastavro/fastavro/blob/${version}/ChangeLog";
71 license = licenses.mit;
72 maintainers = with maintainers; [ samuela ];
73 };
74}