# Contributor: Aiden Grossman <agrossman154@yahoo.com>
# Maintainer:
pkgname=jupyter-nbconvert
pkgver=7.16.4
pkgrel=0
pkgdesc="Notebook conversion tool for jupyter"
url="https://github.com/jupyter/nbconvert"
arch="noarch"
license="BSD-3-Clause"
depends="
	jupyter-nbclient
	jupyter-nbformat
	py3-beautifulsoup4
	py3-bleach
	py3-defusedxml
	py3-jinja2
	py3-jupyter_core
	py3-jupyterlab_pygments
	py3-markupsafe
	py3-mistune
	py3-packaging
	py3-pandocfilters
	py3-pygments
	py3-qt5
	py3-tinycss2
	py3-traitlets
	"
checkdepends="py3-pytest-xdist py3-ipykernel py3-flaky"
makedepends="py3-gpep517 py3-hatchling py3-installer"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/jupyter/nbconvert/archive/refs/tags/v$pkgver.tar.gz
	deprecation-warnings.patch
	"
builddir="$srcdir/nbconvert-$pkgver"

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

check() {
	export PYTHONWARNINGS="ignore::DeprecationWarning"
	# Use a virtual environment as the tests need an actual installation to work
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	./.testenv/bin/python3 -m installer .dist/*.whl
	# TestWebPDFExporter and TestNbConvertApp both require chromium to run tests
	# Last two tests fail on missing templates
	./.testenv/bin/python3 -m pytest -n auto \
		-k 'not TestWebPDFExporter and not TestNbConvertApp' \
		--deselect nbconvert/exporters/tests/test_export.py::TestExport::test_export_disabled \
		--deselect nbconvert/exporters/tests/test_export.py::TestExport::test_export_filename \
		--deselect nbconvert/exporters/tests/test_export.py::TestExport::test_export_filestream \
		--deselect nbconvert/exporters/tests/test_export.py::TestExport::test_export_nbnode \
		--deselect nbconvert/exporters/tests/test_exporter.py::TestExporter::test_get_export_names_disable \
		--deselect nbconvert/exporters/tests/test_exporter.py::TestExporter::test_get_exporter_disable_config_exporters \
		--deselect nbconvert/exporters/tests/test_script.py::TestScriptExporter::test_export \
		--deselect nbconvert/exporters/tests/test_script.py::TestScriptExporter::test_export_config_transfer \
		--deselect nbconvert/exporters/tests/test_script.py::TestScriptExporter::test_export_python \
		--deselect nbconvert/exporters/tests/test_templateexporter.py::TestExporter::test_absolute_template_name_5x_compatibility_display_priority \
		--deselect nbconvert/exporters/tests/test_templateexporter.py::TestExporter::test_absolute_template_name_5x_compatibility_full
}

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

sha512sums="
a492629501de1edc22d898389db18cdb2e62fb8e88892529e14c24d7e129943e89dc922b6579f4f9c2fc80d542e07e7c888358bf5e24414ca8049065970f894e  jupyter-nbconvert-7.16.4.tar.gz
02f53525c21be24c6891b0ad046cb1554f0ade1db47f1c935784dd496386b167167439a9c8152eaf73261fb775b52c0af9b7ad89064185fb52b74882f84e83d0  deprecation-warnings.patch
"
