# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=py3-flit
pkgver=3.12.0
pkgrel=0
pkgdesc="simple packaging tool for simple packages"
url="https://flit.readthedocs.io/"
arch="noarch"
license="BSD-3-Clause"
depends="
	py3-docutils
	py3-flit-core
	py3-requests
	py3-tomli-w
	"
makedepends="
	py3-installer
	"
checkdepends="
	py3-pytest-cov
	py3-responses
	py3-testpath
	"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/f/flit/flit-$pkgver.tar.gz
	tests-use-python3.patch
	"
builddir="$srcdir/flit-$pkgver"

build() {
	# temp hack to not pull in all of py3-build
	mkdir dist
	python3 - <<-EOF
		import flit_core.buildapi as buildapi
		name = buildapi.build_wheel('./dist')
		print(name)
	EOF
}

check() {
	# Necessary for sdist tests
	git init -q
	git add .
	git -c user.email='test@test.test' -c user.name='test' commit -qm. || true

	# pep621 - needs pip
	# install_reqs_my_python_if_needed - needs pip
	# invalid_classifier - needs network access
	# install_reqs_my_python_if_needed - needs pip
	# test_symlink_data_dir - needs pip
	# test_install_data_dir - needs pip
	local _disabled_tests="
		test_install_module_pep621
		and not test_symlink_module_pep621
		and not test_invalid_classifier
		and not install_reqs_my_python_if_needed
		and not test_symlink_data_dir
		and not test_install_data_dir"

	# shellcheck disable=SC2116
	pytest -v -k "not $(echo $_disabled_tests)"
	rm -rf .git
}

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

sha512sums="
f8ed1f0e53452def182453db91a44c9ded5413fe74e2678bb7d56b3640d6ba6f43cccb55ad73e939cc5ca236fa2bf7b3e0f6d77fe4a4f12f90a9e437b561edb2  flit-3.12.0.tar.gz
ecc5cf61f1aab882817f80820e45f958bb208bef83565b8a1407cfb417dcce4b4a7e30f1fd7424256fdc54f8c8b43d24e3db8852cb9ec588d381376c15d764b7  tests-use-python3.patch
"
