Skip to content

Commit 17c58cd

Browse files
committed
python312Packages.llama-cpp-python: init at 0.3.1
1 parent e4ee732 commit 17c58cd

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
lib,
3+
buildPythonPackage,
4+
cmake,
5+
fetchFromGitHub,
6+
gitUpdater,
7+
ninja,
8+
pathspec,
9+
pyproject-metadata,
10+
pytestCheckHook,
11+
pythonOlder,
12+
scikit-build-core,
13+
14+
config,
15+
cudaSupport ? config.cudaSupport,
16+
cudaPackages ? { },
17+
18+
diskcache,
19+
jinja2,
20+
numpy,
21+
typing-extensions,
22+
scipy,
23+
huggingface-hub,
24+
}:
25+
26+
buildPythonPackage rec {
27+
pname = "llama-cpp-python";
28+
version = "0.3.1";
29+
pyproject = true;
30+
31+
disabled = pythonOlder "3.7";
32+
33+
src = fetchFromGitHub {
34+
owner = "abetlen";
35+
repo = "llama-cpp-python";
36+
rev = "refs/tags/v${version}";
37+
hash = "sha256-eO1zvNJZBE5BCnbgbh00tFIRWBCWor1lIsrLXs/HFds=";
38+
fetchSubmodules = true;
39+
};
40+
41+
dontUseCmakeConfigure = true;
42+
SKBUILD_CMAKE_ARGS = lib.strings.concatStringsSep ";" (
43+
lib.optionals cudaSupport [
44+
"-DGGML_CUDA=on"
45+
"-DCUDAToolkit_ROOT=${lib.getDev cudaPackages.cuda_nvcc}"
46+
"-DCMAKE_CUDA_COMPILER=${lib.getExe cudaPackages.cuda_nvcc}"
47+
]
48+
);
49+
50+
nativeBuildInputs = [
51+
cmake
52+
ninja
53+
pathspec
54+
pyproject-metadata
55+
scikit-build-core
56+
];
57+
58+
buildInputs = lib.optionals cudaSupport (
59+
with cudaPackages;
60+
[
61+
cuda_cudart # cuda_runtime.h
62+
cuda_cccl # <thrust/*>
63+
libcublas # cublas_v2.h
64+
]
65+
);
66+
67+
propagatedBuildInputs = [
68+
diskcache
69+
jinja2
70+
numpy
71+
typing-extensions
72+
];
73+
74+
nativeCheckInputs = [
75+
pytestCheckHook
76+
scipy
77+
huggingface-hub
78+
];
79+
80+
disabledTests = [
81+
# tries to download model from huggingface-hub
82+
"test_real_model"
83+
"test_real_llama"
84+
];
85+
86+
pythonImportsCheck = [ "llama_cpp" ];
87+
88+
passthru.updateScript = gitUpdater { rev-prefix = "v"; };
89+
90+
meta = {
91+
description = "Python bindings for llama.cpp";
92+
homepage = "https://github.com/abetlen/llama-cpp-python";
93+
license = lib.licenses.mit;
94+
maintainers = with lib.maintainers; [ kirillrdy ];
95+
};
96+
}

pkgs/top-level/python-packages.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7366,6 +7366,8 @@ self: super: with self; {
73667366

73677367
lizard = callPackage ../development/python-modules/lizard { };
73687368

7369+
llama-cpp-python = callPackage ../development/python-modules/llama-cpp-python { };
7370+
73697371
llama-cloud = callPackage ../development/python-modules/llama-cloud { };
73707372

73717373
llama-index = callPackage ../development/python-modules/llama-index { };

0 commit comments

Comments
 (0)