summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/sudachipy/default.nix
blob: 9420c5d20b8bf01c570abccde07292ad20deef35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{
  lib,
  stdenv,
  buildPythonPackage,
  cargo,
  libiconv,
  rustPlatform,
  rustc,
  sudachi-rs,
  setuptools-rust,
  pytestCheckHook,
  sudachidict-core,
  tokenizers,
  sudachipy,
}:

buildPythonPackage rec {
  format = "setuptools";
  pname = "sudachipy";
  inherit (sudachi-rs) src version;

  patches = sudachi-rs.cargoPatches;

  cargoDeps = rustPlatform.fetchCargoVendor {
    inherit pname version src;
    patches = sudachi-rs.cargoPatches;
    hash = "sha256-lUP/9s4W0JehxeCjMmq6G22KMGdDNnq1YlobeLQn2AE=";
  };

  nativeBuildInputs = [
    cargo
    rustPlatform.cargoSetupHook
    rustc
    setuptools-rust
  ];

  buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];

  preBuild = ''
    cd python
  '';

  # avoid infinite recursion due to sudachidict
  doCheck = false;

  nativeCheckInputs = [
    pytestCheckHook
    sudachidict-core
    tokenizers
  ];

  pythonImportsCheck = [ "sudachipy" ];

  passthru = {
    inherit (sudachi-rs) updateScript;
    tests = {
      pytest = sudachipy.overridePythonAttrs (_: {
        doCheck = true;
        # avoid catchConflicts of sudachipy
        # we don't need to install this package since it is just a test
        dontInstall = true;
      });
    };
  };

  meta = sudachi-rs.meta // {
    homepage = "https://github.com/WorksApplications/sudachi.rs/tree/develop/python";
    mainProgram = "sudachipy";
  };
}