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.16";
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-hgyW3bff70yByxPFqw8pwPMPMAh9FxL1U+LQoJI6INo=";
43 };
44
45 cargoDeps = rustPlatform.fetchCargoVendor {
46 inherit pname version src;
47 hash = "sha256-mOHOIKmcXjPwZ8uPth+yvreHG4IpiS6SFhWY+IZS69E=";
48 };
49
50 nativeBuildInputs =
51 [ cffi ]
52 ++ (with rustPlatform; [
53 cargoSetupHook
54 maturinBuildHook
55 ]);
56
57 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
58
59 nativeCheckInputs = [
60 numpy
61 psutil
62 pytestCheckHook
63 python-dateutil
64 pytz
65 xxhash
66 ];
67
68 pythonImportsCheck = [ "orjson" ];
69
70 passthru.tests = {
71 inherit
72 falcon
73 fastapi
74 gradio
75 mashumaro
76 ufolib2
77 ;
78 };
79
80 meta = with lib; {
81 description = "Fast, correct Python JSON library supporting dataclasses, datetimes, and numpy";
82 homepage = "https://github.com/ijl/orjson";
83 changelog = "https://github.com/ijl/orjson/blob/${version}/CHANGELOG.md";
84 license = with licenses; [
85 asl20
86 mit
87 ];
88 platforms = platforms.unix;
89 maintainers = with maintainers; [ misuzu ];
90 };
91}