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