# Contributor: Fabian Affolter <fabian@affolter-engineering.ch>
# Maintainer: fossdd <fossdd@pwned.life>
pkgname=py3-build
pkgver=1.2.2
pkgrel=1
pkgdesc="Correct PEP517 package builder"
url="https://github.com/pypa/build"
arch="noarch"
license="MIT"
depends="python3 py3-packaging py3-pyproject-hooks"
makedepends="py3-wheel py3-flit-core py3-gpep517 py3-installer"
checkdepends="
	py3-filelock
	py3-pytest-forked
	py3-pytest-mock
	py3-pytest-rerunfailures
	py3-pytest-xdist
	py3-setuptools
	"
subpackages="$pkgname-pyc"
source="https://github.com/pypa/build/archive/refs/tags/$pkgver/py3-build-$pkgver.tar.gz
	flit-core-tests.patch
	"
builddir="$srcdir/build-$pkgver"

replaces=py-build # Backwards compatibility
provides=py-build=$pkgver-r$pkgrel # Backwards compatibility

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

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/build*.whl
	.testenv/bin/python3 -m pytest \
		--deselect tests/test_env.py::test_uv_impl_install_cmd_well_formed \
		--deselect tests/test_env.py::test_requirement_installation \
		--deselect tests/test_env.py::test_venv_creation \
		--deselect tests/test_env.py::test_venv_creation \
		--deselect tests/test_env.py::test_uv_impl_install_cmd_well_formed \
		--deselect tests/test_env.py::test_uv_impl_install_cmd_well_formed \
		--deselect tests/test_env.py::test_external_uv_detection_success \
		--deselect tests/test_env.py::test_uv_impl_install_cmd_well_formed \
		--deselect tests/test_env.py::test_venv_creation \
		--deselect tests/test_main.py::test_build_package \
		--deselect tests/test_main.py::test_output \
		--deselect tests/test_main.py::test_build_package_via_sdist
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/build*.whl
}

sha512sums="
91e14208680915414a87bd3ba31229510a78d82d5504efc40cf7f9c6a7a698cfa4ff523f85c2dd6a56b5e313fae57134f64f2c328c88cd40efe40236b0b661cc  py3-build-1.2.2.tar.gz
6bf57b1e1d5d082f553969af5473386e60043640bcb4808a920f1ce203a2647ff90c3b8ad06c8ce15d79785fd3329a78f2c6824d66eed6e735bc78f9757a174d  flit-core-tests.patch
"
