# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=py3-poetry-core
_pkgname=poetry-core
pkgver=2.0.1
pkgrel=0
pkgdesc="PEP 517 build backend implementation for Poetry"
url="https://github.com/python-poetry/poetry-core"
license="MIT"
arch="noarch"
depends="
	py3-fastjsonschema
	py3-lark-parser
	py3-packaging
	"
makedepends="py3-gpep517"
checkdepends="
	py3-build
	py3-pip
	py3-pytest
	py3-pytest-mock
	py3-setuptools
	py3-tomli-w
	py3-trove-classifiers
	py3-virtualenv
	python3-dev
	"
subpackages="$pkgname-pyc"
source="https://github.com/python-poetry/poetry-core/archive/$pkgver/py3-poetry-core-$pkgver.tar.gz
	fix-tests.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	# broken-ass test .c files
	export CFLAGS="$CFLAGS -Wno-error=int-conversion"
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
	.testenv/bin/python3 -m pytest --integration tests/integration \
		--deselect tests/integration/test_pep517_backend.py::test_pip_install
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/poetry_core-$pkgver-py3-none-any.whl

	# remove vendored versions of installed modules
	local sitedir=$(python3 -c "import site; print(site.getsitepackages()[0])")
	rm -r "$pkgdir/$sitedir"/poetry/core/_vendor
}

sha512sums="
5e578ae615da55b6e138b968e65b5090547807e06a1ba95bff40f8e42f4b86977bb939072df02e9ee76d3e58df250f6065c321d0e0934d1f061414856f2ab894  py3-poetry-core-2.0.1.tar.gz
f369a5a6ce6f9a52a6e2103ba7584d2362f1b338ccbca9e5aafd07475e43140c9c14dde6f6d580514196cce6ef90240960bf2627a8b86689e361831bb542ae6f  fix-tests.patch
"
