File: build.sh

package info (click to toggle)
python-rcssmin 1%3A1.1.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,196 kB
  • sloc: python: 2,379; ansic: 1,216; sh: 110; makefile: 20
file content (75 lines) | stat: -rwxr-xr-x 1,622 bytes parent folder | download
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
#!/bin/bash
set -ex

libc="${1}"
shift

pkg="${1}"
shift

versions=" ${1} "
shift

final="/io/dist"
target="/io/dist/${libc}"
owner="$( stat -c%u:%g /io )"

mkdir -p -- "${final}"
chown -R "${owner}" "${final}"

mkdir -p -- "${target}"
chown -R "${owner}" "${target}"

# Extract name-only from package spec
name="$(
    basename "${pkg}" \
    | sed -e 's,^\([a-zA-Z][a-zA-Z0-9]*\([._-][a-zA-Z][a-zA-Z0-9]*\)*\).*,\1,' \
    | grep -x '\([a-zA-Z][a-zA-Z0-9]*\([._-][a-zA-Z][a-zA-Z0-9]*\)*\)'
)"

# fail if it doesn't build
export SETUP_CEXT_REQUIRED=1

# pip args
args=( wheel --no-binary "${name}" --no-deps "${pkg}" -w "${target}" )

found=
for dir in /opt/python/*; do
    if [ "${dir/pypy}" != "${dir}" ]; then
        continue
    fi

    pyv="$(
        "${dir}/bin/python" -c 'import sys; sys.stdout.write("".join(map(str, sys.version_info[:2])))'
    )"
    if [ "${versions/${pyv}}" = "${versions}" ]; then
        continue
    fi

    "${dir}/bin/pip" "${args[@]}"
    chown -R -- "${owner}" "${target}"
    found=1
done

[ -n "${found}" ]

# Bundle external shared libraries into the wheels
for whl in "${target}"/*.whl; do
    base="$(basename -- "${whl}")"
    if [ "${base/${libc}}" = "${base}" ]; then
        auditwheel repair "${whl}" -w "${target}"
        chown -R -- "${owner}" "${target}"
    fi
done

# Only keep properly tagged wheels
for whl in "${target}"/*.whl; do
    base="$(basename -- "${whl}")"
    if [ "${base/-${libc}}" != "${base}" -a "${base/pypy}" = "${base}" ]; then
        mv -v -- "${whl}" "${final}"
    fi
done
rm -rf -- "${target}"
chown -R -- "${owner}" "${final}"

# The end.