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

_pyname=oslo.config
_realname=oslo-config
pkgbase=mingw-w64-python-${_realname}
pkgname=( "${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=9.7.0
pkgrel=1
pkgdesc="parsing command line arguments and .ini style configuration files (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
msys2_references=(
  'archlinux: python-oslo-config'
  'pypi: oslo.config'
)
msys2_repository_url='https://opendev.org/openstack/oslo.config/'
msys2_changelog_url='https://docs.openstack.org/releasenotes/oslo.config/'
msys2_documentation_url='https://docs.openstack.org/oslo.config/latest/'
msys2_issue_tracker_url='https://bugs.launchpad.net/oslo.config'
url='https://docs.openstack.org/oslo.config/latest/'
license=('spdx:Apache-2.0')
depends=("${MINGW_PACKAGE_PREFIX}-python-debtcollector"
         "${MINGW_PACKAGE_PREFIX}-python-netaddr"
         "${MINGW_PACKAGE_PREFIX}-python-stevedore"
         "${MINGW_PACKAGE_PREFIX}-python-oslo-i18n"
         "${MINGW_PACKAGE_PREFIX}-python-requests"
         "${MINGW_PACKAGE_PREFIX}-python-rfc3986"
         "${MINGW_PACKAGE_PREFIX}-python-yaml"
         "${MINGW_PACKAGE_PREFIX}-python-requests")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-build"
             "${MINGW_PACKAGE_PREFIX}-python-installer"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python-pbr")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-oslotest"
              "${MINGW_PACKAGE_PREFIX}-python-sphinx"
              "${MINGW_PACKAGE_PREFIX}-python-requests-mock"
              "${MINGW_PACKAGE_PREFIX}-python-oslo-log")
options=(!strip)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('b371ebf3f9a63e92b81d5c72b84d2f96f40553532699c68e1c5cd8ca9eca088b')

prepare() {
  cd ${srcdir}
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_pyname}-${pkgver}" "python-build-${MSYSTEM}"

  export PBR_VERSION=$pkgver
}

build() {
  cd "${srcdir}/python-build-${MSYSTEM}"

  ${MINGW_PREFIX}/bin/python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  PYTHON=${MINGW_PREFIX}/bin/python ${MINGW_PREFIX}/bin/stestr run || warning "Tests failed"
}

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

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

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