summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 49d19279082649c0d6535b1f85e1686996558546 (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
69
# Maintainer: Premysl Srubar <premysl.srubar[äT]gmail(.)com>
_pkgname=bitsandbytes
pkgname=('python-bitsandbytes-git')
pkgver=0.44.1.11.g9264f02
pkgrel=1
pkgdesc="Lightweight wrapper around CUDA custom functions, in particular 8-bit optimizers, matrix multiplication (LLM.int8()), and quantization functions."

depends=(
         'python>=3.9'
         'cuda>=11.0'     
         'python-pytorch'
         'python-einops' 
         'python-scipy'
         'python-accelerate'
         'python-transformers'
         'python-lion-pytorch'
         )
       
provides=('python-bitsandbytes')
conflicts=('python-bitsandbytes') 
arch=('x86_64')
url="https://github.com/TimDettmers/bitsandbytes"
license=("MIT")
makedepends=('python-build' 'python-installer' 'git')
checkdepends=('python-pytest')

source=("${pkgname}::git+${url}.git")
        
sha256sums=('SKIP')

pkgver() {
  cd "$srcdir/${pkgname}"

  # Get the most recent semantic version tag like 0.44.1
  local latest_tag=$(git tag | grep -E '^([0-9]+\.[0-9]+\.[0-9]+)$' | sort -V | tail -n 1)

  # Get commit count since the latest tag and current commit hash
  local git_info=$(git describe --long --tags --match "$latest_tag" | sed 's/^[^-]*-//;s/-/./g')

  # Construct full package version
  echo "${latest_tag}.${git_info}"
}


build() {
  
  cd "$pkgname"
  
  cmake -DCOMPUTE_BACKEND=cuda -S .
  make
  python -m build --wheel --no-isolation  
}

check() {
  cd "$pkgname"
  # slow
  #pytest
}

package() {
  cd "$pkgname"
  python -m installer --destdir="$pkgdir" dist/*.whl
  # Remove tests

  rm -rf ${pkgdir}/usr/lib/python*/site-packages/tests/
  install -D -m644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  
}