Skip to content

Commit

Permalink
Merge pull request #350 from abetlen/migrate-to-scikit-build-core
Browse files Browse the repository at this point in the history
Migrate to scikit-build-core
  • Loading branch information
abetlen authored Jun 9, 2023
2 parents 202ed44 + b025a85 commit fb2c5f7
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 147 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ jobs:
- uses: actions/setup-python@v3

- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.12.1
run: python3 -m pip install cibuildwheel==2.12.1

- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --upgrade pip
python3 -m pip install --verbose --editable .
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
run: python3 -m cibuildwheel --output-dir wheelhouse

- uses: actions/upload-artifact@v3
with:
Expand All @@ -46,10 +47,11 @@ jobs:
- uses: actions/setup-python@v3
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --upgrade pip build
python3 -m pip install --verbose --editable .
- name: Build source distribution
run: |
python setup.py sdist
python3 -m build --sdist
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.tar.gz
Expand Down
39 changes: 0 additions & 39 deletions .github/workflows/build-docker.yaml

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/publish-to-test.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools
python3 -m pip install --upgrade pip build
- name: Build source distribution
run: |
python setup.py sdist
python3 -m build --sdist
- name: Publish distribution to PyPI
# TODO: move to tag based releases
# if: startsWith(github.ref, 'refs/tags')
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn
pip install . -v
python3 -m pip install --upgrade pip
python3 -m pip install --verbose --editable .[server,test]
- name: Test with pytest
run: |
pytest
python3 -m pytest
build-windows:

Expand All @@ -49,11 +49,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn
pip install . -v
python3 -m pip install --upgrade pip
python3 -m pip install --verbose --editable .[server,test]
- name: Test with pytest
run: |
pytest
python3 -m pytest
build-macos:

Expand All @@ -72,8 +72,8 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip pytest cmake scikit-build setuptools fastapi sse-starlette httpx uvicorn
pip install . -v
python3 -m pip install --upgrade pip
python3 -m pip install --verbose --editable .[server,test]
- name: Test with pytest
run: |
pytest
python3 -m pytest
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- (build-system) Migrate from scikit-build to scikit-build-core

## [v0.1.59]

### Added
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ if (UNIX AND NOT FORCE_CMAKE)
)
install(
FILES ${CMAKE_CURRENT_SOURCE_DIR}/vendor/llama.cpp/libllama.so
DESTINATION llama_cpp
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
)
else()
set(BUILD_SHARED_LIBS "On")
add_subdirectory(vendor/llama.cpp)
install(
TARGETS llama
LIBRARY DESTINATION llama_cpp
RUNTIME DESTINATION llama_cpp
ARCHIVE DESTINATION llama_cpp
FRAMEWORK DESTINATION llama_cpp
LIBRARY DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
RUNTIME DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
ARCHIVE DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
FRAMEWORK DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/llama_cpp
)
endif()
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,38 @@
update:
poetry install
python3 -m pip install --upgrade pip
git submodule update --init --recursive

update.vendor:
cd vendor/llama.cpp && git pull origin master

build:
python3 setup.py develop
python3 -m pip install --upgrade pip
python3 -m pip install --verbose --editable .

build.cuda:
CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 python3 setup.py develop
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_CUBLAS=on" FORCE_CMAKE=1 python3 -m pip install --verbose --editable .

build.opencl:
CMAKE_ARGS="-DLLAMA_CLBLAST=on" FORCE_CMAKE=1 python3 setup.py develop
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_CLBLAST=on" FORCE_CMAKE=1 python3 -m pip install --verbose --editable .

build.openblas:
CMAKE_ARGS="-DLLAMA_OPENBLAS=on" FORCE_CMAKE=1 python3 setup.py develop
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_OPENBLAS=on" FORCE_CMAKE=1 python3 -m pip install --verbose --editable .

build.blis:
CMAKE_ARGS="-DLLAMA_OPENBLAS=on -DLLAMA_OPENBLAS_VENDOR=blis" FORCE_CMAKE=1 python3 setup.py develop
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_OPENBLAS=on -DLLAMA_OPENBLAS_VENDOR=blis" FORCE_CMAKE=1 python3 -m pip install --verbose --editable .

build.metal:
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 python3 setup.py develop
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_METAL=on" FORCE_CMAKE=1 python3 -m pip install --verbose --editable .

build.sdist:
python3 setup.py sdist
python3 -m pip install --upgrade pip build
python3 -m build --sdist

deploy.pypi:
python3 -m twine upload dist/*
Expand All @@ -36,7 +44,6 @@ deploy.gh-docs:
clean:
- cd vendor/llama.cpp && make clean
- cd vendor/llama.cpp && rm libllama.so
- rm -rf _skbuild
- rm llama_cpp/*.so
- rm llama_cpp/*.dylib
- rm llama_cpp/*.dll
Expand Down
56 changes: 39 additions & 17 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,47 @@
[tool.poetry]
[build-system]
requires = [
"scikit-build-core>=0.4.4",
"cmake>=3.18",
"ninja",
]
build-backend = "scikit_build_core.build"

[project]
name = "llama_cpp_python"
version = "0.1.59"
description = "Python bindings for the llama.cpp library"
authors = ["Andrei Betlen <abetlen@gmail.com>"]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/abetlen/llama-cpp-python"
repository = "https://github.com/abetlen/llama-cpp-python"
packages = [{include = "llama_cpp"}]
include = [
"LICENSE.md",
license = { text = "MIT" }
authors = [
{ name = "Andrei Betlen", email = "abetlen@gmail.com" },
]
requires-python = ">=3.7"
dependencies = [
"typing-extensions>=4.5.0",
"numpy>=1.20.0",
"diskcache>=5.6.1",
]
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]

[tool.scikit-build]
wheel.packages = ["llama_cpp", "llama_cpp.server"]
wheel.expand-macos-universal-tags = true
cmake.verbose = true

[project.optional-dependencies]
server = [
"uvicorn",
"fastapi",
"sse-starlette",
]
test = ["pytest", "httpx"]

[tool.poetry.dependencies]
python = "^3.8.1"
Expand All @@ -33,12 +64,3 @@ scikit-build = "0.17.6"

[tool.poetry.extras]
server = ["uvicorn", "fastapi", "sse-starlette"]

[build-system]
requires = [
"setuptools>=42",
"scikit-build>=0.13",
"cmake>=3.18",
"ninja",
]
build-backend = "setuptools.build_meta"
32 changes: 0 additions & 32 deletions setup.py

This file was deleted.

0 comments on commit fb2c5f7

Please sign in to comment.