# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=py3-pyocd
pkgver=0.36.0
pkgrel=1
pkgdesc="Cortex-M debugger for Python"
url="https://pypi.org/project/pyocd/"
# s390x, ppc64le, riscv64 and loongarch64 blocked by py3-cmsis-pack-manager
arch="noarch !s390x !ppc64le !riscv64 !loongarch64"
license="Apache-2.0"
depends="
	py3-capstone
	py3-cmsis-pack-manager
	py3-colorama
	py3-elftools
	py3-importlib-metadata
	py3-importlib-resources
	py3-intelhex
	py3-intervaltree
	py3-lark-parser
	py3-natsort
	py3-prettytable3
	py3-pylink-square
	py3-six
	py3-typing-extensions
	py3-usb
	py3-yaml
	"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-setuptools_scm
	py3-wheel
	"
checkdepends="py3-pytest"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/pyocd/pyOCD/archive/refs/tags/v$pkgver.tar.gz
	0001-Make-use-of-libusb-package-optional.patch
	0002-Add-uacess-to-udev.patch
	0003-Fix-missing-not_called.patch
	"
builddir="$srcdir/pyOCD-$pkgver"

export SETUPTOOLS_SCM_PRETEND_VERSION="$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
	.testenv/bin/python3 -m pytest
}

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

	install -Dm644 udev/*.rules -t "$pkgdir"/usr/lib/udev/rules.d/
}

sha512sums="
26efd6ceeb0ddaea9ac52170082b9fd87926790f90c0d7ccb1deb9e9ec549b84202801704b65641e6a2ac7fe0215a540e45eb0e1a0b9a38ac373720c5884bd36  py3-pyocd-0.36.0.tar.gz
8255e1faec02474ca8d3db42e32f0d348c398953e690786b2a6ce417d1d700b93c91effb14ce64fe08f5e17fd5a602b2edac02de20858c5a62f255a323a93e83  0001-Make-use-of-libusb-package-optional.patch
132efcb19ee9d4cd4608f9e41a097ab292e7314b5589708a4398f81d727ad17b541047143d3f77628c5e1d70c404b4164625f81aa65a0bcdf6a76611ef09d74e  0002-Add-uacess-to-udev.patch
4054a761b455051ee42afa0ceef55c0d11ee83d344342b587a5e14cc22da11e574d89c3e31905720094c925c5c99f266502a5754c58f6cdede090a71872dd15d  0003-Fix-missing-not_called.patch
"
