summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 305c87fb969aff00b460d464454cbc253db7de8e (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
# Maintainer: 0x9fff00 <0x9fff00+git@protonmail.ch>
# Contributor: Luis Martinez <luis dot martinez at disroot dot org>

_name=mutf8
pkgname=python-$_name
pkgver=1.0.6
pkgrel=4
pkgdesc='MUTF-8 encoder/decoder'
arch=('x86_64')
url="https://github.com/TkTech/$_name"
license=('MIT')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools' 'python-wheel')
checkdepends=('python-pytest')
# tests directory isn't in pypi sdist
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('c7a86f00bc8d313b9ce184375c944bf5be771127283d82a8d2becf33cc84e1c7')

build() {
  cd "$_name-$pkgver"

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

check() {
  cd "$_name-$pkgver"

  # https://wiki.archlinux.org/title/Python_package_guidelines#Check
  local _python_version="$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')"
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-$_python_version" pytest -x
}

package() {
  cd "$_name-$pkgver"

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

  # https://wiki.archlinux.org/title/Python_package_guidelines#Using_site-packages
  local _site_packages="$(python -c 'import site; print(site.getsitepackages()[0])')"

  install -d "$pkgdir/usr/share/licenses/$pkgname"
  local _license_path="$_site_packages/$_name-$pkgver.dist-info/LICENCE"
  [ -f "$pkgdir/$_license_path" ] || { echo "License file not found"; exit 1; }
  ln -s "$_license_path" "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}