# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Will Sinatra <wpsinatra@gmail.com>
maintainer="Will Sinatra <wpsinatra@gmail.com>"
pkgname=py3-networkx
pkgver=3.4.2
pkgrel=0
pkgdesc="Software for complex networks"
url="https://networkx.org/"
arch="noarch"
license="BSD-3-Clause"
depends="
	py3-matplotlib
	py3-numpy
	py3-pandas
	py3-scipy
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
subpackages="$pkgname-doc $pkgname-pyc"
checkdepends="
	graphviz
	py3-lxml
	py3-pydot
	py3-pygraphviz
	py3-pytest
	py3-pytest-xdist
	py3-yaml
	xdg-utils
	"
source="https://pypi.python.org/packages/source/n/networkx/networkx-$pkgver.tar.gz"
builddir="$srcdir/networkx-$pkgver"

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/*.whl

	case "$CARCH" in
	riscv64)
		.testenv/bin/python3 -m pytest \
			--ignore networkx/algorithms/bipartite/tests/test_spectral_bipartivity.py \
			--ignore networkx/algorithms/centrality/tests/test_subgraph.py \
			--ignore networkx/algorithms/tests/test_communicability.py
		# these tests deadlock or take a very long time to complete
		;;
	*)
		.testenv/bin/python3 -m pytest
		;;
	esac
}

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

	find "$pkgdir" -type d -name tests -exec rm -r {} \+

	install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/doc/$pkgname/
	cp -a examples "$pkgdir"/usr/share/doc/$pkgname/
}

sha512sums="
910e1400ad18711761c715896c3238b9c7d8914c571ab4db3aaf18a772b5fef90e5378ca435fbfce55b5821f1ddd3863a3cd65030086e80a971df91d9203c637  networkx-3.4.2.tar.gz
"
