1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 cargo,
6 libiconv,
7 rustPlatform,
8 rustc,
9 sudachi-rs,
10 setuptools-rust,
11 pytestCheckHook,
12 sudachidict-core,
13 tokenizers,
14 sudachipy,
15}:
16
17buildPythonPackage rec {
18 format = "setuptools";
19 pname = "sudachipy";
20 inherit (sudachi-rs) src version;
21
22 patches = sudachi-rs.cargoPatches;
23
24 cargoDeps = rustPlatform.fetchCargoVendor {
25 inherit pname version src;
26 patches = sudachi-rs.cargoPatches;
27 hash = "sha256-lUP/9s4W0JehxeCjMmq6G22KMGdDNnq1YlobeLQn2AE=";
28 };
29
30 nativeBuildInputs = [
31 cargo
32 rustPlatform.cargoSetupHook
33 rustc
34 setuptools-rust
35 ];
36
37 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
38
39 preBuild = ''
40 cd python
41 '';
42
43 # avoid infinite recursion due to sudachidict
44 doCheck = false;
45
46 nativeCheckInputs = [
47 pytestCheckHook
48 sudachidict-core
49 tokenizers
50 ];
51
52 pythonImportsCheck = [ "sudachipy" ];
53
54 passthru = {
55 inherit (sudachi-rs) updateScript;
56 tests = {
57 pytest = sudachipy.overridePythonAttrs (_: {
58 doCheck = true;
59 # avoid catchConflicts of sudachipy
60 # we don't need to install this package since it is just a test
61 dontInstall = true;
62 });
63 };
64 };
65
66 meta = sudachi-rs.meta // {
67 homepage = "https://github.com/WorksApplications/sudachi.rs/tree/develop/python";
68 mainProgram = "sudachipy";
69 };
70}