# Contributor: Brian Vuyk <bvuyk@sama.com>
# Maintainer: Brian Vuyk <bvuyk@sama.com>
pkgname=py3-scikit-build
pkgver=0.17.6
pkgrel=2
pkgdesc="Improved build system generator for CPython C/C++/Fortran/Cython extensions."
url="https://pypi.org/project/scikit-build/"
arch="noarch"
license="MIT"
depends="
	py3-distro
	py3-packaging
	py3-setuptools
	py3-wheel
	python3
	"
makedepends="
	py3-gpep517
	py3-hatchling
	py3-hatch-fancy-pypi-readme
	py3-hatch-vcs
	"
checkdepends="
	cmake
	cython
	gfortran
	py3-distro
	py3-mock
	py3-path
	py3-pytest
	py3-pytest
	py3-pytest-cov
	py3-requests
	py3-six
	py3-wheel
	python3-dev
	"
subpackages="$pkgname-pyc"
source="https://github.com/scikit-build/scikit-build/archive/$pkgver/scikit-build-$pkgver.tar.gz"
builddir="$srcdir/scikit-build-$pkgver"
options="!check" # temporary until 3.11 tests are fixed

build() {
	export SETUPTOOLS_SCM_PRETEND_VERSION=$pkgver
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	local python_version=$(python3 -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
	mkdir -p /tmp/fakepythonroot/usr/lib/python$python_version/site-packages

	# test_setup_requires_keyword_include_cmake requires internet access
	local tests="
		test_cmake_args_keyword_osx_default
		test_dual_pep518
		test_first_invalid_generator
		test_hello_sdist
		test_hello_sdist_with_base
		test_invalid_cmake
		test_invalid_generator
		test_isolated_env_trigger_reconfigure
		test_known_platform
		test_manifest_in_sdist
		test_pep518
		test_pep518_findpython
		test_sdist_with_symlinks
		test_setup_inputs
		test_setup_requires_keyword_include_cmake
		test_unsupported_platform
		test_zip_safe_default
		"
	local skipped_tests=""
	for test in $tests; do
		skipped_tests="$skipped_tests and not $test"
	done
	skipped_tests="${skipped_tests:4}"

	PYTHONPATH="/tmp/fakepythonroot/usr/lib/python$python_version/site-packages" pytest \
		-k "$skipped_tests"
}

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

sha512sums="
a843bd9d66dfb32f7297251c9ae7d31cb5e9a4930131de3153d148a2da76b8cd55d6eacce25f62d04a0bbcd67757a4c901b31af3f8361b8a2c2caeb1b0ba21c9  scikit-build-0.17.6.tar.gz
"
