Debian Codegraph @

tasks/build_/wheel.sh

raw symbols SCIP
1 #!/bin/bash
2 set -ex
3
4 libc="${1}"
5 shift
6
7 pkg="${1}"
8 shift
9
10 versions=" ${1} "
11 shift
12
13 final="/io/dist"
14 target="/io/dist/${libc}"
15 owner="$( stat -c%u:%g /io )"
16
17 mkdir -p -- "${final}"
18 chown -R "${owner}" "${final}"
19
20 mkdir -p -- "${target}"
21 chown -R "${owner}" "${target}"
22
23 # Extract name-only from package spec
24 name="$(
25 basename "${pkg}" \
26 | sed -e 's,^\([a-zA-Z][a-zA-Z0-9]*\([._-][a-zA-Z][a-zA-Z0-9]*\)*\).*,\1,' \
27 | grep -x '\([a-zA-Z][a-zA-Z0-9]*\([._-][a-zA-Z][a-zA-Z0-9]*\)*\)'
28 )"
29
30 # fail if it doesn't build
31 export SETUP_CEXT_REQUIRED=1
32
33 # pip args
34 args=( wheel --no-binary "${name}" --no-deps "${pkg}" -w "${target}" )
35
36 found=
37 for dir in /opt/python/*; do
38 if [ "${dir/pypy}" != "${dir}" ]; then
39 continue
40 fi
41
42 pyv="$(
43 "${dir}/bin/python" -c 'import sys; sys.stdout.write("".join(map(str, sys.version_info[:2])))'
44 )"
45 if [ "${versions/${pyv}}" = "${versions}" ]; then
46 continue
47 fi
48
49 "${dir}/bin/pip" "${args[@]}"
50 chown -R -- "${owner}" "${target}"
51 found=1
52 done
53
54 [ -n "${found}" ]
55
56 # Bundle external shared libraries into the wheels
57 for whl in "${target}"/*.whl; do
58 base="$(basename -- "${whl}")"
59 if [ "${base/${libc}}" = "${base}" ]; then
60 auditwheel repair "${whl}" -w "${target}"
61 chown -R -- "${owner}" "${target}"
62 fi
63 done
64
65 # Only keep properly tagged wheels
66 for whl in "${target}"/*.whl; do
67 base="$(basename -- "${whl}")"
68 if [ "${base/-${libc}}" != "${base}" -a "${base/pypy}" = "${base}" ]; then
69 mv -v -- "${whl}" "${final}"
70 fi
71 done
72 rm -rf -- "${target}"
73 chown -R -- "${owner}" "${final}"
74
75 # The end.