at 25.11-pre 2.9 kB view raw
1{ 2 lib, 3 attrs, 4 buildPythonPackage, 5 cbor2, 6 fetchFromGitHub, 7 fetchpatch2, 8 exceptiongroup, 9 hatchling, 10 hatch-vcs, 11 hypothesis, 12 immutables, 13 motor, 14 msgpack, 15 msgspec, 16 orjson, 17 pytest-xdist, 18 pytestCheckHook, 19 pythonAtLeast, 20 pythonOlder, 21 pyyaml, 22 tomlkit, 23 typing-extensions, 24 ujson, 25}: 26 27buildPythonPackage rec { 28 pname = "cattrs"; 29 version = "24.1.2"; 30 pyproject = true; 31 32 src = fetchFromGitHub { 33 owner = "python-attrs"; 34 repo = "cattrs"; 35 tag = "v${version}"; 36 hash = "sha256-LSP8a/JduK0h9GytfbN7/CjFlnGGChaa3VbbCHQ3AFE="; 37 }; 38 39 patches = [ 40 # https://github.com/python-attrs/cattrs/pull/576 41 (fetchpatch2 { 42 name = "attrs-24_2-compatibility1.patch"; 43 url = "https://github.com/python-attrs/cattrs/commit/2d37226ff19506e23bbc291125a29ce514575819.patch"; 44 excludes = [ 45 "pyproject.toml" 46 "pdm.lock" 47 ]; 48 hash = "sha256-nbk7rmOFk42DXYdOgw4Oe3gl3HbxNEtaJ7ZiVSBb3YA="; 49 }) 50 (fetchpatch2 { 51 name = "attrs-24_2-compatibility2.patch"; 52 url = "https://github.com/python-attrs/cattrs/commit/4bd6dde556042241c6381e1993cedd6514921f58.patch"; 53 hash = "sha256-H1xSAYjvVUI8/jON3LWg2F2TlSxejf6TU1jpCeqly6I="; 54 }) 55 ]; 56 57 build-system = [ 58 hatchling 59 hatch-vcs 60 ]; 61 62 dependencies = 63 [ attrs ] 64 ++ lib.optionals (pythonOlder "3.11") [ 65 exceptiongroup 66 typing-extensions 67 ]; 68 69 nativeCheckInputs = [ 70 cbor2 71 hypothesis 72 immutables 73 motor 74 msgpack 75 msgspec 76 orjson 77 pytest-xdist 78 pytestCheckHook 79 pyyaml 80 tomlkit 81 typing-extensions 82 ujson 83 ]; 84 85 postPatch = '' 86 substituteInPlace pyproject.toml \ 87 --replace-fail "-l --benchmark-sort=fullname --benchmark-warmup=true --benchmark-warmup-iterations=5 --benchmark-group-by=fullname" "" 88 substituteInPlace tests/test_preconf.py \ 89 --replace-fail "from orjson import dumps as orjson_dumps" "" \ 90 --replace-fail "from orjson import loads as orjson_loads" "" 91 ''; 92 93 preCheck = '' 94 export HOME=$(mktemp -d); 95 ''; 96 97 disabledTestPaths = [ 98 # Don't run benchmarking tests 99 "bench" 100 ]; 101 102 disabledTests = 103 [ 104 # orjson is not available as it requires Rust nightly features to compile its requirements 105 "test_orjson" 106 # msgspec causes a segmentation fault for some reason 107 "test_simple_classes" 108 "test_msgspec_json_converter" 109 ] 110 ++ lib.optionals (pythonAtLeast "3.13") [ 111 # https://github.com/python-attrs/cattrs/pull/543 112 "test_unstructure_deeply_nested_generics_list" 113 ]; 114 115 pythonImportsCheck = [ "cattr" ]; 116 117 meta = { 118 description = "Python custom class converters for attrs"; 119 homepage = "https://github.com/python-attrs/cattrs"; 120 changelog = "https://github.com/python-attrs/cattrs/blob/${src.rev}/HISTORY.md"; 121 license = with lib.licenses; [ mit ]; 122 maintainers = with lib.maintainers; [ fab ]; 123 }; 124}