summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: d93a7fda235ea4fbb24ce660a6ee9fcbd54590d3 (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# SPDX-License-Identifier: AGPL-3.0
#
# Maintainer:  Pellegrino Prevete (dvorak) <pellegrinoprevete@gmail.com>
# Maintainer:  Truocolo <truocolo@aol.com>
# Contributor: David Runge <dvzrv@archlinux.org>

_os="$( \
  uname \
    -o)"
_pkg=maturin
_py="python"
_pkgbase="${_pkg}"
pkgbase="${_pkg}-git"
pkgname=(
  "${pkgbase}"
  "${_py}-${_pkg}-git"
)
pkgver="1.4.0.r31.g6030857e"
pkgrel=1
_pkgdesc=(
  "Build and publish crates with pyo3,"
  "rust-c${_py} and cffi bindings"
)
pkgdesc="${_pkgdesc[*]}"
url="https://github.com/PyO3/${_pkg}"
arch=(
  x86_64
  arm
)
license=(
  'Apache-2.0 OR MIT'
)
makedepends=(
  bzip2
  gcc-libs
  git
  glibc
  "${_py}-build"
  "${_py}-installer"
  "${_py}-setuptools"
  "${_py}-setuptools-rust"
  "${_py}-wheel"
  rust
)
# disable LTO until ring can be built with it:
# https://github.com/briansmith/ring/issues/1444
options=(
  !lto
)
source=(
  "${_pkgbase}::git+${url}.git"
)
sha512sums=(
  'SKIP'
)
b2sums=(
  'SKIP'
)

_parse_ver() {
  local \
    _pkgver="${1}" \
    _out="" \
    _ver \
    _rev \
    _commit
  _ver="$( \
    echo \
      "${_pkgver}" | \
      awk \
        -F '+' \
        '{print $1}')"
  _rev="$( \
    echo \
      "${_pkgver}" | \
      awk \
        -F '+' \
        '{print $2}')"
  _commit="$( \
    echo \
      "${_pkgver}" | \
      awk \
        -F '+' \
        '{print $3}')"
  _out=${_ver}
  if [[ "${_rev}" != "" ]]; then
    _out+=".r${_rev}"
  fi
  if [[ "${_commit}" != "" ]]; then
    _out+=".${_commit}"
  fi
  echo \
    "${_out}"
}

pkgver() {
  local \
    _pkgver
  cd \
    "${_pkg}" || \
    exit
  _pkgver="$( \
    git \
      describe \
      --tags | \
        sed \
          's/_/./g;s/-/+/g')"
  _parse_ver \
    "${_pkgver}"
}

_pick() {
  local \
    p="${1}" \
    f \
    d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir \
      -p \
        "$(dirname "$d")"
    mv \
      "$f" \
      "$d"
    rmdir \
    -p \
    --ignore-fail-on-non-empty \
    "$( \
      dirname \
        "$f")"
  done
}

prepare() {
  local \
    _target
  _target="${CARCH}-unknown-linux-gnu"
  [[ "${_os}" == "Android" ]] && \
    _target="${CARCH}-linux-androideabi"
  cd \
    "${_pkg}"
  cargo \
    fetch \
    --locked \
    --target \
      "${_target}"
}

build() {
  cd \
    "${_pkg}"
  "${_py}" \
    -m \
      build \
      --wheel \
      --no-isolation
}

package_maturin-git() {
  depends=(
    bzip2
    gcc-libs
    glibc
    rust
  )
  provides+=(
    "${_pkgbase}=${pkgver}"
  )
  conflicts+=(
    "${_pkgbase}"
  )
 cd \
    "${_pkg}"
  "${_py}" \
    -m installer \
    --destdir="${pkgdir}" \
    dist/*.whl
  install \
    -vDm 644 \
    {Changelog,README}.md \
    -t "${pkgdir}/usr/share/doc/${pkgname}/"
  install \
    -vDm 644 \
    license-mit \
    -t "${pkgdir}/usr/share/licenses/${pkgname}/"

  (
    cd \
      "${pkgdir}"
    _pick \
      "${_py}-${_pkg}" \
      usr/lib
  )
}

package_python-maturin-git() {
  pkgdesc+=" - Python bindings"
  depends=(
    "${_pkg}=${pkgver}"
    "${_py}"
  )
  provides+=(
    "${_py}-${_pkg}=${pkgver}"
  )
  conflicts+=(
    "${_py}-${_pkg}"
  )
  mv \
    -v \
    "${_py}-${pkg}/"* \
    "${pkgdir}"
  install \
    -vDm 644 \
    "${pkgdir}/license-mit" \
    -t \
    "${pkgdir}/usr/share/licenses/${_pkg}/"
}

# vim:set sw=2 sts=-1 et: