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 pname = "sudachipy";
19 inherit (sudachi-rs) src version;
20
21 cargoDeps = rustPlatform.fetchCargoVendor {
22 inherit pname version src;
23 hash = "sha256-/VKveTtB8BbWgRBEzWBjrSrW84uFcz08cz6tZTuMMeE=";
24 };
25
26 nativeBuildInputs = [
27 cargo
28 rustPlatform.cargoSetupHook
29 rustc
30 setuptools-rust
31 ];
32
33 buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
34
35 preBuild = ''
36 cd python
37 '';
38
39 # avoid infinite recursion due to sudachidict
40 doCheck = false;
41
42 nativeCheckInputs = [
43 pytestCheckHook
44 sudachidict-core
45 tokenizers
46 ];
47
48 pythonImportsCheck = [ "sudachipy" ];
49
50 passthru = {
51 inherit (sudachi-rs) updateScript;
52 tests = {
53 pytest = sudachipy.overridePythonAttrs (_: {
54 doCheck = true;
55 # avoid catchConflicts of sudachipy
56 # we don't need to install this package since it is just a test
57 dontInstall = true;
58 });
59 };
60 };
61
62 meta = sudachi-rs.meta // {
63 homepage = "https://github.com/WorksApplications/sudachi.rs/tree/develop/python";
64 mainProgram = "sudachipy";
65 };
66}