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.10.0";
22 pyproject = true;
23
24 disabled = pythonOlder "3.6";
25
26 src = fetchFromGitHub {
27 owner = pname;
28 repo = pname;
29 tag = version;
30 hash = "sha256-/YZFrEs7abm+oPn9yyLMV1X/G5VZ/s+ThpvzoQtYQu0=";
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 ] ++ lib.flatten (lib.attrValues optional-dependencies);
60
61 # Fails with "AttributeError: module 'fastavro._read_py' has no attribute
62 # 'CYTHON_MODULE'." Doesn't appear to be serious. See https://github.com/fastavro/fastavro/issues/112#issuecomment-387638676.
63 disabledTests = [ "test_cython_python" ];
64
65 # CLI tests are broken on Python 3.8. See https://github.com/fastavro/fastavro/issues/558.
66 disabledTestPaths = lib.optionals isPy38 [ "tests/test_main_cli.py" ];
67
68 pythonImportsCheck = [ "fastavro" ];
69
70 meta = with lib; {
71 description = "Fast read/write of AVRO files";
72 mainProgram = "fastavro";
73 homepage = "https://github.com/fastavro/fastavro";
74 changelog = "https://github.com/fastavro/fastavro/blob/${version}/ChangeLog";
75 license = licenses.mit;
76 maintainers = with maintainers; [ samuela ];
77 };
78}