summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 5131520bba056a77432b3b1206be019802395cd3 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# Maintainer:  dreieck (https://aur.archlinux.org/account/dreieck)

_pyname="fastkml"
_gitname="${_pyname}"
_pkgname="python-${_pyname}"
pkgname="${_pkgname}-git"
pkgver=1.4.0+49.r1659.20260119.052ae67
pkgrel=1
pkgdesc="A Python library for reading, writing and manipulating KML files."
groups=()
arch=(
  'any'
)
_githost='github.com'
_gituser='cleder'
url="https://fastkml.readthedocs.io/"
license=("LGPL-2.1-or-later")
depends=(
  'python>=3.9'
  'python-arrow'
  'python-lxml'
  'python-pygeoif>=1.5'
  'python-typing_extensions>=4'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-setuptools>=61.2'
  'python-wheel'

  ## docs:
  'python-sphinx'
  'python-pyshp'
  'python-sphinx-autodoc-typehints'
  'python-sphinx_rtd_theme'
)
optdepends=()
checkdepends=(
  'python-anyio'
  'python-hypothesis'
  'python-pluggy'
  'python-pytest'
  'python-pytest-cov'
  'python-pytz'
  'python-tzdata'
)
provides=(
  "${_pkgname}=${pkgver}"
  "${_pkgname}-docs=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "${_pkgname}-docs"
)

source=(
  "${_pkgname}::git+https://${_githost}/${_gituser}/${_gitname}.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  cd "${srcdir}/${_pkgname}"

  git log > "${srcdir}/git.log"
}

pkgver() {
  cd "${srcdir}/${_pkgname}"

  # _ver="$(grep -E '^[[:space:]]*version[[:space:]]*=' pyproject.toml  | head -n1 | awk -F= '{print $2}' | tr -d \'\"[[:space:]])"
  _ver="$(git describe --tags | sed -E -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' | tr '-' '+')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}/${_pkgname}"
  printf '%s\n' " --> building ..."
  python -m build --wheel --no-isolation

  printf '%s\n' " --> building documentation ..."
  make -C docs text
  make -C docs man
  make -C docs html
  make -C docs changes
}

check() {
  cd "${srcdir}/${_pkgname}"
  printf '%s\n' " --> testing ..."
  pytest

  printf '%s\n' " --> testing documentation ..."
  make -C docs doctest
  make -C docs coverage
}

package() {
  cd "${srcdir}/${_pkgname}"
  printf '%s\n' " --> installing ..."
  python -m installer --destdir="$pkgdir" --compile-bytecode=2 dist/*.whl

  _docfiles=(
    "${srcdir}/git.log"
    README.rst
    docs/*.rst
    docs/*.gif
    docs/*.jpg
    docs/*.txt
    docs/*.kml
  )
  _docdirs=(
    docs/_build/{changes,html,text}
  )
  _manfiles=(
    # docs/_build/man/fastkml.1
    docs/_build/man/*
  )
  _infofiles=()
  _licensefiles=(
    LICENSE
  )
  printf '%s\n' " --> installing documentation ..."
  for _docfile in "${_docfiles[@]}"; do
    install -D -v -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/$(basename "${_docfile}")"
  done
  for _docdir in "${_docdirs[@]}"; do
    cp -rv "${_docdir}" "${pkgdir}/usr/share/doc/${_pkgname}/$(basename "${_docdir}")"
  done
  for _manfile in "${_manfiles[@]}"; do
    _section="$(basename "${_manfile}" .gz | sed -E -e 's|^.*\.([^.]*)$|\1|')"
    install -D -v -m644 "${_manfile}" "${pkgdir}/usr/share/man/man${_section}/$(basename "${_manfile}")"
  done
  for _infofile in "${_infofiles[@]}"; do
    install -D -v -m644 "${_infofile}" "${pkgdir}/usr/share/info/$(basename "${_infofile}")"
  done
  printf '%s\n' " --> installing license ..."
  for _licensefile in "${_licensefiles[@]}"; do
    install -D -v -m644 "${_licensefile[@]}" "${pkgdir}/usr/share/licenses/${pkgname}/$(basename "${_licensefile}")"
    ln -svr "${pkgdir}/usr/share/licenses/${pkgname}/$(basename "${_licensefile}")" "${pkgdir}/usr/share/doc/${_pkgname}/$(basename "${_licensefile}")"
  done
}