Skip to content

Commit

Permalink
Merge pull request #1 from xhedit/conv
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
xhedit authored Apr 1, 2024
2 parents aa9f1ae + 49bc4ec commit 88c01c0
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 901 deletions.
24 changes: 22 additions & 2 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [ubuntu-latest, windows-latest]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -77,4 +77,24 @@ jobs:
with:
files: dist/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-sdist-to-pypi:
name: Release
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/llama_cpp_conv
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download the sdist
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.10
182 changes: 156 additions & 26 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -1,32 +1,162 @@
name: Publish to PyPI
name: Publish

# Based on: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

on: workflow_dispatch
on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
pypi:
description: 'Upload wheels to PyPI? 1 = yes, 0 = no'
default: '0'
required: true
type: string

jobs:
build-n-publish:
name: Build and publish
build-linux:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
with:
submodules: "recursive"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install build
python3 -m pip install .[all] -v
- name: Build Wheel
id: build-wheel-sdist
run: |
python -m build -n
- uses: actions/upload-artifact@v3
with:
name: 'wheel'
path: ./dist/* # Use ./dist/*.whl to only upload the JIT compile wheel

build-windows:

runs-on: windows-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install .[all] -v
- uses: actions/upload-artifact@v3
with:
name: 'wheel'
path: ./dist/* # Use ./dist/*.whl to only upload the JIT compile wheel


build-macos:

runs-on: macos-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip build
python3 -m pip install -e .[all]
- name: Build source distribution
run: |
python3 -m build --sdist
- name: Publish distribution to PyPI
# TODO: move to tag based releases
# if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install .[all] --verbose
- uses: actions/upload-artifact@v3
with:
name: 'wheel'
path: ./dist/* # Use ./dist/*.whl to only upload the JIT compile wheel

# build-linux-opencl:

# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v3
# with:
# submodules: "recursive"
# - name: Set up Python 3.8
# uses: actions/setup-python@v4
# with:
# python-version: "3.8"
# - name: Set up OpenCL & CLBlast
# run: |
# wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
# echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
# sudo apt-get update
# sudo apt-get install -y --no-install-recommends llvm intel-oneapi-runtime-opencl intel-oneapi-runtime-compilers libclblast-dev
# - name: Install dependencies
# run: |
# python3 -m pip install --upgrade pip
# CMAKE_ARGS="-DLLAMA_CLBLAST=on" python3 -m pip install .[all] --verbose


build-macos-metal:

runs-on: macos-latest

steps:
- uses: actions/checkout@v3
with:
submodules: "recursive"
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: "3.8"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
CMAKE_ARGS="-DLLAMA_METAL=on" python3 -m pip install .[all] --verbose
- uses: actions/upload-artifact@v3
with:
name: 'wheel'
path: ./dist/* # Use ./dist/*.whl to only upload the JIT compile wheel

publish-to-pypi:
name: Publish Python distribution to PyPI
if: inputs.pypi == '1'
needs: ["build-linux", "build-windows", "build-macos", "build-macos-metal"]
runs-on: ubuntu-latest

environment:
name: pypi
url: https://pypi.org/p/llama_cpp_python
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download the wheel
uses: actions/download-artifact@v3
with:
name: wheel
path: dist/
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@v1.8.10
126 changes: 0 additions & 126 deletions .github/workflows/test.yaml

This file was deleted.

Loading

0 comments on commit 88c01c0

Please sign in to comment.