summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c01a9f6715ec3836c905a4e1b672065d3d689848 (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
67
68
69
70
71
72
# Maintainer: Gesh <gesh@gesh.uni.cx>
# Contributor: Christopher Arndt <aur -at- chrisarndt -dot- de>

_name='flake8-polyfill'
pkgname="python-${_name}"
pkgver=1.0.2.r18.gb98e6f4
pkgrel=4
pkgdesc='Polyfill package for Flake8 plugins'
url="https://github.com/PyCQA/${_name}"
depends=('flake8')
checkdepends=('python-pytest')
makedepends=(git python-build python-installer python-wheel python-setuptools)
license=('MIT')
arch=('any')
source=("$pkgname::git+$url" fix-tests.patch)
sha256sums=('SKIP'
            '33a28897eda38828c197a6f31e0415a8804209c40f698ca5b5201b7660b65985')

# Necessary since upstream, seemingly abandoned, has forgotten to tag the 1.0.2
# release it cut
_bumpTag() {
    cd "${srcdir}/$pkgname"
    local version oldVer verCmd _verCmd

    verCmd=(python -c 'import setuptools; setuptools.setup()' --version)

    git stash &> /dev/null
    version="$("${verCmd[@]}")"
    oldVer="$(git describe --abbrev=0)"
    if test "$version" != "$oldVer"; then
        printf -v _verCmd '%q ' "${verCmd[@]}"
        printf 'test "$(%s)" != %s\n' "$_verCmd" "$version" > bisector.sh
        chmod 755 bisector.sh
        git bisect start
        git bisect new
        git bisect old "$oldVer"
        git bisect run ./bisector.sh
        git tag -f "$version"
        git bisect reset
    fi &> /dev/null

    git describe --long --tags --abbrev=7
    git stash pop &> /dev/null
}

pkgver() {
    _bumpTag | sed -E 's/^[^0-9]*//;s/-([^-]*-g)/.r\1/;s/-/./g'
}

prepare() {
    cd "${srcdir}/$pkgname"
    patch -p1 -i ../fix-tests.patch
}

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

check() {
    cd "${srcdir}/$pkgname"
    PYTHONPATH=src:"$PYTHONPATH" python -m pytest tests
}

package() {
    cd "${srcdir}/$pkgname"
    python -m installer --destdir="$pkgdir" dist/*.whl

    # license
    install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}