summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5ac6ee3076a340d9de6ce4d6d7778a9f5d10f58e (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
# Maintainer: Daniel Bershatsky <bepshatsky@yandex.ru>
# Contributor: Filip GraliƄski <filipg@amu.edu.pl>

: ${CARGO_HOME:=${SRCDEST:-$startdir}/cargo-home}

_gitname="tokenizers"
_pkgname="python-$_gitname"
pkgname="$_pkgname"
pkgver=0.19.1
pkgrel=2
pkgdesc='Fast State-of-the-Art Tokenizers optimized for Research and Production'
url="https://github.com/huggingface/tokenizers"
license=('Apache-2.0')
arch=('i686' 'x86_64')

depends=(
  'python'
  'oniguruma'
)
makedepends=(
  'clang'
  'rust-bindgen'
  'git'
  'python-build'
  'python-installer'
  'python-maturin'
  'python-setuptools-rust'
  'python-wheel'
)

options=('!lto')

_pkgsrc="$_gitname"
source=("$_pkgsrc"::"git+$url.git#tag=v${pkgver%%.r*}")
sha256sums=('SKIP')

prepare() {
  export CARGO_HOME
  export GIT_DIR='.'
  export RUSTUP_TOOLCHAIN=stable

  cd "$_pkgsrc/bindings/python"

  # fix typo
  sed -E -e 's@defaut@default@' -i Cargo.toml

  cargo update
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  export CARGO_HOME
  export GIT_DIR='.'
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target

  cd "$_pkgsrc/bindings/python"
  cargo build --frozen --release
  python -m build --no-isolation --wheel
}

package() {
  cd "$_pkgsrc/bindings/python"
  python -m installer --destdir="$pkgdir" dist/*.whl
}