# Contributor: Aiden Grossman <agrossman154@yahoo.com>
# Maintainer:
pkgname=jupyter-server
pkgver=2.9.1
pkgrel=1
pkgdesc="Backend for Jupyter web applications"
url="https://github.com/jupyter-server/jupyter_server"
arch="noarch"
license="BSD-3-Clause"
depends="
	jupyter-nbconvert
	jupyter-nbformat
	jupyter-server-terminals
	py3-anyio
	py3-argon2-cffi
	py3-jinja2
	py3-jupyter-events
	py3-jupyter_client
	py3-jupyter_core
	py3-overrides
	py3-packaging
	py3-prometheus-client
	py3-send2trash
	py3-terminado
	py3-tornado
	py3-traitlets
	py3-websocket-client
	"
makedepends="
	py3-gpep517
	py3-hatch-jupyter-builder
	py3-hatchling
	py3-installer
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-flaky
	py3-ipykernel
	py3-pytest
	py3-pytest-console-scripts
	py3-pytest-jupyter
	py3-pytest-timeout
	py3-pytest-tornasync
	py3-requests
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jupyter-server/jupyter_server/releases/download/v$pkgver/jupyter_server-$pkgver.tar.gz"
builddir="$srcdir/jupyter_server-$pkgver"

# secfixes:
#   2.7.3-r0:
#     - CVE-2023-39968
#     - CVE-2023-40170

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	# test_server_extension_list requires another pytest dependency to be packaged
	# test_terminal is throwing errors related to tornado
	# test_authorizer is throwing key errors for terminal manager
	# test_stop_extension is failing a single assert
	# test_copy_big_dir is not raising a HTTPError, needs more investigation
	# test_delete_non_empty_folder not raising HTTPError on x86 & x86_64 builders
	# test_api 500 errors under certain builder state repeatedly (why?)
	# test_restart_kernel fails on x86 with a 1!=0 assert
	# test_gateway_request_with_expiring_cookies fails on riscv64: TypeError: argument of type 'NoneType' is not iterable
	pytest \
		--disable-warnings \
		-W ignore::DeprecationWarning \
		--deselect tests/extension/test_entrypoint.py::test_server_extension_list \
		--deselect tests/test_terminal.py \
		--deselect tests/auth/test_authorizer.py \
		--deselect tests/extension/test_app.py::test_stop_extension \
		--deselect tests/services/contents/test_manager.py::test_copy_big_dir \
		--deselect tests/services/contents/test_manager.py::test_delete_non_empty_folder \
		--deselect tests/services/contents/test_api.py \
		--deselect tests/services/sessions/test_api.py::test_restart_kernel \
		--deselect tests/test_gateway.py::test_gateway_request_with_expiring_cookies
}

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

sha512sums="
148c3eaa4b6ca1147961c1188e0016a634e5adae350e762903bdde000acde7ab62507e71dbe1278c2b9358ce2cf1c28c17ea8b184f3d4a2d59277910b5b44965  jupyter-server-2.9.1.tar.gz
"
