# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=django
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
pkgver=5.2.7
pkgrel=1
pkgdesc="A high-level Python Web framework that encourages rapid development and clean design (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://www.djangoproject.com/'
msys2_repository_url='https://github.com/django/django/'
msys2_references=(
  'archlinux: python-django'
  'gentoo: dev-python/django'
  'purl: pkg:pypi/django'
  "cpe: cpe:/a:djangoproject:django"
)
license=('spdx:BSD-3-Clause')
depends=("${MINGW_PACKAGE_PREFIX}-python"
         "${MINGW_PACKAGE_PREFIX}-python-asgiref"
         "${MINGW_PACKAGE_PREFIX}-python-sqlparse"
         "${MINGW_PACKAGE_PREFIX}-python-tzdata")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-bcrypt"
             "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi")
optdepends=("${MINGW_PACKAGE_PREFIX}-python-bcrypt: for bcrypt support"
            "${MINGW_PACKAGE_PREFIX}-python-argon2_cffi: for Argon2 support")
options=('!strip')
source=(#"Django-${pkgver}.tar.gz"::"https://www.djangoproject.com/download/${pkgver}/tarball/"
        https://github.com/django/django/archive/${pkgver}/${_realname}-${pkgver}.tar.gz)
sha512sums=('55e37326bc92519ef86f0566855097c5cb6190cd29b627cccb42d1c897fcae8774bd14814e810956f8521211cabe91baf954ad63fb8993e615ee0f6dc1742eb7')
noextract=(${_realname}-${pkgver}.tar.gz)

prepare() {
  tar -xzf "${srcdir}"/${_realname}-${pkgver}.tar.gz || true
}

build() {
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}" && cd "python-build-${MSYSTEM}"
  python -m build --wheel --skip-dependency-check --no-isolation
}

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

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

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
