at master 1.6 kB view raw
1{ 2 lib, 3 stdenv, 4 buildPythonPackage, 5 fetchFromGitHub, 6 pythonOlder, 7 8 # build-system 9 rustPlatform, 10 cffi, 11 12 # native dependencies 13 libiconv, 14 15 # tests 16 numpy, 17 psutil, 18 pytestCheckHook, 19 python-dateutil, 20 pytz, 21 xxhash, 22 23 # for passthru.tests 24 falcon, 25 fastapi, 26 gradio, 27 mashumaro, 28 ufolib2, 29}: 30 31buildPythonPackage rec { 32 pname = "orjson"; 33 version = "3.10.18"; 34 pyproject = true; 35 36 disabled = pythonOlder "3.8"; 37 38 src = fetchFromGitHub { 39 owner = "ijl"; 40 repo = "orjson"; 41 tag = version; 42 hash = "sha256-gEShQJrqSFMwc9PreRhbup3yE0RySwJtlgXfhDomiIc="; 43 }; 44 45 cargoDeps = rustPlatform.fetchCargoVendor { 46 inherit pname version src; 47 hash = "sha256-vMuqqUfaYFZ1wC3SZBVF7Wq2OUKd7UkdC8GB93QBq8Y="; 48 }; 49 50 nativeBuildInputs = [ 51 cffi 52 ] 53 ++ (with rustPlatform; [ 54 cargoSetupHook 55 maturinBuildHook 56 ]); 57 58 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]; 59 60 nativeCheckInputs = [ 61 numpy 62 psutil 63 pytestCheckHook 64 python-dateutil 65 pytz 66 xxhash 67 ]; 68 69 pythonImportsCheck = [ "orjson" ]; 70 71 passthru.tests = { 72 inherit 73 falcon 74 fastapi 75 gradio 76 mashumaro 77 ufolib2 78 ; 79 }; 80 81 meta = with lib; { 82 description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy"; 83 homepage = "https://github.com/ijl/orjson"; 84 changelog = "https://github.com/ijl/orjson/blob/${version}/CHANGELOG.md"; 85 license = with licenses; [ 86 asl20 87 mit 88 ]; 89 platforms = platforms.unix; 90 maintainers = with maintainers; [ misuzu ]; 91 }; 92}