Skip to content

Commit d0c0561

Browse files
committed
initial import, version 0.2.60
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
1 parent 926efc4 commit d0c0561

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/llama-cpp-python-0.2.60.tar.gz
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From 854fa8a9114778e9c386201b8fa2ca413dfdd2cd Mon Sep 17 00:00:00 2001
2+
From: Tomas Tomecek <ttomecek@redhat.com>
3+
Date: Tue, 9 Apr 2024 13:08:58 +0200
4+
Subject: [PATCH] don't build llama.cpp and llava
5+
6+
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
7+
---
8+
CMakeLists.txt | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/CMakeLists.txt b/CMakeLists.txt
12+
index 70f9b99..e48cd3c 100644
13+
--- a/CMakeLists.txt
14+
+++ b/CMakeLists.txt
15+
@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 3.21)
16+
17+
project(llama_cpp)
18+
19+
-option(LLAMA_BUILD "Build llama.cpp shared library and install alongside python package" ON)
20+
-option(LLAVA_BUILD "Build llava shared library and install alongside python package" ON)
21+
+option(LLAMA_BUILD "Build llama.cpp shared library and install alongside python package" OFF)
22+
+option(LLAVA_BUILD "Build llava shared library and install alongside python package" OFF)
23+
24+
if (LLAMA_BUILD)
25+
set(BUILD_SHARED_LIBS "On")
26+
--
27+
2.44.0
28+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 6ff51f64a0472e4bc83a4a64d170a1791ce88e1a Mon Sep 17 00:00:00 2001
2+
From: Tomas Tomecek <ttomecek@redhat.com>
3+
Date: Thu, 11 Apr 2024 09:47:29 +0200
4+
Subject: [PATCH] search for libllama.so in /usr/lib64
5+
6+
Signed-off-by: Tomas Tomecek <ttomecek@redhat.com>
7+
---
8+
llama_cpp/llama_cpp.py | 1 +
9+
1 file changed, 1 insertion(+)
10+
11+
diff --git a/llama_cpp/llama_cpp.py b/llama_cpp/llama_cpp.py
12+
index accc02c..731abe5 100644
13+
--- a/llama_cpp/llama_cpp.py
14+
+++ b/llama_cpp/llama_cpp.py
15+
@@ -31,6 +31,7 @@ def _load_shared_library(lib_base_name: str):
16+
if sys.platform.startswith("linux"):
17+
_lib_paths += [
18+
_base_path / f"lib{lib_base_name}.so",
19+
+ pathlib.Path(f"/usr/lib64/lib{lib_base_name}.so")
20+
]
21+
elif sys.platform == "darwin":
22+
_lib_paths += [
23+
--
24+
2.44.0
25+

python-llama-cpp-python.spec

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
%global pypi_name llama-cpp-python
2+
%global pypi_version 0.2.60
3+
# it's all python code
4+
%global debug_package %{nil}
5+
6+
Name: python-%{pypi_name}
7+
Version: %{pypi_version}
8+
Release: %autorelease
9+
License: MIT
10+
Summary: Simple Python bindings for @ggerganov's llama.cpp library
11+
URL: https://github.com/abetlen/llama-cpp-python
12+
Source: %{url}/archive/v%{version}/%{pypi_name}-%{version}.tar.gz
13+
Patch1: 0001-don-t-build-llama.cpp-and-llava.patch
14+
Patch2: 0002-search-for-libllama-so-in-usr-lib64.patch
15+
16+
%bcond_with test
17+
18+
# this is what llama-cpp is on
19+
# and this library is by default installed in /usr/lib64/python3.12/site-packages/llama_cpp/__init__.py
20+
ExclusiveArch: x86_64 aarch64
21+
22+
BuildRequires: git-core
23+
BuildRequires: gcc
24+
BuildRequires: gcc-c++
25+
BuildRequires: ninja-build
26+
BuildRequires: python3-devel
27+
BuildRequires: llama-cpp-devel
28+
%if %{with test}
29+
BuildRequires: python3-pytest
30+
BuildRequires: python3-scipy
31+
%endif
32+
33+
%generate_buildrequires
34+
%pyproject_buildrequires
35+
36+
%description
37+
%{pypi_name} provides:
38+
Low-level access to C API via `ctypes` interface.
39+
High-level Python API for text completion.
40+
OpenAI compatible web server
41+
42+
%package -n python3-%{pypi_name}
43+
Summary: %{summary}
44+
# -devel has the unversioned libllama.so
45+
Requires: llama-cpp-devel
46+
47+
%description -n python3-%{pypi_name}
48+
%{pypi_name} provides:
49+
Low-level access to C API via `ctypes` interface.
50+
High-level Python API for text completion.
51+
OpenAI compatible web server
52+
53+
54+
%prep
55+
%autosetup -p1 -n %{pypi_name}-%{version} -Sgit
56+
57+
%build
58+
%pyproject_wheel
59+
60+
%if %{with test}
61+
%check
62+
# most test_llama.py tests utilize model ggml-vocab-llama.gguf from vendored llama.cpp
63+
%pytest -vs tests/test_llama.py::test_llama_cpp_version tests/test_llama.py::test_logits_to_logprobs tests/test_llama_speculative.py tests/test_llama_chat_format.py tests/test_llama_grammar.py
64+
%endif
65+
66+
%install
67+
%pyproject_install
68+
%pyproject_save_files -l llama_cpp
69+
70+
%files -n python3-%{pypi_name} -f %{pyproject_files}
71+
%license LICENSE.md
72+
%doc README.md
73+
74+
%changelog
75+
%autochangelog
76+

sources

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SHA512 (llama-cpp-python-0.2.60.tar.gz) = a556054e67c04838b07fa4c768766899a27e6ea0edc55f2fa0d77f6a4dc4c3f1f44cf530f68ca2df0e26b22b6ce059a2a652db9586273e908d35b544372d9e7f

0 commit comments

Comments
 (0)