4
4
# Builds autonomous Python packages including all available dependencies
5
5
# using docker.
6
6
#
7
- # This is a tiny linux alternative to cibuildwheel as a workaround
8
- # to provide --volumes-from=.. on docker-in-docker builds.
7
+ # This is a tiny linux alternative to cibuildwheel on linux that does
8
+ # not rely on Docker volumes to work (such as for docker-in-docker).
9
+ #
10
+ # The in-docker portion of this script is based on cibuildwheel's counterpart.
9
11
#
10
12
11
- if [[ $# -lt 3 ]]; then
12
- echo " Usage: $0 <librdkafka_tag> <repo-dir-full-path> <relative- out-dir>"
13
+ if [[ $# -ne 2 ]]; then
14
+ echo " Usage: $0 <librdkafka_tag> <out-dir>"
13
15
exit 1
14
16
fi
15
17
16
18
set -ex
17
19
18
20
if [[ $1 != " --in-docker" ]]; then
19
21
# Outside our docker
20
- workdir=$2
21
- if [[ -f /.dockerenv ]]; then
22
- echo " $0 : $HOSTNAME : Currently running from inside docker: exposing host mounts"
23
- docker run -i --volumes-from=$HOSTNAME quay.io/pypa/manylinux1_x86_64 $workdir /tools/build-linux-selfcontained.sh --in-docker $1 $2 $3
24
- else
25
- echo " $0 : $HOSTNAME : Not currently running from inside docker: exposing $2 as volume"
26
- docker run -i -v $workdir :$workdir quay.io/pypa/manylinux1_x86_64 $workdir /tools/build-linux-selfcontained.sh --in-docker $1 $2 $3
27
- fi
22
+ LIBRDKAFKA_VERSION=$1
23
+ outdir=$2
24
+ [[ ! -d $outdir ]] || mkdir -p $outdir
25
+
26
+ docker_image=quay.io/pypa/manylinux1_x86_64
27
+
28
+ script_in_docker=/tmp/$( basename $0 )
29
+
30
+ # Create container
31
+ container=$( basename $( mktemp -u pywhlXXXXXX) )
32
+ docker create -i --name $container $docker_image $script_in_docker --in-docker $LIBRDKAFKA_VERSION
33
+
34
+ # Create archive
35
+ git archive -o src.tar.gz HEAD
36
+
37
+ # Copy this script to container
38
+ docker cp $0 $container :$script_in_docker
39
+
40
+ # Copy archive to container
41
+ docker cp src.tar.gz $container :/tmp/
42
+
43
+ # Run this script in docker
44
+ docker start -i $container
45
+
46
+ # Copy artifacts from container
47
+ rm -rf $outdir /output
48
+ docker cp $container :/output $outdir /
49
+ mv $outdir /output/* $outdir /
50
+ rm -rf $outdir /output
51
+
52
+ # Remove container
53
+ docker rm $container
54
+
55
+ echo " Artifacts now available in $outdir :"
56
+ ls -la $outdir /
57
+
28
58
exit 0
29
59
fi
30
60
61
+
31
62
#
32
63
# Inside our docker
33
64
#
34
65
66
+ if [[ $# -ne $2 ]]; then
67
+ echo " Inner usage: $0 --in-docker <librdkafka_tag>"
68
+ exit 1
69
+ fi
70
+
35
71
echo " $0 : $HOSTNAME : Run"
36
72
37
73
shift # remove --in-docker
38
74
39
75
LIBRDKAFKA_VERSION=$1
40
- WORKDIR=$2
41
- OUTDIR=$3
42
76
43
77
44
78
function install_deps {
@@ -49,25 +83,28 @@ function install_deps {
49
83
yum install -y zlib-devel gcc gcc-c++ libstdc++-devel
50
84
51
85
# Build OpenSSL
52
- $( dirname $0 ) /build-openssl.sh /usr
86
+ tools /build-openssl.sh /usr
53
87
54
88
fi
55
89
}
56
90
57
91
function build_librdkafka {
58
92
local dest=$1
59
93
echo " # Building librdkafka ${LIBRDKAFKA_VERSION} "
60
- $( dirname $0 ) /bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} $dest
94
+ tools /bootstrap-librdkafka.sh --require-ssl ${LIBRDKAFKA_VERSION} $dest
61
95
62
96
}
63
97
64
98
65
99
function build {
66
100
local workdir=$1
67
- local outdir=$2
101
+ local outdir=/output
68
102
103
+ mkdir -p $workdir
69
104
pushd $workdir
70
105
106
+ tar xvzf /tmp/src.tar.gz
107
+
71
108
install_deps
72
109
73
110
build_librdkafka /usr
@@ -101,10 +138,13 @@ function build {
101
138
102
139
# we're all done here; move it to output
103
140
mv " $delocated_wheel " $outdir /
141
+ ls -la $outdir /
104
142
done
105
143
106
144
popd # workdir
107
145
}
108
146
109
- build $WORKDIR $OUTDIR
147
+ echo " $0 : $HOSTNAME : Building in docker"
148
+ build /build
149
+ echo " $0 : $HOSTNAME : Done"
110
150
0 commit comments