Unverified Commit c1eefc64 authored by misuzu's avatar misuzu Committed by GitHub
Browse files

python313Packages.argostranslate: modernize, update, and enable tests (#491472)

parents caf38120 de5dec98
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
{
  lib,
  buildPythonPackage,
  fetchPypi,
  pytestCheckHook,
  fetchFromGitHub,
  # build-system
  setuptools,
  # dependencies
  ctranslate2,
  ctranslate2-cpp,
  minisbd,
  sacremoses,
  sentencepiece,
  spacy,
  stanza,
  # tests
  pytestCheckHook,
  writableTmpDirAsHomeHook,
}:
let
  ctranslate2OneDNN = ctranslate2.override {
@@ -18,38 +25,37 @@ let
    };
  };
in
buildPythonPackage rec {
buildPythonPackage (finalAttrs: {
  pname = "argostranslate";
  version = "1.9.6";

  format = "setuptools";
  version = "1.11.0";
  pyproject = true;

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-3YzBMnqmcTIpn5UOFg3SDTFLjPSE9UDw0i8fB8LYh2s=";
  src = fetchFromGitHub {
    owner = "argosopentech";
    repo = "argos-translate";
    tag = "v${finalAttrs.version}";
    hash = "sha256-8uzWS0YZEteeLTYAp9qpnnJhxyhxbWkKt1krqe/RF4M=";
  };

  propagatedBuildInputs = [
  build-system = [ setuptools ];

  dependencies = [
    ctranslate2OneDNN
    minisbd
    sacremoses
    sentencepiece
    spacy
    stanza
  ];

  postPatch = ''
    ln -s */requires.txt requirements.txt

    substituteInPlace requirements.txt  \
      --replace "==" ">="
  '';

  doCheck = false; # needs network access

  nativeCheckInputs = [ pytestCheckHook ];
  nativeCheckInputs = [
    pytestCheckHook
    writableTmpDirAsHomeHook
  ];

  # required for import check to work
  # PermissionError: [Errno 13] Permission denied: '/homeless-shelter'
  env.HOME = "/tmp";
  pythonRelaxDeps = [
    "stanza"
  ];

  pythonImportsCheck = [
    "argostranslate"
@@ -59,7 +65,11 @@ buildPythonPackage rec {
  meta = {
    description = "Open-source offline translation library written in Python";
    homepage = "https://www.argosopentech.com";
    changelog = "https://github.com/argosopentech/argos-translate/releases/tag/${finalAttrs.src.tag}";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ misuzu ];
    maintainers = with lib.maintainers; [
      misuzu
      Stebalien
    ];
  };
}
})