summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 7283d2b238cf6e0a47a83be4d1d5b49fe77ae46f (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
# Maintainer: Carl Smedstad <carsme@archlinux.org>

pkgname=shell-gpt
_pkgname=${pkgname/-/_}
pkgver=1.4.3
pkgrel=2
pkgdesc="A command-line productivity tool powered by OpenAI's ChatGPT"
arch=(any)
url="https://github.com/TheR1D/shell_gpt"
license=(MIT)
depends=(
  litellm
  python
  python-click
  python-distro
  python-instructor
  python-openai
  python-pydantic
  python-rich
  python-typer
)
makedepends=(
  python-build
  python-hatchling
  python-installer
  python-wheel
)
checkdepends=(python-pytest)
source=("$pkgname-$pkgver.tar.gz::$url/archive/$pkgver.tar.gz")
sha256sums=('0b7f6facf708a55ddc3b4a2495a445e90711b1100c489735afe289c062c33c45')

_archive="$_pkgname-$pkgver"

prepare() {
  cd "$_archive"

  # If building inside a Git repository, hatch will determine which files to
  # install using the unrelated .gitignore file. This is likely to exclude all
  # files from the package.
  echo "[tool.hatch.build]" >> pyproject.toml
  echo "ignore-vcs = true" >> pyproject.toml

  # Python 3.12 compatibility - called_once_with has been replaced with
  # assert_called_once_with.
  sed -i 's/mock_system.called_once_with/mock_system.assert_called_once_with/' \
    tests/test_shell.py
}

build() {
  cd "$_archive"

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

check() {
  cd "$_archive"

  # Randomly generated mock API key
  export OPENAI_API_KEY=sk-dBAe8c5a9bc4294cca9bed292cd61e0ff9030bB94647adfb
  pytest \
    --deselect tests/test_default.py::test_markdown \
    --deselect tests/test_default.py::test_show_chat_use_markdown \
    --deselect tests/test_integration.py
}

package() {
  cd "$_archive"

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

  install -Dm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}