summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: df3592f7e1b1aad8f286ce3e05ad0cfc54be877a (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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Maintainer: Carl Smedstad <carl.smedstad at protonmail dot com>

pkgname=python-outlines
_pkgname=${pkgname#python-}
pkgver=0.0.27
_commit=1626ceaeb0611dd0c4439948072577ca05152f6e
pkgrel=1
pkgdesc="Guided text generation"
arch=(any)
url="https://github.com/outlines-dev/outlines"
license=(Apache-2.0)
depends=(
  python
  python-cloudpickle
  python-diskcache
  python-interegular
  python-jinja
  python-jsonschema
  python-lark
  python-nest-asyncio
  python-numba
  python-numpy
  python-openai
  python-pydantic
  python-pytorch
  python-referencing
  python-requests
  python-tiktoken
  python-transformers
)
makedepends=(
  git
  python-build
  python-installer
  python-setuptools-scm
  python-wheel
)
checkdepends=(
  python-pytest
  python-pytest-benchmark
  python-pytest-mock
  python-responses
)
optdepends=(
  # 'python-vllm: deploy as LLM service' # Not packaged yet
  'python-fastapi: deploy as LLM service'
  'uvicorn: deploy as LLM service'
  'python-llama-cpp: llama.cpp backend'
)

source=("git+$url.git#commit=$_commit")
sha256sums=('SKIP')

_archive="$_pkgname"

pkgver() {
  cd "$_archive"

  git describe --tags
}

build() {
  cd "$_archive"

  python -m build --wheel --no-isolation
}

check() {
  cd "$_archive"

  local ignored_tests=(
    # Fails 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
    tests/benchmark/test_benchmark_json_schema.py
    tests/benchmark/test_benchmark_numba_compile.py
    tests/benchmark/test_benchmark_regex_fsm.py
    tests/generate/test_integration_transfomers.py
    tests/models/test_transformers.py

    # Requires python-llama-cpp which I'm currently unable to install.
    tests/models/test_llama_cpp.py
  )
  local ignored_tests_arg=$(printf " --ignore=%s" "${ignored_tests[@]}")

  local deselected_tests=(
    # Fails 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
    tests/test_function.py::test_function_basic
    tests/fsm/test_regex.py::test_create_fsm_index_tokenizer
  )
  local deselected_tests_arg=$(printf " --deselect=%s" "${deselected_tests[@]}")

  rm -rf tmp_install
  python -m installer --destdir=tmp_install dist/*.whl

  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  export PYTHONPATH="$PWD/tmp_install/$site_packages"
  # shellcheck disable=SC2086
  pytest \
    $ignored_tests_arg \
    $deselected_tests_arg
}

package() {
  cd "$_archive"

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