summaryrefslogtreecommitdiffstats
path: root/pkgs/development/python-modules/argos-translate-files/default.nix
blob: 6003dd24a067c4b98b690daf16b6d63d872e4a0d (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
{
  lib,
  stdenv,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
  setuptools,
  lxml,
  pymupdf,
  pysrt,
  translatehtml,
}:

let
  inherit (stdenv.hostPlatform) isLinux isAarch64;
  isAarch64Linux = isLinux && isAarch64;
in
buildPythonPackage (finalAttrs: {
  pname = "argos-translate-files";
  version = "1.4.4";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "LibreTranslate";
    repo = "argos-translate-files";
    tag = "v${finalAttrs.version}";
    hash = "sha256-6AxVBiK0g6ajstyCQZ9ExF9MRYSLd4Frw03N7c9bvuI=";
  };

  build-system = [ setuptools ];

  pythonRelaxDeps = [ "beautifulsoup4" ];

  # LibreTranslate has forked argos-translate [1] to fix some bugs and
  # make stanza optional, but it's unclear what the future of this fork
  # is.
  #
  # We'll stay on upstream argostranslate for now.
  #
  # [1]: https://github.com/Libretranslate/argos-translate/
  pythonRemoveDeps = [ "argos-translate-lt" ];

  dependencies = [
    lxml
    pymupdf
    pysrt
    translatehtml
  ];

  nativeCheckInputs = [
    pytestCheckHook
    # pythonImportsCheck needs a home dir for argostranslatefiles
    writableTmpDirAsHomeHook
  ];

  # aarch64-linux fails cpuinfo test, because /sys/devices/system/cpu/ does not exist in the sandbox:
  # terminate called after throwing an instance of 'onnxruntime::OnnxRuntimeException'
  pythonImportsCheck = lib.optional (!isAarch64Linux) "argostranslatefiles";
  doCheck = !isAarch64Linux;

  meta = {
    description = "Translate files using Argos Translate";
    homepage = "https://www.argosopentech.com";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ misuzu ];
  };
})