_realname=poetry-core
pkgname="python-${_realname}"
pkgver=1.9.1
pkgrel=1
pkgdesc='Poetry PEP 517 Build Backend'
arch=(any)
url='https://github.com/python-poetry/poetry-core'
msys2_references=(
  "pypi:poetry-core"
)
license=('spdx:MIT')
depends=("python")
makedepends=(
  "python-setuptools"
  "python-build"
  "python-installer"
)
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('7a2d49214bf58b4f17f99d6891d947a9836c9899a67a5069f52d7b67217f61b8')

build() {
  cd "${_realname/-/_}-${pkgver}"

  # https://github.com/python-poetry/poetry/issues/5547
  export GIT_DIR="$(pwd)"
  python -m build --wheel --skip-dependency-check --no-isolation
}

package() {
  cd "${_realname/-/_}-${pkgver}"

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

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