-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbindings.nix
601 lines (536 loc) · 14.7 KB
/
bindings.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
final: prev:
let
inherit (prev) buildPythonPackage;
inherit (prev.stdenv) isAarch64 isDarwin;
inherit (prev.pkgs) fetchFromGitHub darwin writeTextFile;
inherit (prev.lib) licenses maintainers;
isM1 = isDarwin && isAarch64;
llama-cpp-pin = fetchFromGitHub {
owner = "ggerganov";
repo = "llama.cpp";
rev = "ce8784bdb153ff7794dde5a50b0ebfa51baa6171";
hash = "sha256-jhr/KHVwqFMIY7tkn531VXdzPyDtphhAOkS+RphGwZ8=";
};
in
rec {
gguf = buildPythonPackage {
pname = "gguf";
version = "0.0.1";
pyproject = true;
src = llama-cpp-pin;
postPatch = ''
cd ./gguf-py
'';
propagatedBuildInputs = with prev; [ numpy ];
nativeBuildInputs = with prev; [
poetry-core
];
pythonImportsCheck = [ "gguf" ];
meta = {
description = "package for writing binary files in the GGUF (GGML Universal File) format";
homepage = "https://github.com/ggerganov/llama.cpp/tree/master/gguf-py";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
ggml-python =
let
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate MetalKit MetalPerformanceShaders MetalPerformanceShadersGraph ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
in
buildPythonPackage rec {
pname = "ggml-python";
version = "0.0.1";
pyproject = true;
src = fetchFromGitHub {
owner = "abetlen";
repo = pname;
rev = "c4cb698cd2068addafe0b2b4fd3c63b49061f5c8";
# rev = "refs/tags/v${version}";
hash = "sha256-jMjkJYXUGA0PL0FoZOXpeHScVS0s2i0izhQbPk4iJsA=";
fetchSubmodules = true;
};
CMAKE_ARGS = if isM1 then "-DLLAMA_METAL=on" else null;
FORCE_CMAKE = if isM1 then "1" else null;
# let's remove this - we propagate it below
postPatch = ''
sed -i -E '/typing_extensions/d' ./pyproject.toml
'';
preBuild = ''
cd ..
'';
buildInputs = osSpecific;
nativeBuildInputs = with prev; [
pkgs.cmake
pkgs.ninja
pathspec
poetry-core
pyproject-metadata
scikit-build
scikit-build-core
setuptools
];
propagatedBuildInputs = with prev; [
numpy
typing-extensions
# server mode
fastapi
sse-starlette
uvicorn
];
pythonImportsCheck = [ "ggml" ];
meta = {
description = "Python bindings for ggml";
homepage = "https://github.com/abetlen/ggml-python";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
pyllamacpp =
let
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
in
buildPythonPackage rec {
pname = "pyllamacpp";
version = "2.4.3";
pyproject = true;
src = fetchFromGitHub {
owner = "abdeladim-s";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-uBlequjMBOG9utBTj2fj291tO+BkKyaoStfrbxk+iDY=";
fetchSubmodules = true;
};
preBuild = ''
sed -E -i \
-e '/"ninja/d' \
-e '/"cmake/d' \
./pyproject.toml
'';
buildInputs = osSpecific;
nativeBuildInputs = with prev; [
pkgs.cmake
pkgs.ninja
setuptools
wheel
];
pythonImportsCheck = [ "pyllamacpp" ];
dontUseCmakeConfigure = true;
meta = {
description = "Python bindings for llama.cpp";
homepage = "https://github.com/abdeladim-s/pyllamacpp";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
pygptj =
let
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
in
buildPythonPackage rec {
pname = "pygptj";
version = "2.0.3";
pyproject = true;
src = fetchFromGitHub {
owner = "abdeladim-s";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-Ub7qXARiOIpT4UaI9mACtrRUiPbIQgABUias3TNDqP0=";
fetchSubmodules = true;
};
buildInputs = osSpecific;
nativeBuildInputs = with prev; [
pkgs.cmake
pkgs.ninja
setuptools
wheel
];
dontUseCmakeConfigure = true;
propagatedBuildInputs = with prev; [
numpy
];
pythonImportsCheck = [ "pygptj" ];
meta = {
description = "Python bindings for the GGML GPT-J Laguage model";
homepage = "https://github.com/abdeladim-s/pygptj";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
pygpt4all = buildPythonPackage rec {
pname = "pygpt4all";
version = "1.1.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "nomic-ai";
repo = pname;
rev = "refs/tags/v${version}";
hash = "sha256-4/AogNqSv2bBugkXj4T5G6xgr2tubZNkBpUu/CUDYko=";
};
pythonImportsCheck = [ "pygpt4all" ];
propagatedBuildInputs = [
pyllamacpp
pygptj
];
meta = {
description = "Official Python CPU inference for GPT4All language models based on llama.cpp and ggml";
homepage = "https://github.com/nomic-ai/pygpt4all";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
rwkv-cpp =
let
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
version = "0.0.1";
libFile = if isDarwin then "librwkv.dylib" else "librwkv.so";
setup-py = writeTextFile {
name = "setup.py";
text = ''
from setuptools import setup
setup(
name="rwkv_cpp",
version="${version}",
author="",
author_email="",
packages=["."],
package_data={"":["${libFile}"]},
setup_requires=["numpy", "torch", "tokenizers"],
install_requires=[],
)
'';
};
in
buildPythonPackage {
inherit version;
pname = "rwkv-cpp";
pyproject = true;
src = fetchFromGitHub {
owner = "saharNooby";
repo = "rwkv.cpp";
rev = "1c363e6d5f4ec7817ceffeeb17bd972b1ce9d9d0";
hash = "sha256-IU+3MwIY3NnJPYtxrgpphLOnHAOQAKYd+8BV1tusgC4=";
fetchSubmodules = true;
};
preBuild = ''
cd ..
cp ./rwkv/rwkv_cpp_model.py .
cp ./rwkv/rwkv_cpp_shared_library.py .
cp ${setup-py} ./setup.py
mkdir -p ./bin/Release
cmake .
cmake --build . --config Release
sed -i -E "s#(paths = \[)#\1'$out/${prev.python.sitePackages}/${libFile}',#g" ./rwkv_cpp_shared_library.py
'';
buildInputs = osSpecific;
nativeBuildInputs = with prev; [
pkgs.cmake
pkgs.ninja
poetry-core
scikit-build
setuptools
];
propagatedBuildInputs = with prev; [
numpy
tokenizers
torch
typing-extensions
];
pythonImportsCheck = [
"rwkv_cpp_model"
"rwkv_cpp_shared_library"
];
meta = {
description = "";
homepage = "https://github.com/saharNooby/rwkv.cpp";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
rwkv = buildPythonPackage rec {
pname = "rwkv";
version = "0.8.22";
pyproject = true;
src = final.fetchPypi {
inherit pname version;
hash = "sha256-7kSOmP4r2ZLh1l5JB19Z/vf4opskX2u5ahS9ugerR1o=";
};
nativeBuildInputs = with final; [
setuptools
wheel
];
propagatedBuildInputs = with final; [
tokenizers
];
pythonImportsCheck = [ "rwkv" ];
meta = {
description = "The RWKV Language Model";
homepage = "https://pypi.org/project/rwkv/";
license = licenses.asl20;
maintainers = with maintainers; [ jpetrucciani ];
};
};
whisper-cpp-python =
let
name = "whisper-cpp-python";
version = "0.2.0";
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
in
buildPythonPackage {
inherit version;
pname = name;
pyproject = true;
src = fetchFromGitHub {
owner = "carloscdias";
repo = name;
rev = "0744238e10f6b1da3440d43aa3dff43d46b09b30";
hash = "sha256-Nj35UwCLD88SF26rqrNiLo1lUQTHAKUVKyMyaA0Cy7Q=";
fetchSubmodules = true;
};
postPatch = let sed = "sed -i -E"; in
if isDarwin then ''
${sed} 's#(_lib_base_name = )"whisper"#\1"libwhisper"#g' ./setup.py
${sed} 's#(lib_ext = )".so"#\1".dylib"#g' ./setup.py
''
else "";
preBuild = ''
cd ..
sed -E -i 's#(requires =).*#\1["scikit-build"]#g' ./pyproject.toml
'';
buildInputs = osSpecific;
pythonRelaxDeps = [ "librosa" ];
nativeBuildInputs = with prev; [
pythonRelaxDepsHook
pkgs.cmake
pkgs.ninja
pycparser
scikit-build
setuptools
] ++ (if isDarwin then [ prev.pkgs.gcc ] else [ ]);
propagatedBuildInputs = with prev; [
librosa
];
pythonImportsCheck = [ "whisper_cpp_python" ];
meta = {
description = "A Python wrapper for whisper.cpp";
homepage = "https://github.com/carloscdias/whisper-cpp-python";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
ctransformers =
let
name = "ctransformers";
version = "0.3.4";
osSpecific =
if isM1 then with darwin.apple_sdk_11_0.frameworks; [ Accelerate ]
else if isDarwin then with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics CoreVideo ]
else [ ];
in
buildPythonPackage {
inherit version;
pname = name;
format = "setuptools";
src = fetchFromGitHub {
owner = "marella";
repo = name;
rev = "refs/tags/v${version}";
hash = "sha256-Ub+1z7A4kabQiuL+E2UlHzwY6dFZHSYR4VuFk9ancTY=";
fetchSubmodules = true;
};
propagatedBuildInputs = with prev; [
huggingface-hub
py-cpuinfo
];
dontUseCmakeConfigure = true;
nativeBuildInputs = with prev; [
pkgs.cmake
scikit-build
];
buildInputs = osSpecific;
nativeCheckInputs = with prev; [ pytestCheckHook ];
pythonImportsCheck = [ "ctransformers" ];
disabledTestPaths = [ "tests/test_model.py" ];
pytestFlagsArray = [ "--lib basic" ];
meta = {
description = "Python bindings for the Transformer models implemented in C/C++ using GGML library";
homepage = "https://github.com/marella/ctransformers";
license = licenses.mit;
maintainers = with maintainers; [ jpetrucciani ];
};
};
google-cloud-aiplatform = buildPythonPackage rec {
pname = "google-cloud-aiplatform";
version = "1.27.0";
format = "setuptools";
src = fetchFromGitHub {
owner = "googleapis";
repo = "python-aiplatform";
rev = "refs/tags/v${version}";
hash = "sha256-0bSmOcU4gcjI9RiF2RJX9mki4faXSXbIJNVh9GGgjOE=";
};
# let's remove this - we propagate it below
postPatch = ''
sed -i -E '/shapely/d' ./setup.py
rm -rf ./samples
'';
# the tests require a variety of deps, and credentials
doCheck = false;
propagatedBuildInputs = with prev; [
google-api-core
google-cloud-bigquery
google-cloud-resource-manager
google-cloud-storage
packaging
proto-plus
protobuf
shapely
];
nativeCheckInputs = with prev; [
pytestCheckHook
pytest-asyncio
];
passthru.optional-dependencies = with prev; {
autologging = [
mlflow
];
cloud_profiler = [
tensorboard-plugin-profile
tensorflow
werkzeug
];
datasets = [
pyarrow
];
endpoint = [
requests
];
full = [
docker
explainable-ai-sdk
fastapi
google-cloud-bigquery-storage
google-vizier
lit-nlp
mlflow
numpy
pandas
pyarrow
pyyaml
requests
starlette
tensorflow
urllib3
uvicorn
];
lit = [
explainable-ai-sdk
lit-nlp
pandas
tensorflow
];
metadata = [
numpy
pandas
];
pipelines = [
pyyaml
];
prediction = [
docker
fastapi
starlette
uvicorn
];
private_endpoints = [
requests
urllib3
];
tensorboard = [
tensorflow
];
testing = [
docker
explainable-ai-sdk
fastapi
google-cloud-bigquery-storage
google-vizier
grpcio-testing
ipython
kfp
lit-nlp
mlflow
numpy
pandas
pyarrow
pytest-asyncio
pytest-xdist
pyyaml
requests
scikit-learn
starlette
tensorboard-plugin-profile
tensorflow
urllib3
uvicorn
werkzeug
xgboost
];
vizier = [
google-vizier
];
xai = [
tensorflow
];
};
pythonImportsCheck = [ "google.cloud.aiplatform" ];
meta = {
description = "Vertex AI API client library";
homepage = "https://github.com/googleapis/python-aiplatform";
license = licenses.asl20;
maintainers = with maintainers; [ jpetrucciani ];
};
};
groq = buildPythonPackage rec {
pname = "groq";
version = "0.4.1";
pyproject = true;
src = final.fetchPypi {
inherit pname version;
hash = "sha256-8ihcCn1kq+/N7D1h6LwaYf8E2IftMLmRrH/lOuHhAlE=";
};
nativeBuildInputs = with final; [
hatchling
];
propagatedBuildInputs = with final; [
anyio
cached-property
distro
httpx
pydantic
sniffio
typing-extensions
];
pythonImportsCheck = [ "groq" ];
meta = {
description = "The official Python library for the groq API";
homepage = "https://pypi.org/project/groq/";
license = licenses.asl20;
maintainers = with maintainers; [ jpetrucciani ];
};
};
}