# Contributor: Antoine Martin (ayakael) <dev@ayakael.net>
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=celery
pkgver=5.5.3
pkgrel=0
pkgdesc="An asynchronous task queue/job queue based on distributed message passing"
url="http://www.celeryproject.org/"
# loongarch64: blocked by py3-moto
# s390x: blocked by py3-kombu
arch="noarch !loongarch64 !s390x"
license="Apache-2.0"
depends="
	py3-billiard
	py3-click
	py3-click-didyoumean
	py3-click-plugins
	py3-click-repl
	py3-dateutil
	py3-kombu
	py3-tz
	py3-tzdata
	py3-vine
	python3
	"
makedepends="python3-dev py3-setuptools py3-gpep517 py3-wheel"
checkdepends="
	pre-commit
	py3-pytest
	py3-greenlet
	py3-dnspython
	py3-mongo
	py3-pytest-celery
	py3-pytest-subtests
	py3-pytest-timeout
	py3-pytest-click
	py3-pydantic
	py3-boto3
	py3-moto
	py3-pyaml
	py3-msgpack
"
install="$pkgname.pre-install"
source="https://files.pythonhosted.org/packages/source/c/celery/celery-$pkgver.tar.gz
	celery.confd
	celery.initd
	"
pkgusers="celery"
pkggroups="celery"
subpackages="$pkgname-openrc $pkgname-pyc"
provides="py3-celery=$pkgver-r$pkgrel"

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 "$builddir"/.dist/*.whl
	# t/unit/backends/test_azureblockblob.py: requires py3-azure
	# t/unit/backends/test_gcs.py: requires py3-google-cloud-storage
	# t/unit/worker/test_worker.py::test_WorkController::test_with_file_descriptor_safety: no file descriptors available
	# t/unit/worker/test_worker.py::test_WorkController::test_with_autoscaler_file_descriptor_safety: no file descriptors available
	case $CARCH in
		ppc64le|riscv64)
			.testenv/bin/python3 -m pytest -v \
				--ignore=t/unit/backends/test_gcs.py \
				--ignore=t/unit/backends/test_azureblockblob.py \
				--deselect t/unit/worker/test_worker.py::test_WorkController::test_with_autoscaler_file_descriptor_safety \
				--deselect t/unit/worker/test_worker.py::test_WorkController::test_with_file_descriptor_safety \
				--deselect t/unit/concurrency/test_prefork.py::test_AsynPool::test_register_with_event_loop__no_on_tick_dupes
			;;
		*)
			.testenv/bin/python3 -m pytest -v \
				--ignore=t/unit/backends/test_gcs.py \
				--ignore=t/unit/backends/test_azureblockblob.py \
				--deselect t/unit/concurrency/test_prefork.py::test_AsynPool::test_register_with_event_loop__no_on_tick_dupes \
				--deselect t/unit/concurrency/test_prefork.py::test_AsynPool::test_schedule_writes_hub_remove_fd_only_from_writers_when_write_job_is_done
		;;
esac

}

package() {
	# install scripts
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -m644 -D "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname

	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
cc6fc7201325d265fe006bd173e288b1229c4f11e76db341dd949ad852d07341da0bb5fec84b0b7f5bb61f87415e89818baa11a84c5a34f5349f8849330ce56d  celery-5.5.3.tar.gz
c283956f8fe386ef39cb3e165a20d1cc7ff6398fbf5a922bec6b61fe4a71188519baed9feafc4e0e5b6864851545edaba54b89ba3613b2cf2ddd6426a6bf8fc2  celery.confd
a27cc3521cdf79ec60b15318c15679fe8f593c029c3ead53b162453ab9e86c05c57f7e4af843d69f17817a707db885f2c44d3b7f56337676dfc2ec0210bf38b7  celery.initd
"
