Skip to content

File tree

5 files changed

+13
-40
lines changed

5 files changed

+13
-40
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
data/
12
.python-version
23

34
.vscode/

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,16 @@ project(llama_cpp)
55
option(LLAMA_BUILD "Build llama.cpp shared library and install alongside python package" ON)
66

77
if (LLAMA_BUILD)
8-
set(BUILD_SHARED_LIBS "On")
9-
if (APPLE AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
10-
# Need to disable these llama.cpp flags on Apple x86_64,
11-
# otherwise users may encounter invalid instruction errors
12-
set(LLAMA_AVX "Off" CACHE BOOL "llama: enable AVX" FORCE)
13-
set(LLAMA_AVX2 "Off" CACHE BOOL "llama: enable AVX2" FORCE)
14-
set(LLAMA_FMA "Off" CACHE BOOL "llama: enable FMA" FORCE)
15-
set(LLAMA_F16C "Off" CACHE BOOL "llama: enable F16C" FORCE)
8+
include(ExternalProject)
9+
if(NOT DEFINED SKBUILD_PLATLIB_DIR)
10+
set(SKBUILD_PLATLIB_DIR ${CMAKE_SOURCE_DIR})
1611
endif()
17-
add_subdirectory(vendor/llama.cpp)
18-
install(
19-
TARGETS llama
20-
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
21-
RUNTIME DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
22-
ARCHIVE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
23-
FRAMEWORK DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
24-
RESOURCE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
25-
)
26-
# Temporary fix for https://github.com/scikit-build/scikit-build-core/issues/374
27-
install(
28-
TARGETS llama
29-
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
30-
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
31-
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
32-
FRAMEWORK DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
33-
RESOURCE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
34-
)
35-
# Workaround for Windows + CUDA https://github.com/abetlen/llama-cpp-python/issues/563
36-
install(
37-
FILES $<TARGET_RUNTIME_DLLS:llama>
38-
DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
39-
)
40-
install(
41-
FILES $<TARGET_RUNTIME_DLLS:llama>
42-
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
43-
)
12+
ExternalProject_Add(
13+
llama-cpp
14+
GIT_REPOSITORY "https://github.com/ggerganov/llama.cpp"
15+
GIT_TAG f5ef5cf
16+
CMAKE_ARGS -DBUILD_SHARED_LIBS=ON "-DCMAKE_INSTALL_PREFIX=${SKBUILD_PLATLIB_DIR}/llama_cpp/data"
17+
USES_TERMINAL_DOWNLOAD 1
18+
USES_TERMINAL_CONFIGURE 1
19+
USES_TERMINAL_BUILD 1)
4420
endif()

llama_cpp/llama_cpp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# Load the library
2626
def _load_shared_library(lib_base_name: str):
2727
# Construct the paths to the possible shared library names
28-
_base_path = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
28+
_base_path = pathlib.Path(os.path.abspath(os.path.dirname(__file__))) / "data" / "lib"
2929
# Searching for the library in the current directory under the name "libllama" (default name
3030
# for llamacpp) and "llama" (default name for this repo)
3131
_lib_paths: List[pathlib.Path] = []

vendor/llama.cpp

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)