# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_pyname=markdown
pkgname=python-markdown
pkgver=3.9
pkgrel=1
pkgdesc="Python implementation of John Gruber's Markdown"
arch=('any')
url='https://python-markdown.github.io/'
license=('spdx:BSD-3-Clause')
depends=('python')
makedepends=('python-build' 'python-installer' 'python-setuptools')
optdepends=('python-yaml: parse Python in YAML metadata')
checkdepends=('python-yaml')
msys2_repository_url="https://github.com/Python-Markdown/markdown"
msys2_references=(
  'purl: pkg:pypi/markdown'
)
source=("${_pyname}-$pkgver.tar.gz"::"https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('d2900fe1782bd33bdbbd56859defef70c2e78fc46668f8eb9df3128138f2cb6a')

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

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

check() {
  cd "${_pyname}-$pkgver"

  python -m unittest discover tests
}

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

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

  install -Dm644 LICENSE.md "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.md"
}
