Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cb77a2

Browse filesBrowse files
committed
Migrate to scikit-build-core. Closes abetlen#489
1 parent c9985ab commit 6cb77a2
Copy full SHA for 6cb77a2

File tree

Expand file treeCollapse file tree

13 files changed

+96
-1763
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+96
-1763
lines changed

‎.github/workflows/build-and-release.yaml

Copy file name to clipboardExpand all lines: .github/workflows/build-and-release.yaml
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ jobs:
2626

2727
- name: Install dependencies
2828
run: |
29-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
29+
python -m pip install --upgrade pip
30+
python -m pip install -e .[all]
3031
3132
- name: Build wheels
3233
run: python -m cibuildwheel --output-dir wheelhouse
@@ -46,10 +47,11 @@ jobs:
4647
- uses: actions/setup-python@v3
4748
- name: Install dependencies
4849
run: |
49-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
50+
python -m pip install --upgrade pip build
51+
python -m pip install -e .[all]
5052
- name: Build source distribution
5153
run: |
52-
python setup.py sdist
54+
python -m build --sdist
5355
- uses: actions/upload-artifact@v3
5456
with:
5557
path: ./dist/*.tar.gz

‎.github/workflows/publish-to-test.yaml

Copy file name to clipboardExpand all lines: .github/workflows/publish-to-test.yaml
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ jobs:
1919
python-version: "3.8"
2020
- name: Install dependencies
2121
run: |
22-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
22+
python3 -m pip install --upgrade pip build
23+
python3 -m pip install -e .[all]
2324
- name: Build source distribution
2425
run: |
25-
python setup.py sdist
26+
python3 -m build --sdist
2627
- name: Publish to Test PyPI
2728
uses: pypa/gh-action-pypi-publish@release/v1
2829
with:

‎.github/workflows/publish.yaml

Copy file name to clipboardExpand all lines: .github/workflows/publish.yaml
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ jobs:
1919
python-version: "3.8"
2020
- name: Install dependencies
2121
run: |
22-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
22+
python3 -m pip install --upgrade pip build
23+
python3 -m pip install -e .[all]
2324
- name: Build source distribution
2425
run: |
25-
python setup.py sdist
26+
python3 -m build --sdist
2627
- name: Publish distribution to PyPI
2728
# TODO: move to tag based releases
2829
# if: startsWith(github.ref, 'refs/tags')

‎.github/workflows/test-pypi.yaml

Copy file name to clipboardExpand all lines: .github/workflows/test-pypi.yaml
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install dependencies
1919
run: |
2020
python3 -m pip install --upgrade pip
21-
python3 -m pip install --verbose llama-cpp-python[server,test]
21+
python3 -m pip install --verbose llama-cpp-python[all]
2222
- name: Test with pytest
2323
run: |
2424
python3 -c "import llama_cpp"
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python3 -m pip install --upgrade pip
41-
python3 -m pip install --verbose llama-cpp-python[server,test]
41+
python3 -m pip install --verbose llama-cpp-python[all]
4242
- name: Test with pytest
4343
run: |
4444
python3 -c "import llama_cpp"
@@ -58,7 +58,7 @@ jobs:
5858
- name: Install dependencies
5959
run: |
6060
python3 -m pip install --upgrade pip
61-
python3 -m pip install --verbose llama-cpp-python[server,test]
61+
python3 -m pip install --verbose llama-cpp-python[all]
6262
- name: Test with pytest
6363
run: |
6464
python3 -c "import llama_cpp"

‎.github/workflows/test.yaml

Copy file name to clipboardExpand all lines: .github/workflows/test.yaml
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
python-version: ${{ matrix.python-version }}
2727
- name: Install dependencies
2828
run: |
29-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn pydantic-settings
30-
pip install . -v
29+
python3 -m pip install --upgrade pip
30+
python3 -m pip install .[all] -v
3131
- name: Test with pytest
3232
run: |
33-
pytest
33+
python3 -m pytest
3434
3535
build-windows:
3636

@@ -49,11 +49,11 @@ jobs:
4949
python-version: ${{ matrix.python-version }}
5050
- name: Install dependencies
5151
run: |
52-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn pydantic-settings
53-
pip install . -v
52+
python3 -m pip install --upgrade pip
53+
python3 -m pip install .[all] -v
5454
- name: Test with pytest
5555
run: |
56-
pytest
56+
python3 -m pytest
5757
5858
build-macos:
5959

@@ -72,8 +72,8 @@ jobs:
7272
python-version: ${{ matrix.python-version }}
7373
- name: Install dependencies
7474
run: |
75-
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn pydantic-settings
76-
pip install . -v
75+
python3 -m pip install --upgrade pip
76+
python3 -m pip install .[all] -v
7777
- name: Test with pytest
7878
run: |
79-
pytest
79+
python3 -m pytest

‎CMakeLists.txt

Copy file name to clipboardExpand all lines: CMakeLists.txt
+16-22Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,27 @@ cmake_minimum_required(VERSION 3.4...3.22)
22

33
project(llama_cpp)
44

5-
option(FORCE_CMAKE "Force CMake build of Python bindings" OFF)
5+
option(BUILD_LLAMA_CPP "Build llama.cpp shared library and install alongside python package" ON)
66

7-
set(FORCE_CMAKE $ENV{FORCE_CMAKE})
87

9-
if (UNIX AND NOT FORCE_CMAKE)
10-
add_custom_command(
11-
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
12-
COMMAND make libllama.so
13-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp
14-
)
15-
add_custom_target(
16-
run ALL
17-
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
18-
)
19-
install(
20-
FILES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
21-
DESTINATION llama_cpp
22-
)
23-
else()
8+
if (BUILD_LLAMA_CPP)
249
set(BUILD_SHARED_LIBS "On")
2510
add_subdirectory(vendor/llama.cpp)
2611
install(
2712
TARGETS llama
28-
LIBRARY DESTINATION llama_cpp
29-
RUNTIME DESTINATION llama_cpp
30-
ARCHIVE DESTINATION llama_cpp
31-
FRAMEWORK DESTINATION llama_cpp
32-
RESOURCE DESTINATION llama_cpp
13+
LIBRARY DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
14+
RUNTIME DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
15+
ARCHIVE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
16+
FRAMEWORK DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
17+
RESOURCE DESTINATION ${SKBUILD_PLATLIB_DIR}/llama_cpp
18+
)
19+
# Temporary fix for https://github.com/scikit-build/scikit-build-core/issues/374
20+
install(
21+
TARGETS llama
22+
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
23+
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
24+
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
25+
FRAMEWORK DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
26+
RESOURCE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
3327
)
3428
endif()

‎Makefile

Copy file name to clipboardExpand all lines: Makefile
+11-7Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,30 @@ update:
55
update.vendor:
66
cd vendor/llama.cpp && git pull origin master
77

8+
deps:
9+
python3 -m pip install pip
10+
python3 -m pip install -e ".[all]"
11+
812
build:
9-
python3 setup.py develop
13+
python3 -m pip install -e .
1014

1115
build.cuda:
12-
CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 python3 setup.py develop
16+
CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 python3 -m pip install -e .
1317

1418
build.opencl:
15-
CMAKE_ARGS="-DLLAMA_CLBLAST=on" FORCE_CMAKE=1 python3 setup.py develop
19+
CMAKE_ARGS="-DLLAMA_CLBLAST=on" FORCE_CMAKE=1 python3 -m pip install -e .
1620

1721
build.openblas:
18-
CMAKE_ARGS="-DLLAMA_OPENBLAS=on" FORCE_CMAKE=1 python3 setup.py develop
22+
CMAKE_ARGS="-DLLAMA_CLBLAST=on" FORCE_CMAKE=1 python3 -m pip install -e .
1923

2024
build.blis:
21-
CMAKE_ARGS="-DLLAMA_OPENBLAS=on -DLLAMA_OPENBLAS_VENDOR=blis" FORCE_CMAKE=1 python3 setup.py develop
25+
CMAKE_ARGS="-DLLAMA_OPENBLAS=on -DLLAMA_OPENBLAS_VENDOR=blis" FORCE_CMAKE=1 python3 -m pip install -e .
2226

2327
build.metal:
24-
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 python3 setup.py develop
28+
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 python3 -m pip install -e .
2529

2630
build.sdist:
27-
python3 setup.py sdist
31+
python3 -m build --sdist
2832

2933
deploy.pypi:
3034
python3 -m twine upload dist/*

‎README.md

Copy file name to clipboardExpand all lines: README.md
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,6 @@ pip install -e .
180180

181181
# if you want to use the fastapi / openapi server
182182
pip install -e .[server]
183-
184-
# If you're a poetry user, installing will also include a virtual environment
185-
poetry install --all-extras
186-
. .venv/bin/activate
187-
188-
# Will need to be re-run any time vendor/llama.cpp is updated
189-
python3 setup.py develop
190183
```
191184

192185
# How does this compare to other Python bindings of `llama.cpp`?

‎docker/simple/Dockerfile

Copy file name to clipboardExpand all lines: docker/simple/Dockerfile
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ RUN mkdir /app
1919
WORKDIR /app
2020
COPY . /app
2121

22-
RUN python3 -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi uvicorn sse-starlette pydantic-settings
22+
RUN python3 -m pip install --upgrade pip
2323

24-
RUN make build && make clean
24+
RUN make deps && make build && make clean
2525

2626
# Set environment variable for the host
2727
ENV HOST=0.0.0.0

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.