summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a78e09164d593ab5804cbc55660ac768edecf5ec (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
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>

pkgname=python-tree-sitter-language-pack
_gitpkgname=tree-sitter-language-pack
pkgver=0.6.0
pkgrel=1
pkgdesc='Comprehensive collection of tree-sitter languages'
arch=('x86_64')
url='https://github.com/Goldziher/tree-sitter-language-pack'
license=(
  'Apache-2.0'
  'BSD-2-Clause'
  'BSD-3-Clause'
  'CC0-1.0'
  'ISC'
  'MIT'
  'Unlicense'
  'WTFPL'
)
depends=(
  'glibc'
  'python'
  'python-tree-sitter'
  'python-tree-sitter-c-sharp'
  'python-tree-sitter-embedded-template'
  'python-tree-sitter-yaml'
)
makedepends=(
  'cython'
  'nodejs'
  'python-anyio'
  'python-build'
  'python-gitpython'
  'python-installer'
  'python-setuptools'
  'python-typing_extensions'
  'python-wheel'
  'tree-sitter'
  'tree-sitter-cli'
)
checkdepends=(
  'python-pytest'
)

source=(
  "${_gitpkgname}-${pkgver}.tar.gz::https://github.com/Goldziher/tree-sitter-language-pack/archive/v${pkgver}.tar.gz"
)

sha512sums=(
  '0409721da12e8678e59a66f77efbc6640050f48d0abd46465ffd322f83931cedaabd11288e449d9d37bbda030f723caa383d422c6b1074cd671bf82700b83ad2'
)

prepare() {
  cd "${_gitpkgname}-${pkgver}"

  echo >&2 'Downloading and building vendored parsers'
  mkdir parsers
  python scripts/clone_vendors.py
}

build() {
  cd "${_gitpkgname}-${pkgver}"

  echo >&2 'Building wheel'
  python -m build --wheel --no-isolation
}

check() {
  cd "${_gitpkgname}-${pkgver}"
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl

  # Run tests from a working directory other than the source tree.
  # The source tree would shadow the `.tree_sitter_language_pack.bindings`
  # package in the installed wheel. The modules inside that package were
  # only generated during the build, so only the wheel has them.
  echo >&2 'Running unit tests'
  env -C "$(mktemp -d)" "$(pwd)/test-env/bin/python" -m \
    pytest --import-mode=append "$(pwd)/tests"
}

package() {
  cd "${_gitpkgname}-${pkgver}"

  echo >&2 'Packaging the wheel'
  python -I -m installer --destdir="${pkgdir}" dist/*.whl

  echo >&2 'Packaging the documentation'
  install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
    README.md

  echo >&2 'Packaging licenses'
  install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
    LICENSE
  find vendor -name 'LICENSE*' -exec \
    install -D -m 644 -T '{}' "${pkgdir}/usr/share/licenses/${pkgname}/{}" \
    ';'
}