Commit a16e7472 authored by Steven Allen's avatar Steven Allen
Browse files

libretranslate: modernize

- Avoid recursive attribute set.
- Use writeableTmpDirAsHomeHook
parent 140e029b
Loading
Loading
Loading
Loading
+7 −12
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@
  pkgs,
  buildPythonPackage,
  fetchFromGitHub,
  pytestCheckHook,
  writableTmpDirAsHomeHook,
  runCommand,
  hatchling,
  argostranslate,
@@ -32,7 +32,7 @@
  lndir,
}:

buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
  pname = "libretranslate";
  version = "1.9.0";
  pyproject = true;
@@ -40,8 +40,8 @@ buildPythonPackage rec {
  src = fetchFromGitHub {
    owner = "LibreTranslate";
    repo = "LibreTranslate";
    tag = "v${version}";
    hash = "sha256-bBs7gG42H4MNca5RUiedKNQkLjKpBm2SbPMRyh2gh6c=";
    tag = "v${finalAttrs.version}";
  };

  build-system = [
@@ -80,13 +80,8 @@ buildPythonPackage rec {
    ln -s $out/${python.sitePackages}/libretranslate/static $out/share/libretranslate/static
  '';

  doCheck = false; # needs network access

  nativeCheckInputs = [ pytestCheckHook ];

  # required for import check to work (argostranslate)
  env.HOME = "/tmp";

  # needed to import the argostranslate module
  nativeCheckInputs = [ writableTmpDirAsHomeHook ];
  pythonImportsCheck = [ "libretranslate" ];

  passthru = {
@@ -112,8 +107,8 @@ buildPythonPackage rec {
  meta = {
    description = "Free and Open Source Machine Translation API. Self-hosted, no limits, no ties to proprietary services";
    homepage = "https://libretranslate.com";
    changelog = "https://github.com/LibreTranslate/LibreTranslate/releases/tag/${src.tag}";
    changelog = "https://github.com/LibreTranslate/LibreTranslate/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.agpl3Only;
    maintainers = with lib.maintainers; [ misuzu ];
  };
}
})