summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: f08e58c2d63c9c124946bda05fcf5a4a4f5b5a2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Maintainer: Bao Trinh <qubidt at gmail dot com>

pkgname=python-darker
pkgver=2.1.1
pkgrel=1
pkgdesc='Apply black reformatting to Python files only in regions changed since a given commit'
arch=('any')
url=https://github.com/akaihola/darker
license=("BSD-3-Clause")
depends=(
	'python'
	'python-black'
	'python-darkgraylib'
	'python-graylint'
)
makedepends=(
	'git'
	'python-build'
	'python-installer'
	'python-setuptools'
	'python-wheel'
)
checkdepends=(
	'python-pytest'
	'python-pytest-kwparametrize'
	'git'
	'python-regex'
	'python-pathspec'
	'python-pygments'
	'python-toml'
	'python-flynt'
	'python-isort'
)
optdepends=(
	'python-isort: for sorting import statements'
	'python-pygments: terminal syntax highlighting'
	'python-flynt: convert string literals to f-strings'
)
source=("${pkgname}::git+${url}.git#tag=v${pkgver}")
sha256sums=('05f5b60cb0098d2ba934fa457e273087eb3c284b34d766cd69ec548532dbccb0')

prepare() {
	cd "${pkgname}"
	# tests mistakenly included because tests dir contains __init__.py file
	echo "prune src/darker/tests" >> MANIFEST.in
}

build() {
	cd "${pkgname}"
	python -m build --no-isolation
}

check() {
	cd "${pkgname}"
	# override XDG_CONFIG_HOME to avoid global black config breaking tests
	XDG_CONFIG_HOME="${pkgdir}" \
	PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${PWD}/src" \
	python -m pytest src
}

package() {
	cd "${pkgname}"
	python -m installer --destdir="${pkgdir}" dist/*.whl
	install -vDm 644 LICENSE.rst -t "${pkgdir}/usr/share/licenses/${pkgname}"
	install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}