Skip to content

Commit b96331c

Browse files
committed
Build quantize binary in setup.py
- remove pre-built binaries from git - create a proper sdist with sources - add `setup.py` to compile `quantize` binary for current platform - update to latest release of `llama.cpp` Signed-off-by: Christian Heimes <[email protected]>
1 parent 8ed18f8 commit b96331c

13 files changed

+222
-183
lines changed

.github/workflows/build.yaml

-119
This file was deleted.

.github/workflows/pypi.yaml

+58-15
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ on:
1414
types:
1515
- published
1616

17-
permissions:
18-
# allow gh release upload
19-
contents: write
20-
# see https://docs.pypi.org/trusted-publishers/
21-
id-token: write
22-
2317
jobs:
2418
build-package:
2519
name: Build and check packages
@@ -29,27 +23,73 @@ jobs:
2923
with:
3024
# for setuptools-scm
3125
fetch-depth: 0
26+
submodules: true
3227

3328
- uses: hynek/build-and-inspect-python-package@v2
29+
with:
30+
skip-wheel: 'false'
31+
32+
build_wheels:
33+
name: Build wheels on ${{ matrix.os }}
34+
runs-on: ${{ matrix.os }}
35+
strategy:
36+
matrix:
37+
# macos-13 is an intel runner, macos-14 is apple silicon
38+
os: [ubuntu-latest, ubuntu-24.04-arm, macos-14]
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
# for setuptools-scm
44+
fetch-depth: 0
45+
submodules: true
46+
47+
- name: Build wheels
48+
uses: pypa/[email protected]
49+
50+
- uses: actions/upload-artifact@v4
51+
with:
52+
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
53+
path: ./wheelhouse/*.whl
54+
55+
build_sdist:
56+
name: Build source distribution
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
# for setuptools-scm
62+
fetch-depth: 0
63+
submodules: true
64+
65+
- name: Build sdist
66+
run: pipx run build --sdist
67+
68+
- uses: actions/upload-artifact@v4
69+
with:
70+
name: cibw-sdist
71+
path: dist/*.tar.gz
3472

3573
publish-test-pypi:
3674
name: Publish packages to test.pypi.org
3775
# environment: publish-test-pypi
38-
# TODO: move to instructlab
76+
permissions:
77+
id-token: write
3978
if: |
40-
github.repository_owner == 'tiran' && (
79+
github.repository_owner == 'instructlab' && (
4180
github.event.action == 'published' ||
4281
(github.event_name == 'push' && github.ref == 'refs/heads/main')
4382
)
4483
runs-on: ubuntu-latest
45-
needs: build-package
84+
needs: [build_wheels, build_sdist]
4685

4786
steps:
4887
- name: Fetch build artifacts
4988
uses: actions/download-artifact@v4
5089
with:
51-
name: Packages
90+
pattern: cibw-*
5291
path: dist
92+
merge-multiple: true
5393

5494
- name: Upload to Test PyPI
5595
uses: pypa/gh-action-pypi-publish@release/v1
@@ -59,20 +99,23 @@ jobs:
5999
publish-pypi:
60100
name: Publish release to pypi.org
61101
# environment: publish-pypi
62-
# TODO: move to instructlab
102+
permissions:
103+
contents: write
104+
id-token: write
63105
if: |
64-
github.repository_owner == 'tiran' && github.event.action == 'published'
106+
github.repository_owner == 'instructlab' && github.event.action == 'published'
65107
runs-on: ubuntu-latest
66-
needs: build-package
108+
needs: [build_wheels, build_sdist]
67109

68110
steps:
69111
- name: Fetch build artifacts
70112
uses: actions/download-artifact@v4
71113
with:
72-
name: Packages
114+
pattern: cibw-*
73115
path: dist
116+
merge-multiple: true
74117

75-
- uses: sigstore/gh-action-sigstore-python@v2.1.1
118+
- uses: sigstore/gh-action-sigstore-python@v3.0.0
76119
with:
77120
inputs: >-
78121
./dist/*.tar.gz

.github/workflows/tests.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,21 @@ jobs:
2626
- "3.10"
2727
- "3.11"
2828
- "3.12"
29-
- "3.13-dev"
29+
- "3.13"
3030
steps:
3131
- uses: "actions/checkout@v4"
3232
with:
33-
submodules: true
33+
submodules: true
34+
# for setuptools-scm
35+
fetch-depth: 0
3436

3537
- uses: "actions/setup-python@v5"
3638
with:
3739
python-version: "${{ matrix.python-version }}"
3840
allow-prereleases: true
3941

4042
- name: "Update pip"
41-
run: python -m pip install --upgrade pip setuptools wheel
43+
run: python -m pip install --upgrade pip
4244

4345
- name: "Install tox dependencies"
4446
run: python -m pip install --upgrade tox tox-gh-actions
@@ -55,7 +57,7 @@ jobs:
5557
submodules: true
5658

5759
- name: "Update pip"
58-
run: python -m pip install --upgrade pip setuptools wheel
60+
run: python -m pip install --upgrade pip
5961

6062
- name: "Install tox dependencies"
6163
run: python -m pip install --upgrade tox

MANIFEST.in

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
include tox.ini tests.py .pylintrc
2+
recursive-include llama.cpp *
3+
exclude llama.cpp/.git
4+
5+
global-exclude gguf.inp gguf.out
6+
exclude llama.cpp/models/ggml-vocab-aquila.gguf
7+
exclude llama.cpp/models/ggml-vocab-baichuan.gguf
8+
exclude llama.cpp/models/ggml-vocab-bert-bge.gguf
9+
exclude llama.cpp/models/ggml-vocab-command-r.gguf
10+
exclude llama.cpp/models/ggml-vocab-deepseek-coder.gguf
11+
exclude llama.cpp/models/ggml-vocab-deepseek-llm.gguf
12+
exclude llama.cpp/models/ggml-vocab-falcon.gguf
13+
exclude llama.cpp/models/ggml-vocab-gpt2.gguf
14+
exclude llama.cpp/models/ggml-vocab-gpt-neox.gguf
15+
# used in tests.py
16+
# exclude llama.cpp/models/ggml-vocab-llama-bpe.gguf
17+
exclude llama.cpp/models/ggml-vocab-llama-spm.gguf
18+
exclude llama.cpp/models/ggml-vocab-mpt.gguf
19+
exclude llama.cpp/models/ggml-vocab-phi-3.gguf
20+
exclude llama.cpp/models/ggml-vocab-qwen2.gguf
21+
exclude llama.cpp/models/ggml-vocab-refact.gguf
22+
exclude llama.cpp/models/ggml-vocab-stablelm-3b-4e1t.gguf
23+
exclude llama.cpp/models/ggml-vocab-starcoder.gguf

Makefile

-39
This file was deleted.

llama.cpp

pyproject.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

33
[build-system]
4-
requires = ["setuptools>=64", "setuptools_scm>=8"]
4+
requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"]
55
build-backend = "setuptools.build_meta"
66

77
[project]
@@ -34,10 +34,12 @@ dynamic = ["version"]
3434
[project.urls]
3535
# TODO: move the project to instructlab
3636
# homepage = "https://instructlab.io"
37-
source = "https://github.com/tiran/instructlab-quantize"
38-
issues = "https://github.com/tiran/instructlab-quantize/issues"
37+
source = "https://github.com/instructlab/instructlab-quantize"
38+
issues = "https://github.com/instructlab/instructlab-quantize/issues"
3939

4040
[tool.setuptools_scm]
41+
# do not include +gREV local version, required for Test PyPI upload
42+
local_scheme = "no-local-version"
4143

4244
[tool.setuptools]
4345
package-dir = {"" = "src"}

0 commit comments

Comments
 (0)