_realname='poetry-core'
_pyname="${_realname/-/_}"
pkgname="python-${_realname}"
pkgver=2.4.1
pkgrel=1
pkgdesc='Poetry PEP 517 Build Backend'
arch=('any')
url='https://github.com/python-poetry/poetry-core'
msys2_repository_url='https://github.com/python-poetry/poetry-core'
msys2_changelog_url='https://github.com/python-poetry/poetry-core/blob/main/CHANGELOG.md'
msys2_references=(
  'anitya: 71155'
  'archlinux: python-poetry-core'
  'gentoo: dev-python/poetry-core'
  'purl: pkg:pypi/poetry-core'
)
license=('spdx:MIT')
depends=('python')
makedepends=(
  'python-build'
  'python-installer'
)
source=("https://pypi.org/packages/source/${_pyname::1}/${_pyname}/${_pyname}-${pkgver}.tar.gz")
sha256sums=('89dceb6c10e9c6d8650a16183400e3c9ff9ddee13b0a81023b5575334a2b3744')

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

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

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

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

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