1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 fetchPypi,
6 pytestCheckHook,
7 ctranslate2,
8 ctranslate2-cpp,
9 sentencepiece,
10 stanza,
11}:
12let
13 ctranslate2OneDNN = ctranslate2.override {
14 ctranslate2-cpp = ctranslate2-cpp.override {
15 # https://github.com/OpenNMT/CTranslate2/issues/1294
16 withOneDNN = true;
17 withOpenblas = false;
18 };
19 };
20in
21buildPythonPackage rec {
22 pname = "argostranslate";
23 version = "1.9.6";
24
25 format = "setuptools";
26
27 src = fetchPypi {
28 inherit pname version;
29 hash = "sha256-3YzBMnqmcTIpn5UOFg3SDTFLjPSE9UDw0i8fB8LYh2s=";
30 };
31
32 propagatedBuildInputs = [
33 ctranslate2OneDNN
34 sentencepiece
35 stanza
36 ];
37
38 postPatch = ''
39 ln -s */requires.txt requirements.txt
40
41 substituteInPlace requirements.txt \
42 --replace "==" ">="
43 '';
44
45 doCheck = false; # needs network access
46
47 nativeCheckInputs = [ pytestCheckHook ];
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 = {
59 description = "Open-source offline translation library written in Python";
60 homepage = "https://www.argosopentech.com";
61 license = lib.licenses.mit;
62 maintainers = with lib.maintainers; [ misuzu ];
63 # Segfaults at import
64 broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64;
65 };
66}