File: build-manylinux.sh

package info (click to toggle)
python-confluent-kafka 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,660 kB
  • sloc: python: 30,428; ansic: 9,487; sh: 1,477; makefile: 192
file content (102 lines) | stat: -rwxr-xr-x 2,948 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
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
#!/bin/bash
#
#
# Builds autonomous Python packages including all dependencies
# using the excellent manylinux docker images and the equally awesome
# auditwheel tool.
#
# This script should be run in a docker image where the confluent-kafka-python
# directory is mapped as /io .
#
# Usage on host:
#  tools/build-manylinux.sh <librdkafka_tag>
#
# Usage in container:
#  docker run -t -v $(pwd):/io quay.io/pypa/manylinux2010_x86_64:latest  /io/tools/build-manylinux.sh <librdkafka_tag>

LIBRDKAFKA_VERSION=$1
PYTHON_VERSIONS=("cp37" "cp38" "cp39" "cp310" "cp311" "cp312" "cp313")

if [[ -z "$LIBRDKAFKA_VERSION" ]]; then
    echo "Usage: $0 <librdkafka_tag>"
    exit 1
fi

set -ex

if [[ ! -f /.dockerenv ]]; then
    #
    # Running on host, fire up a docker container a run it.
    #

    if [[ ! -f tools/$(basename $0) ]]; then
        echo "Must be called from confluent-kafka-python root directory"
        exit 1
    fi

    if [[ $ARCH == arm64* ]]; then
        docker_image=quay.io/pypa/manylinux_2_28_aarch64:latest
    else
        docker_image=quay.io/pypa/manylinux_2_28_x86_64:latest
    fi

    docker run -t -v $(pwd):/io $docker_image  /io/tools/build-manylinux.sh "v${LIBRDKAFKA_VERSION}"

    exit $?
fi


#
# Running in container
#

echo "# Installing basic system dependencies"
yum install -y zlib-devel gcc-c++ python3 curl-devel perl-IPC-Cmd perl-Pod-Html

echo "# Building librdkafka ${LIBRDKAFKA_VERSION}"
$(dirname $0)/bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} /usr

# Compile wheels
echo "# Compile"
for PYBIN in /opt/python/cp*/bin; do
    for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"; do
        if [[ $PYBIN == *"$PYTHON_VERSION"* ]]; then
            echo "## Compiling $PYBIN"
            CFLAGS="-Werror -Wno-strict-aliasing -Wno-parentheses" \
            "${PYBIN}/pip" wheel /io/ -w unrepaired-wheelhouse/
            break
        fi
    done
done

# Bundle external shared libraries into the wheels
echo "# auditwheel repair"
mkdir -p /io/wheelhouse
for whl in unrepaired-wheelhouse/*.whl; do
    echo "## Repairing $whl"
    auditwheel repair "$whl" -w /io/wheelhouse
done

echo "# Repaired wheels"
for whl in /io/wheelhouse/*.whl; do
    echo "## Repaired wheel $whl"
    auditwheel show "$whl"
done

# Install packages and test
echo "# Installing wheels"
for PYBIN in /opt/python/cp*/bin; do
    for PYTHON_VERSION in "${PYTHON_VERSIONS[@]}"; do
        if [[ $PYBIN == *"$PYTHON_VERSION"* ]]; then
            echo "## Installing $PYBIN"
            "${PYBIN}/pip" -V
            "${PYBIN}/pip" install --no-index -f /io/wheelhouse confluent_kafka 
            "${PYBIN}/python" -c 'import confluent_kafka; print(confluent_kafka.libversion())'
            "${PYBIN}/pip" install pytest
            "${PYBIN}/pytest" /io/tests/test_Producer.py
            echo "## Uninstalling $PYBIN"
            "${PYBIN}/pip" uninstall -y confluent_kafka
            break
        fi
    done
done