summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4cf9446e7087b73f7f678c62e600232056d9e302 (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
# Maintainer: David Runge <dvzrv@archlinux.org>
# Maintainer: taotieren <admin@taotieren.com>

pkgname=python-cmsis-pack-manager
_name=cmsis_pack_manager
pkgver=0.5.3.r21.ga312ce0
pkgrel=2
pkgdesc="A Rust and Python module for handling CMSIS Pack files"
arch=(any)
url="https://github.com/pyocd/cmsis-pack-manager"
license=(Apache-2.0)
depends=(
  gcc-libs
  glibc
  python
  python-appdirs
  python-cffi
  python-pyyaml
)
makedepends=(
  cbindgen
  git
  python-build
  python-installer
  python-maturin
  python-wheel
  rust
)
checkdepends=(
  python-hypothesis
  python-jinja
  python-pytest
)
# disable LTO until ring can be built with it: https://github.com/briansmith/ring/issues/1444
options=(!lto)
source=(
  "${_name}::git+$url.git"
)
sha512sums=('SKIP')
# source=("${_name}-${pkgver}.tar.gz::https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz")
# sha512sums=('d6f35f33917fd906d5b78a8f66891222f409d0e42f602f93de49dd87e9fc16c602f9eb63e529db8e68546a4b38d6f1f91e4456e238b3b8d149d19c822f238394')

prepare() {
  # https://github.com/pyocd/cmsis-pack-manager/pull/219
  #   patch -Np1 -d $_name -i ../$pkgname-0.5.3-update_maturin.patch
  git -C "${srcdir}/${_name}" clean -dfx
  cd $_name
  git tag -l 'rust*' | xargs git tag -d
}

pkgver() {
  cd "${srcdir}/${_name}"
  (
    set -o pipefail
    git describe --long --tag --match='v*' --abbrev=7 2>/dev/null | sed 's/^v//g;s/\([^-]*-g\)/r\1/;s/-/./g' ||
      printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
  )
}

build() {
  local python_build_options=(
    --wheel
    --no-isolation
    -C"--target=$CARCH-unknown-linux-gnu"
    -C"--locked"
    -C"--release"
    -C"--all-features"
    -C"--strip"
  )
  cd "${srcdir}/${_name}"
  python -m build "${python_build_options[@]}"
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd "${srcdir}/${_name}"
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="$PWD/test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv
}

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

# build() {
#   local python_build_options=(
#     --wheel
#     --no-isolation
#     -C"--target=$CARCH-unknown-linux-gnu"
#     -C"--locked"
#     -C"--release"
#     -C"--all-features"
#     -C"--strip"
#   )
#   cd "${srcdir}/${_name}-${pkgver}"
#   python -m build "${python_build_options[@]}"
# }
#
# check() {
#   local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
#
#   cd "${srcdir}/${_name}-${pkgver}"
#   python -m installer --destdir=test_dir dist/*.whl
#   export PYTHONPATH="$PWD/test_dir/$_site_packages:$PYTHONPATH"
#   pytest -vv
# }
#
# package() {
#   cd "${srcdir}/${_name}-${pkgver}"
#   python -m installer --destdir="$pkgdir" dist/*.whl
# }