1{
2 lib,
3 buildPythonPackage,
4 pythonOlder,
5 fetchFromGitHub,
6 fetchpatch,
7
8 # Native build inputs
9 cython,
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 = "fairseq";
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 which
56 ];
57
58 pythonRelaxDeps = [
59 "hydra-core"
60 "omegaconf"
61 "torchaudio"
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 pytestFlags = [ "--import-mode=append" ];
93
94 disabledTests = [
95 # this test requires xformers
96 "test_xformers_single_forward_parity"
97 "test_mask_for_xformers"
98 # this test requires iopath
99 "test_file_io_async"
100 # these tests require network access
101 "test_s2s_transformer_checkpoint"
102 "test_librispeech_s2t_transformer_s_checkpoint"
103 "test_s2s_transformer_checkpoint"
104 "test_waitk_checkpoint"
105 "test_sotasty_es_en_600m_checkpoint"
106 "test_librispeech_s2t_conformer_s_checkpoint"
107 # TODO research failure
108 "test_multilingual_translation_latent_depth"
109 ];
110
111 disabledTestPaths = [
112 # ValueError: mutable default ... for field bar is not allowed: use default_factory
113 "test_dataclass_utils.py"
114 ];
115
116 meta = with lib; {
117 description = "Facebook AI Research Sequence-to-Sequence Toolkit";
118 homepage = "https://github.com/pytorch/fairseq";
119 license = licenses.mit;
120 platforms = platforms.linux;
121 hydraPlatforms = [ ];
122 maintainers = with maintainers; [ happysalada ];
123 broken = true; # requires numpy1 which is incompatible with sacrebleu depending on numpy2
124 };
125}