summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8bf72ec51475670a31a815802d891a6e4065fa58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Maintainer: envolution
# shellcheck shell=bash disable=SC2034,SC2154
pkgname=python-gguf-git
_pkgname=gguf
pkgver=b9209.r9.3a9c1b854d
pkgrel=1
pkgdesc="GGUF file format library and model conversion tools for llama.cpp"
arch=('x86_64')
url='https://ggml.ai/'
license=(MIT)
depends=(python python-sentencepiece)
makedepends=(
  python-build
  python-installer
  python-wheel
  python-setuptools
  python-poetry
  git)
optdepends=(
  'python-numpy: for numerical operations'
  'python-tqdm: for progress bars'
  'python-torch: for convert_hf_to_gguf.py and convert_lora_to_gguf.py'
  'python-huggingface-hub: for --remote flag in convert_hf_to_gguf.py')
provides=('python-gguf')
conflicts=('python-gguf')

# Source from llama.cpp repository's gguf-py directory
source=("${pkgname}::git+https://github.com/ggml-org/llama.cpp.git")
sha256sums=('SKIP')

pkgver() {
  cd "${pkgname}" || exit
  printf "%s" "$(git describe --tags | sed 's/\([^-]*-\)g/r\1/;s/-/./g')"
}


build() {
  cd "$pkgname/gguf-py"
  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname/gguf-py"
  # Tests may require additional setup
  # python -m pytest -s -v tests
}

package() {
  cd "$pkgname/gguf-py"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

  # Install conversion/ package
  local _pyver
  _pyver="$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")')"
  local _sitelib="/usr/lib/python${_pyver}/site-packages"

  cd ../

  install -Dm644 "conversion/__init__.py" "$pkgdir${_sitelib}/conversion/__init__.py"
  install -m644 "conversion"/*.py "$pkgdir${_sitelib}/conversion/"

  # Install conversion scripts
  install -Dm755 "convert_hf_to_gguf.py" "$pkgdir/usr/bin/convert_hf_to_gguf.py"
  install -Dm755 "convert_hf_to_gguf_update.py" "$pkgdir/usr/bin/convert_hf_to_gguf_update.py"
  install -Dm755 "convert_lora_to_gguf.py" "$pkgdir/usr/bin/convert_lora_to_gguf.py"
}
# vim:set ts=2 sw=2 et: