From c3765f82f7d7ab4e8dbcc800356c135dd14c77ab Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Tue, 17 Feb 2026 11:06:41 -0800 Subject: [PATCH] python313Packages.argostranslate: modernize and enable tests 1. Modernize per feedback received in #491271. 2. Enable checks and disable the single one that doesn't work. Co-authored-by: Sarah Clark --- .../python-modules/argostranslate/default.nix | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/pkgs/development/python-modules/argostranslate/default.nix b/pkgs/development/python-modules/argostranslate/default.nix index 03cf9ab06c1d..cbaa4d5a578a 100644 --- a/pkgs/development/python-modules/argostranslate/default.nix +++ b/pkgs/development/python-modules/argostranslate/default.nix @@ -1,13 +1,18 @@ { lib, buildPythonPackage, - fetchPypi, - pytestCheckHook, + fetchFromGitHub, + # build-system + setuptools, + # dependencies ctranslate2, ctranslate2-cpp, sacremoses, sentencepiece, stanza, + # tests + pytestCheckHook, + writableTmpDirAsHomeHook, }: let ctranslate2OneDNN = ctranslate2.override { @@ -18,38 +23,36 @@ let }; }; in -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "argostranslate"; version = "1.9.6"; + pyproject = true; - format = "setuptools"; - - src = fetchPypi { - inherit pname version; - hash = "sha256-3YzBMnqmcTIpn5UOFg3SDTFLjPSE9UDw0i8fB8LYh2s="; + src = fetchFromGitHub { + owner = "argosopentech"; + repo = "argos-translate"; + tag = "v${finalAttrs.version}"; + hash = "sha256-OFF2DAcuRwEJxZebgRq5Ukb/TaNsP/rsO7BUAcD+lz8="; }; - propagatedBuildInputs = [ + build-system = [ setuptools ]; + + dependencies = [ ctranslate2OneDNN sacremoses sentencepiece stanza ]; - postPatch = '' - ln -s */requires.txt requirements.txt + nativeCheckInputs = [ + pytestCheckHook + writableTmpDirAsHomeHook + ]; - substituteInPlace requirements.txt \ - --replace "==" ">=" - ''; - - doCheck = false; # needs network access - - nativeCheckInputs = [ pytestCheckHook ]; - - # required for import check to work - # PermissionError: [Errno 13] Permission denied: '/homeless-shelter' - env.HOME = "/tmp"; + pythonRelaxDeps = [ + "stanza" + "sentencepiece" + ]; pythonImportsCheck = [ "argostranslate" @@ -59,7 +62,8 @@ 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 ]; }; -} +})