summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d71ded01968678028bbe32e0bd8860a1db90e16a (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
70
71
72
73
74
75
76
77
78
79
80
81
# Maintainer: Carl Smedstad <carl.smedstad at protonmail dot com>

pkgname=python-outlines
_name=${pkgname#python-}
pkgver=0.0.23
pkgrel=1
pkgdesc="Guided text generation"
arch=(any)
url="https://github.com/outlines-dev/outlines"
license=(Apache)
depends=(
  python
  python-fastapi
  python-interegular
  python-jinja
  python-jsonschema
  python-lark
  python-nest-asyncio
  python-numba
  python-numpy
  python-openai
  python-perscache
  python-pydantic
  python-pytorch
  python-referencing
  python-requests
  python-transformers
)
makedepends=(
  python-build
  python-installer
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-pytest
  python-responses
)

source=(
  "$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz"
  "fix-package-discovery.patch"
)
sha256sums=(
  '094f63276f7920b5424d43f3b394a4692dde6c4b4ead6cd3b9cf13b0eba3cf6c'
  '9140b5e8436f3f75b02f74f6dabb3862f21e93e16c87e6d9a9e6209ec53a8756'
)

_archive="$_name-$pkgver"

prepare() {
  cd "$_archive"

  patch --forward --strip=1 --input="$srcdir/fix-package-discovery.patch"
}

build() {
  cd "$_archive"

  export SETUPTOOLS_SCM_PRETEND_VERSION="$pkgver"
  python -m build --wheel --no-isolation
}

check() {
  cd "$_archive"

  # Tests fail due to the following import error:
  #   ImportError: /usr/lib/python3.11/site-packages/tokenizers/tokenizers.cpython-311-x86_64-linux-gnu.so: undefined symbol: OnigDefaultSyntax
  pytest \
    --ignore tests/models/test_llama_cpp.py \
    --ignore tests/models/test_transformers.py \
    --ignore tests/generate/test_integration_transfomers.py \
    --deselect tests/test_function.py::test_function_basic \
    --deselect tests/fsm/test_regex.py::test_create_fsm_index_tokenizer
}

package() {
  cd "$_archive"

  python -m installer --destdir="$pkgdir" dist/*.whl
}