summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pyopenjtalk/default.nix
blob: a6397785966b603a7c73dc3c67c41e9156463904 (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
71
72
73
74
75
76
77
78
79
{
  lib,
  python,
  buildPythonPackage,
  fetchFromGitHub,
  fetchzip,

  cmake,
  cython,
  numpy,
  setuptools,
  setuptools-scm,

  tqdm,

  pytestCheckHook,
}:

let
  dic-dirname = "open_jtalk_dic_utf_8-1.11";
  dic-src = fetchzip {
    name = dic-dirname;
    url = "https://github.com/r9y9/open_jtalk/releases/download/v1.11.1/${dic-dirname}.tar.gz";
    hash = "sha256-+6cHKujNEzmJbpN9Uan6kZKsPdwxRRzT3ZazDnCNi3s=";
  };
in
buildPythonPackage (finalAttrs: {
  pname = "pyopenjtalk";
  version = "0.4.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "r9y9";
    repo = "pyopenjtalk";
    tag = "v${finalAttrs.version}";
    hash = "sha256-f0JNiMCeKpTY+jH3/9LuCkX2DRb9U8sN0SezT6OTm/E=";
    fetchSubmodules = true;
  };

  build-system = [
    cmake
    cython
    numpy
    setuptools
    setuptools-scm
  ];

  dontUseCmakeConfigure = true;

  dependencies = [
    numpy
    tqdm
  ];

  postInstall = ''
    # the package searches for a cached dic directory in this location
    ln -s ${dic-src} $out/${python.sitePackages}/pyopenjtalk/${dic-dirname}
  '';

  nativeCheckInputs = [
    pytestCheckHook
  ];

  preCheck = ''
    # the built extension modules are only present in $out
    # so we make sure to resolve pyopenjtalk from $out
    rm -r pyopenjtalk
  '';

  pythonImportsCheck = [ "pyopenjtalk" ];

  meta = {
    changelog = "https://github.com/r9y9/pyopenjtalk/releases/tag/${finalAttrs.src.tag}";
    description = "Python wrapper for OpenJTalk";
    homepage = "https://github.com/r9y9/pyopenjtalk";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ tomasajt ];
  };
})