summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c13ca99eb55def8d9ff40e6d4ef4dea15a1d596e (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
# Contributor: Marcell Meszaros < marcell.meszaros AT runbox.eu >
# Contributor: David Runge <dvzrv@archlinux.org>
# Contributor: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Richard Neumann aka. rne <r dot neumann at homeinfo fullstop de>

_pkgbase=python-magic
pkgname="${_pkgbase}-git"
pkgver=0.4.27.r22.g54d86fd
pkgrel=3
_stablepkg_epoch=1
pkgdesc="File type identification library; compatible with official file/libmagic Python wrapper (git)"
arch=('any')
url='https://pypi.org/project/python-magic'
_repourl='https://github.com/ahupp/python-magic'
license=('MIT')
depends=(
  'file'
  'python'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools'
  'python-wheel'
)
checkdepends=('python-pytest')
provides=("${_pkgbase}=${_stablepkg_epoch}:${pkgver%.r*}")
conflicts=(
  "${_pkgbase}"
  'python-file-magic' # official libmagic bindings - https://pypi.org/project/file-magic
)
source=("${_pkgbase}::git+${_repourl}.git")
b2sums=('SKIP')

pkgver() {
    cd "${_pkgbase}"

    # Generate git tag based version. Count only proper (v)#.#* [#=number] tags.
    local _gitversion=$(git describe --long --tags --match '[v0-9][0-9.][0-9.]*' | sed -e 's|^v||' | tr '[:upper:]' '[:lower:]') 

    # Format git-based version for pkgver
    # Expected format: e.g. 1.5.0rc2.r521.g99982a1c
    # Or in case of 'post': 1.5.0.post1.r521.g99982a1c
    echo "${_gitversion}" | sed \
        -e 's;^\([0-9][0-9.]*\)[-_.]\([a-zA-Z]\+\);\1\2;' \
        -e 's;\([0-9]\+-g\);r\1;' \
        -e 's;-;.;g' \
        -e 's;\(post.*\);\.\1;'
}

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

check() {
  cd "${_pkgbase}"
  LC_ALL=en_US.UTF-8 pytest -vv "${pytest_options[@]}"
}

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