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