nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, attrs
3, buildPythonPackage
4, fetchFromGitHub
5, hypothesis
6, immutables
7, motor
8, msgpack
9, poetry-core
10, pytest-xdist
11, pytestCheckHook
12, pythonOlder
13, pyyaml
14, tomlkit
15, typing-extensions
16, ujson
17}:
18
19buildPythonPackage rec {
20 pname = "cattrs";
21 version = "1.10.0";
22 format = "pyproject";
23
24 disabled = pythonOlder "3.7";
25
26 src = fetchFromGitHub {
27 owner = "python-attrs";
28 repo = pname;
29 rev = "v${version}";
30 hash = "sha256-VbfQMMDO03eeUHAACxoX6a3DKmzoF9EfLuTpvaY6bWs=";
31 };
32
33 nativeBuildInputs = [
34 poetry-core
35 ];
36
37 propagatedBuildInputs = [
38 attrs
39 ] ++ lib.optionals (pythonOlder "3.7") [
40 typing-extensions
41 ];
42
43 checkInputs = [
44 hypothesis
45 immutables
46 motor
47 msgpack
48 pytest-xdist
49 pytestCheckHook
50 pyyaml
51 tomlkit
52 ujson
53 ];
54
55
56 postPatch = ''
57 substituteInPlace pyproject.toml \
58 --replace "-l --benchmark-sort=fullname --benchmark-warmup=true --benchmark-warmup-iterations=5 --benchmark-group-by=fullname" "" \
59 --replace 'orjson = "^3.5.2"' "" \
60 --replace "[tool.poetry.group.dev.dependencies]" "[tool.poetry.dev-dependencies]"
61 substituteInPlace tests/test_preconf.py \
62 --replace "from orjson import dumps as orjson_dumps" "" \
63 --replace "from orjson import loads as orjson_loads" ""
64 '';
65
66 preCheck = ''
67 export HOME=$(mktemp -d);
68 '';
69
70 disabledTestPaths = [
71 # Don't run benchmarking tests
72 "bench/test_attrs_collections.py"
73 "bench/test_attrs_nested.py"
74 "bench/test_attrs_primitives.py"
75 "bench/test_primitives.py"
76 ];
77
78 disabledTests = [
79 # orjson is not available as it requires Rust nightly features to compile its requirements
80 "test_orjson"
81 # tomlkit is pinned to an older version and newer versions raise InvalidControlChar exception
82 "test_tomlkit"
83 ];
84
85 pythonImportsCheck = [
86 "cattr"
87 ];
88
89 meta = with lib; {
90 description = "Python custom class converters for attrs";
91 homepage = "https://github.com/python-attrs/cattrs";
92 license = with licenses; [ mit ];
93 maintainers = with maintainers; [ fab ];
94 };
95}