Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
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.3"; 30 pyproject = true; 31 32 src = fetchFromGitHub { 33 owner = "python-attrs"; 34 repo = "cattrs"; 35 tag = "v${version}"; 36 hash = "sha256-yrrb2Lvq7zMzeOLr8wwxVsKmPYEZxzDKR2mnCMNuHdE="; 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 ] 65 ++ lib.optionals (pythonOlder "3.11") [ 66 exceptiongroup 67 typing-extensions 68 ]; 69 70 nativeCheckInputs = [ 71 cbor2 72 hypothesis 73 immutables 74 motor 75 msgpack 76 msgspec 77 orjson 78 pytest-xdist 79 pytestCheckHook 80 pyyaml 81 tomlkit 82 typing-extensions 83 ujson 84 ]; 85 86 postPatch = '' 87 substituteInPlace pyproject.toml \ 88 --replace-fail "-l --benchmark-sort=fullname --benchmark-warmup=true --benchmark-warmup-iterations=5 --benchmark-group-by=fullname" "" 89 substituteInPlace tests/test_preconf.py \ 90 --replace-fail "from orjson import dumps as orjson_dumps" "" \ 91 --replace-fail "from orjson import loads as orjson_loads" "" 92 ''; 93 94 preCheck = '' 95 export HOME=$(mktemp -d); 96 ''; 97 98 disabledTestPaths = [ 99 # Don't run benchmarking tests 100 "bench" 101 ]; 102 103 disabledTests = [ 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}