# Contributor: Dirk Stolle

_realname=imagesize
pkgname=python-${_realname}
pkgver=2.0.0
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=('8e8358c4a05c304f1fccf7ff96f036e7243a189e9e42e90851993c558cfe9ee3')

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"
}
