nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5
6 # build-system
7 setuptools,
8
9 # dependencies
10 filelock,
11 huggingface-hub,
12 numpy,
13 protobuf,
14 packaging,
15 pyyaml,
16 regex,
17 requests,
18 tokenizers,
19 safetensors,
20 tqdm,
21
22 # optional-dependencies
23 diffusers,
24 scikit-learn,
25 tensorflow,
26 onnxconverter-common,
27 opencv4,
28 tf2onnx,
29 torch,
30 accelerate,
31 faiss,
32 datasets,
33 jax,
34 jaxlib,
35 flax,
36 optax,
37 ftfy,
38 onnxruntime,
39 onnxruntime-tools,
40 cookiecutter,
41 sagemaker,
42 fairscale,
43 optuna,
44 ray,
45 pydantic,
46 uvicorn,
47 fastapi,
48 starlette,
49 librosa,
50 phonemizer,
51 torchaudio,
52 pillow,
53 timm,
54 torchvision,
55 av,
56 sentencepiece,
57 hf-xet,
58}:
59
60buildPythonPackage (finalAttrs: {
61 pname = "transformers";
62 version = "4.57.6";
63 pyproject = true;
64
65 src = fetchFromGitHub {
66 owner = "huggingface";
67 repo = "transformers";
68 tag = "v${finalAttrs.version}";
69 hash = "sha256-a78ornUAYlOpr30iFdq1oUiWQTm6GeT0iq8ras5i3DQ=";
70 };
71
72 build-system = [ setuptools ];
73
74 dependencies = [
75 filelock
76 huggingface-hub
77 numpy
78 packaging
79 pyyaml
80 regex
81 requests
82 tokenizers
83 safetensors
84 tqdm
85 ];
86
87 pythonRelaxDeps = [ "huggingface-hub" ];
88
89 optional-dependencies =
90 let
91 audio = [
92 librosa
93 # pyctcdecode
94 phonemizer
95 # kenlm
96 ];
97 vision = [ pillow ];
98 in
99 {
100 agents = [
101 diffusers
102 accelerate
103 datasets
104 torch
105 sentencepiece
106 opencv4
107 pillow
108 ];
109 ja = [
110 # fugashi
111 # ipadic
112 # rhoknp
113 # sudachidict_core
114 # sudachipy
115 # unidic
116 # unidic_lite
117 ];
118 sklearn = [ scikit-learn ];
119 tf = [
120 tensorflow
121 onnxconverter-common
122 tf2onnx
123 # tensorflow-text
124 # keras-nlp
125 ];
126 torch = [
127 torch
128 accelerate
129 ];
130 retrieval = [
131 faiss
132 datasets
133 ];
134 flax = [
135 jax
136 jaxlib
137 flax
138 optax
139 ];
140 hf_xet = [
141 hf-xet
142 ];
143 tokenizers = [ tokenizers ];
144 ftfy = [ ftfy ];
145 onnxruntime = [
146 onnxruntime
147 onnxruntime-tools
148 ];
149 onnx = [
150 onnxconverter-common
151 tf2onnx
152 onnxruntime
153 onnxruntime-tools
154 ];
155 modelcreation = [ cookiecutter ];
156 sagemaker = [ sagemaker ];
157 deepspeed = [
158 # deepspeed
159 accelerate
160 ];
161 fairscale = [ fairscale ];
162 optuna = [ optuna ];
163 ray = [ ray ] ++ ray.optional-dependencies.tune;
164 # sigopt = [ sigopt ];
165 # integrations = ray ++ optuna ++ sigopt;
166 serving = [
167 pydantic
168 uvicorn
169 fastapi
170 starlette
171 ];
172 audio = audio;
173 speech = [ torchaudio ] ++ audio;
174 torch-speech = [ torchaudio ] ++ audio;
175 tf-speech = audio;
176 flax-speech = audio;
177 timm = [ timm ];
178 torch-vision = [ torchvision ] ++ vision;
179 # natten = [ natten ];
180 # codecarbon = [ codecarbon ];
181 video = [
182 av
183 ];
184 sentencepiece = [
185 sentencepiece
186 protobuf
187 ];
188 };
189
190 # Many tests require internet access.
191 doCheck = false;
192
193 pythonImportsCheck = [ "transformers" ];
194
195 meta = {
196 broken = lib.versionAtLeast huggingface-hub.version "1.0";
197 homepage = "https://github.com/huggingface/transformers";
198 description = "Natural Language Processing for TensorFlow 2.0 and PyTorch";
199 mainProgram = "transformers-cli";
200 changelog = "https://github.com/huggingface/transformers/releases/tag/${finalAttrs.src.tag}";
201 license = lib.licenses.asl20;
202 platforms = lib.platforms.unix;
203 maintainers = with lib.maintainers; [
204 pashashocky
205 happysalada
206 ];
207 };
208})