1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cargo,
6 libiconv,
7 fetchFromGitHub,
8 json-stream,
9 json-stream-rs-tokenizer,
10 pythonOlder,
11 rustc,
12 rustPlatform,
13 setuptools,
14 setuptools-rust,
15 wheel,
16}:
17
18buildPythonPackage rec {
19 pname = "json-stream-rs-tokenizer";
20 version = "0.4.25";
21 pyproject = true;
22
23 disabled = pythonOlder "3.7";
24
25 src = fetchFromGitHub {
26 owner = "smheidrich";
27 repo = "py-json-stream-rs-tokenizer";
28 rev = "refs/tags/v${version}";
29 hash = "sha256-zo/jRAWSwcOnO8eU4KhDNz44P6xDGcrZf9CflwsSvF0=";
30 };
31
32 cargoDeps = rustPlatform.importCargoLock {
33 lockFile = ./Cargo.lock;
34 outputHashes = {
35 "utf8-read-0.4.0" = "sha256-L/NcgbB+2Rwtc+1e39fQh1D9S4RqQY6CCFOTh8CI8Ts=";
36 };
37 };
38
39 nativeBuildInputs = [
40 cargo
41 rustPlatform.cargoSetupHook
42 rustc
43 setuptools
44 setuptools-rust
45 wheel
46 ];
47
48 buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];
49
50 # Tests depend on json-stream, which depends on this package.
51 # To avoid infinite recursion, we only enable tests when building passthru.tests.
52 doCheck = false;
53
54 checkInputs = [ json-stream ];
55
56 pythonImportsCheck = [ "json_stream_rs_tokenizer" ];
57
58 passthru.tests = {
59 runTests = json-stream-rs-tokenizer.overrideAttrs (_: {
60 doCheck = true;
61 });
62 };
63
64 meta = with lib; {
65 description = "A faster tokenizer for the json-stream Python library";
66 homepage = "https://github.com/smheidrich/py-json-stream-rs-tokenizer";
67 license = licenses.mit;
68 maintainers = with maintainers; [ winter ];
69 };
70}