Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-wheel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,22 @@ jobs:

# Windows AMD64
- os: windows-latest
arch: auto
arch: AMD64
platform-id: win_amd64
python: 39
requires-python: ">=3.9,<3.10"
- os: windows-latest
arch: auto
arch: AMD64
platform-id: win_amd64
python: 310
requires-python: ">=3.10,<3.11"
- os: windows-latest
arch: auto
arch: AMD64
platform-id: win_amd64
python: 311
requires-python: ">=3.11,<3.12"
- os: windows-latest
arch: auto
arch: AMD64
platform-id: win_amd64
python: 312
requires-python: ">=3.12,<3.13"
Expand Down
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@ endif

all: build

build_llama_cpp:
build:
@bash scripts/setup.sh

build: build_llama_cpp
@git diff thirdparty > changes.diff
@python3 setup.py build_ext --inplace


python setup.py build_ext --inplace

wheel:
@echo "WITH_DYLIB=$(WITH_DYLIB)"
@python3 setup.py bdist_wheel
@python setup.py bdist_wheel
ifeq ($(WITH_DYLIB),1)
delocate-wheel -v dist/*.whl
endif
Expand Down
8 changes: 4 additions & 4 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ build_llamacpp() {
cd build && \
cmake .. -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DCMAKE_INSTALL_LIBDIR=lib && \
cmake --build . --config Release && \
cmake --install . --prefix ${PREFIX} && \
cp common/libcommon.a ${LIB} && \
cp examples/llava/libllava_static.a ${LIB}/libllava.a && \
cd ${CWD}
cmake --install . --prefix ${PREFIX}
[[ -e common/libcommon.a ]] && cp common/libcommon.a ${LIB}
[[ -e common/Release/common.lib ]] && cp common/Release/common.lib ${LIB}
cd ${CWD}
}

get_llamacpp_shared() {
Expand Down
34 changes: 14 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

PLATFORM = platform.system()

WITH_DYLIB = os.getenv("WITH_DYLIB", False)
LLAMACPP_INCLUDES_DIR = os.path.join(CWD, "src/llama.cpp/include")
LLAMACPP_LIBS_DIR = os.path.join(CWD, "src/llama.cpp/lib")

Expand All @@ -27,25 +26,20 @@
INCLUDE_DIRS = [
"src/pyllama",
LLAMACPP_INCLUDES_DIR,
os.path.join(CWD, "thirdparty/llama.cpp"), # For including 'common/base64.hpp' in server/utils.hpp
os.path.join(
CWD, "thirdparty/llama.cpp"
), # For including 'common/base64.hpp' in server/utils.hpp
os.path.join(CWD, "thirdparty/llama.cpp/examples/server"),
]
LIBRARY_DIRS = [
LLAMACPP_LIBS_DIR,
]
LIBRARIES = ["pthread"]
LIBRARIES = []


if WITH_DYLIB:
EXTRA_OBJECTS.append(f"{LLAMACPP_LIBS_DIR}/libcommon.a")
LIBRARIES.extend(
[
"common",
"ggml",
"llama",
]
)
if PLATFORM == "Windows":
LIBRARIES.extend(["common", "llama", "ggml", "ggml-base", "ggml-cpu", "Advapi32"])
else:
LIBRARIES.extend(["pthread"])
EXTRA_OBJECTS.extend(
[
f"{LLAMACPP_LIBS_DIR}/libcommon.a",
Expand All @@ -55,13 +49,13 @@
f"{LLAMACPP_LIBS_DIR}/libggml-cpu.a",
]
)
if PLATFORM == "Darwin":
EXTRA_OBJECTS.extend(
[
f"{LLAMACPP_LIBS_DIR}/libggml-blas.a",
f"{LLAMACPP_LIBS_DIR}/libggml-metal.a",
]
)
if PLATFORM == "Darwin":
EXTRA_OBJECTS.extend(
[
f"{LLAMACPP_LIBS_DIR}/libggml-blas.a",
f"{LLAMACPP_LIBS_DIR}/libggml-metal.a",
]
)

INCLUDE_DIRS.append(os.path.join(CWD, "src/pyllama"))

Expand Down