summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ae84c8d9e4b67a19848d8c535c8cb6c997a43e51 (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
# Maintainer: Smoolak <smoolak [at] gmail.com>.

pkgname=python-pi-heif
_pkgname=pillow_heif
pkgver=1.2.0
pkgrel=1
pkgdesc="Python interface for libheif library (lightweight version without encoding)"
arch=('x86_64')
url="https://github.com/bigcat88/pillow_heif"
license=('BSD-3-Clause')
depends=(
  'python'
  'python-pillow'
  'libheif'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=(
  'python-pytest'
)
source=("$pkgname-$pkgver.tar.gz::https://github.com/bigcat88/${_pkgname}/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('dff8da52f315a500859d5cd173fd01afe036e4df9d0578a15918fc135028692a')

prepare() {
  cd "$_pkgname-$pkgver"

  # Copy pi-heif config and transform to pi_heif
  # Remove pre-existing pi_heif dir so the transform rename succeeds
  rm -rf pi_heif pi_heif.egg-info
  cp -r pi-heif/* .
  python .github/transform_to-pi_heif.py
}

build() {
  cd "$_pkgname-$pkgver"
  python -m build --wheel --no-isolation
}

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

  # Basic import test (use build directory for compiled extension)
  local _pyver=$(python -c 'import sys; print(f"{sys.version_info[0]}{sys.version_info[1]}")')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-$_pyver:$PYTHONPATH" \
    python -c "import pi_heif; print('pi_heif imported successfully')" || \
    echo "Warning: Import test failed"
}

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

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

  install -Dm644 LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
  install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}