1{ lib
2, buildPythonPackage
3, pythonOlder
4, fetchFromGitHub
5, fetchpatch
6
7# Native build inputs
8, cython
9, pythonRelaxDepsHook
10, which
11
12# Propagated build inputs
13, cffi
14, hydra-core
15, omegaconf
16, sacrebleu
17, numpy
18, regex
19, torch
20, tqdm
21, bitarray
22, torchaudio
23, scikit-learn
24, packaging
25
26# Check inputs
27, expecttest
28, hypothesis
29, pytestCheckHook
30}:
31
32buildPythonPackage rec {
33 pname = "fairseq";
34 version = "0.12.3";
35 pyproject = true;
36 disabled = pythonOlder "3.7";
37
38 src = fetchFromGitHub {
39 owner = "pytorch";
40 repo = pname;
41 rev = "v${version}";
42 hash = "sha256-XX/grU5ljQCwx33miGoFc/7Uj9fZDtmhm4Fz7L4U+Bc=";
43 };
44
45 patches = [
46 # https://github.com/facebookresearch/fairseq/pull/5359
47 (fetchpatch {
48 url = "https://github.com/facebookresearch/fairseq/commit/2fa0768c2115b0a4c207cfa3e1b3e4ff3ad9a00c.patch";
49 hash = "sha256-aYYP/knQX6q6vhyA6q9uOOYfRhDAuJCo9QJWfFEDuuA=";
50 })
51 ];
52
53 nativeBuildInputs = [
54 cython
55 pythonRelaxDepsHook
56 which
57 ];
58
59 pythonRelaxDeps = [
60 "hydra-core"
61 "omegaconf"
62 ];
63
64 propagatedBuildInputs = [
65 cffi
66 hydra-core
67 omegaconf
68 sacrebleu
69 numpy
70 regex
71 torch
72 tqdm
73 bitarray
74 torchaudio
75 scikit-learn
76 packaging
77 ];
78
79 nativeCheckInputs = [
80 expecttest
81 hypothesis
82 pytestCheckHook
83 ];
84
85 pythonImportsCheck = [ "fairseq" ];
86
87 preCheck = ''
88 export HOME=$TMPDIR
89 cd tests
90 '';
91
92 pytestFlagsArray = [
93 "--import-mode append"
94 ];
95
96 disabledTests = [
97 # this test requires xformers
98 "test_xformers_single_forward_parity"
99 # this test requires iopath
100 "test_file_io_async"
101 # these tests require network access
102 "test_s2s_transformer_checkpoint"
103 "test_librispeech_s2t_transformer_s_checkpoint"
104 "test_s2s_transformer_checkpoint"
105 "test_waitk_checkpoint"
106 "test_sotasty_es_en_600m_checkpoint"
107 "test_librispeech_s2t_conformer_s_checkpoint"
108 ];
109
110 disabledTestPaths = [
111 # ValueError: mutable default ... for field bar is not allowed: use default_factory
112 "test_dataclass_utils.py"
113 ];
114
115 meta = with lib; {
116 description = "Facebook AI Research Sequence-to-Sequence Toolkit";
117 homepage = "https://github.com/pytorch/fairseq";
118 license = licenses.mit;
119 platforms = platforms.linux;
120 maintainers = with maintainers; [ happysalada ];
121 };
122}