1{ lib
2, buildPythonPackage
3, fetchPypi
4, pytestCheckHook
5, ctranslate2
6, ctranslate2-cpp
7, sentencepiece
8, stanza
9}:
10let
11 ctranslate2OneDNN = ctranslate2.override {
12 ctranslate2-cpp = ctranslate2-cpp.override {
13 # https://github.com/OpenNMT/CTranslate2/issues/1294
14 withOneDNN = true;
15 withOpenblas = false;
16 };
17 };
18in
19buildPythonPackage rec {
20 pname = "argostranslate";
21 version = "1.9.1";
22
23 format = "setuptools";
24
25 src = fetchPypi {
26 inherit pname version;
27 sha256 = "sha256-OlVrRfBhbJpIFjWdLQsn7zEteRP6UfkIpGT4Y933QKk=";
28 };
29
30 propagatedBuildInputs = [
31 ctranslate2OneDNN
32 sentencepiece
33 stanza
34 ];
35
36 postPatch = ''
37 ln -s */requires.txt requirements.txt
38
39 substituteInPlace requirements.txt \
40 --replace "==" ">="
41 '';
42
43 doCheck = false; # needs network access
44
45 nativeCheckInputs = [
46 pytestCheckHook
47 ];
48
49 # required for import check to work
50 # PermissionError: [Errno 13] Permission denied: '/homeless-shelter'
51 env.HOME = "/tmp";
52
53 pythonImportsCheck = [
54 "argostranslate"
55 "argostranslate.translate"
56 ];
57
58 meta = with lib; {
59 description = "Open-source offline translation library written in Python";
60 homepage = "https://www.argosopentech.com";
61 license = licenses.mit;
62 maintainers = with maintainers; [ misuzu ];
63 };
64}