diff --git a/.github/workflows/build-wheel.yaml b/.github/workflows/build-wheel.yaml index e5e12139..8fde084d 100644 --- a/.github/workflows/build-wheel.yaml +++ b/.github/workflows/build-wheel.yaml @@ -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" diff --git a/Makefile b/Makefile index ce800bda..89855cdb 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/scripts/setup.sh b/scripts/setup.sh index ee4be550..2c5937b6 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -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() { diff --git a/setup.py b/setup.py index debad004..5588e83d 100644 --- a/setup.py +++ b/setup.py @@ -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") @@ -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", @@ -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"))