# Contributor: Hoang Nguyen <folliekazetani@protonmail.com>
# Contributor: vinnie <fz12345@gmail.com>
# Maintainer: vinnie <fz12345@gmail.com>
pkgname=xonsh
pkgver=0.19.1
pkgrel=0
pkgdesc="Python-powered, full-featured and cross-platform shell"
url="https://xon.sh"
arch="noarch"
license="BSD-2-Clause"
depends="
	py3-distro
	py3-prompt_toolkit>=3.0
	py3-pygments>=2.2
	py3-pyperclip
	py3-ujson
	"
makedepends="py3-setuptools py3-gpep517 py3-installer py3-wheel"
# man-db with groff-1.23.0 breaks "test_man.py" due to escape codes in output
checkdepends="
	mandoc
	py3-pip
	py3-pyte
	py3-pytest
	py3-pytest-mock
	py3-pytest-rerunfailures
	py3-pytest-subprocess
	py3-pytest-timeout
	py3-requests
	py3-virtualenv
	"
subpackages="$pkgname-pyc"
source="$pkgname-$pkgver.tar.gz::https://github.com/xonsh/xonsh/archive/$pkgver.tar.gz
	no-col.patch
	"

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 \
		--ignore=tests/test_integrations.py \
		--ignore=tests/test_pipelines.py \
		--ignore=tests/test_ptk_shell.py \
		--ignore=tests/completers/test_bash_completer.py \
		--ignore=tests/procs/test_specs.py \
		--deselect tests/test_man.py::test_man_completion
}

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

	# The build process appends dirty bit into the version string
	# if a git repo is detected
	sed -i "s/^\(__version__ =\).*/\1 \"$pkgver\"/" \
		"$pkgdir"/usr/lib/python*/site-packages/xonsh/__init__.py
}

sha512sums="
2fbbd6ae42708b2c95b062633c1f8214f06d51d2020e60b3e8ef5d7bd11472d9774eb176d46a71466ef4ee34067b4282bd1ecdb0e5e9ae56c9d87a3f4575e3a0  xonsh-0.19.1.tar.gz
56e6548dde6faaa70e000f0d49a260ca0fe5297b0ec0abb1ab2cb0c22154479a957155f06037b91d9fda3736f3c7935d019a6c45adf506334e5940dfd8ac37d1  no-col.patch
"
