# Contributor: Dirk Stolle

_realname=imagesize
pkgname=python-${_realname}
pkgver=1.4.1
pkgrel=1
pkgdesc='Analyzes JPEG/JPEG 2000/PNG/GIF/TIFF/SVG image headers and returns image size or DPI'
arch=('any')
url='https://github.com/shibukawa/imagesize_py'
msys2_references=(
  'cygwin: python-imagesize'
  'purl: pkg:pypi/imagesize'
)
license=('spdx:MIT')
depends=('python')
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools'
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('69150444affb9cb0d5cc5a92b3676f0b2fb7cd9ae39e947a5e11a36b4497cd4a')

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"

  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "python-build-${MSYSTEM}"

  python -m unittest discover -v
}

package() {
  cd "python-build-${MSYSTEM}"

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

  install -Dm644 LICENSE.rst "${pkgdir}${MSYSTEM_PREFIX}/share/licenses/python-${_realname}/LICENSE.rst"
}
