Skip to content

Commit 724012b

Browse files
Simplify dependency upgrade process and upgrade Pulsar C++ client to 3.1.0 (#56)
### Motivation Currently there are many files that require the download URLs of dependencies to download them. It's hard to maintain if some download URL changed. For example, #17 updates the ZLib download URL under https://zlib.net/fossils/ for macOS build. However, the ZLib download URL for Linux is under https://github.com/madler/zlib/archive/. The same goes for the Pulsar C++ client, it's hard to test another URL because the candidates and the official releases are stored in different paths. ### Modifications Add a `dep-url.sh` to provide two shell functions: - `pulsar_cpp_base_url`: Print the base URL of the Pulsar C++ client release, there are the source code or binaries in the subpath. - `download_dependency`: Download the source code according to the dependency file and the dependency name. Then apply the `dep-url.sh` in all files that need to download the source or binary of the dependencies. In addition, this PR upgrades the `pulsar-cpp` dependency to 3.1.0 so that the Windows build can depend on an official release.
1 parent 9182dd7 commit 724012b

File tree

10 files changed

+120
-59
lines changed

10 files changed

+120
-59
lines changed

.github/workflows/ci-build-release-wheels.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,11 @@ jobs:
167167
- name: Download Pulsar C++ client on Windows
168168
shell: bash
169169
run: |
170+
source ./build-support/dep-url.sh
171+
BASE_URL=$(pulsar_cpp_base_url $(grep pulsar-cpp dependencies.yaml | awk '{print $2}'))
170172
mkdir -p ${{ env.PULSAR_CPP_DIR }}
171173
cd ${{ env.PULSAR_CPP_DIR }}
172-
# TODO: switch to official releases
173-
curl -O -L https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-cpp/pulsar-client-cpp-3.1.0-candidate-1/x64-windows-static.tar.gz
174+
curl -O -L ${BASE_URL}/x64-windows-static.tar.gz
174175
tar zxf x64-windows-static.tar.gz
175176
mv x64-windows-static/* .
176177
ls -l ${{ env.PULSAR_CPP_DIR }}

.github/workflows/ci-pr-validation.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ jobs:
199199
- name: Download Pulsar C++ client on Windows
200200
shell: bash
201201
run: |
202+
source ./build-support/dep-url.sh
203+
BASE_URL=$(pulsar_cpp_base_url $(grep pulsar-cpp dependencies.yaml | awk '{print $2}'))
202204
mkdir -p ${{ env.PULSAR_CPP_DIR }}
203205
cd ${{ env.PULSAR_CPP_DIR }}
204-
# TODO: switch to official releases
205-
curl -O -L https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-cpp/pulsar-client-cpp-3.1.0-candidate-1/x64-windows-static.tar.gz
206+
curl -O -L ${BASE_URL}/x64-windows-static.tar.gz
206207
tar zxf x64-windows-static.tar.gz
207208
mv x64-windows-static/* .
208209
ls -l ${{ env.PULSAR_CPP_DIR }}

build-support/copy-deps-versionfile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ for dir in manylinux2014 manylinux_musl; do
2626
mkdir -p pkg/$dir/.build
2727
cp $ROOT_DIR/dependencies.yaml pkg/$dir/.build
2828
cp $ROOT_DIR/build-support/dep-version.py pkg/$dir/.build
29+
cp $ROOT_DIR/build-support/dep-url.sh pkg/$dir/.build
2930
done

build-support/dep-url.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
pulsar_cpp_base_url() {
21+
if [[ $# -ne 1 ]]; then
22+
echo "Usage: pulsar_cpp_base_url <version>"
23+
exit 1
24+
fi
25+
VERSION=$1
26+
# TODO: use official release url from https://archive.apache.org/
27+
echo "https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-cpp/pulsar-client-cpp-${VERSION}-candidate-3"
28+
}
29+
30+
download_dependency() {
31+
if [[ $# -ne 2 ]]; then
32+
echo "Usage: download_dependency <dependency-name> <dependency-version>"
33+
exit 1
34+
fi
35+
36+
DEP_FILE=$1
37+
DEP=$2
38+
# Here we don't use read command to make it available in Alpine
39+
VERSION=$(grep $DEP $DEP_FILE | sed 's/://' | awk '{print $2}')
40+
41+
case $DEP in
42+
"cmake")
43+
URL=https://github.com/Kitware/CMake/releases/download/v${VERSION}/cmake-${VERSION}-linux-${ARCH}.tar.gz
44+
;;
45+
"pulsar-cpp")
46+
URL=$(pulsar_cpp_base_url $VERSION)/apache-pulsar-client-cpp-${VERSION}.tar.gz
47+
;;
48+
"pybind11")
49+
URL=https://github.com/pybind/pybind11/archive/refs/tags/v${VERSION}.tar.gz
50+
;;
51+
"boost")
52+
VERSION_UNDERSCORE=$(echo $VERSION | sed 's/\./_/g')
53+
URL=https://boostorg.jfrog.io/artifactory/main/release/${VERSION}/source/boost_${VERSION_UNDERSCORE}.tar.gz
54+
;;
55+
"protobuf")
56+
URL=https://github.com/google/protobuf/releases/download/v${VERSION}/protobuf-cpp-${VERSION}.tar.gz
57+
;;
58+
"zlib")
59+
URL=https://github.com/madler/zlib/archive/v${VERSION}.tar.gz
60+
;;
61+
"zstd")
62+
URL=https://github.com/facebook/zstd/releases/download/v${VERSION}/zstd-${VERSION}.tar.gz
63+
;;
64+
"snappy")
65+
URL=https://github.com/google/snappy/archive/refs/tags/${VERSION}.tar.gz
66+
;;
67+
"openssl")
68+
URL=https://github.com/openssl/openssl/archive/OpenSSL_$(echo $VERSION | sed 's/\./_/g').tar.gz
69+
;;
70+
"curl")
71+
VERSION_UNDERSCORE=$(echo $VERSION | sed 's/\./_/g')
72+
URL=https://github.com/curl/curl/releases/download/curl-${VERSION_UNDERSCORE}/curl-${VERSION}.tar.gz
73+
;;
74+
*)
75+
echo "Unknown dependency $DEP for version $VERSION"
76+
exit 1
77+
esac
78+
curl -O -L $URL
79+
tar zxf $(basename $URL)
80+
}

build-support/install-dependencies.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ cd `dirname $0`
2424

2525
CPP_CLIENT_VERSION=$(./dep-version.py pulsar-cpp ../dependencies.yaml)
2626
PYBIND11_VERSION=$(./dep-version.py pybind11 ../dependencies.yaml)
27+
source ./dep-url.sh
2728

2829
if [ $USER != "root" ]; then
2930
SUDO="sudo"
@@ -35,7 +36,7 @@ export $(cat /etc/*-release | grep "^ID=")
3536
cd /tmp
3637

3738
# Fetch the client binaries
38-
BASE_URL=https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-cpp-${CPP_CLIENT_VERSION}
39+
BASE_URL=$(pulsar_cpp_base_url ${CPP_CLIENT_VERSION})
3940

4041
UNAME_ARCH=$(uname -m)
4142
if [ $UNAME_ARCH == 'aarch64' ]; then

dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919

2020
cmake: 3.24.2
21-
pulsar-cpp: 3.0.0
21+
pulsar-cpp: 3.1.0
2222
pybind11: 2.10.1
2323
boost: 1.80.0
2424
protobuf: 3.20.0

pkg/mac/build-dependencies.sh

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PYTHON_VERSION=$1
2727
PYTHON_VERSION_LONG=$2
2828

2929
source pkg/mac/common.sh
30+
source build-support/dep-url.sh
3031

3132
pip3 install pyyaml
3233

@@ -49,8 +50,7 @@ PREFIX=$CACHE_DIR/install
4950

5051
###############################################################################
5152
if [ ! -f pybind11/.done ]; then
52-
curl -L -O https://github.com/pybind/pybind11/archive/refs/tags/v${PYBIND11_VERSION}.tar.gz
53-
tar zxf v${PYBIND11_VERSION}.tar.gz
53+
download_dependency $ROOT_DIR/dependencies.yaml pybind11
5454
mkdir -p $PREFIX/include/
5555
cp -rf pybind11-${PYBIND11_VERSION}/include/pybind11 $PREFIX/include/
5656
mkdir -p pybind11
@@ -60,8 +60,7 @@ fi
6060
###############################################################################
6161
if [ ! -f zlib-${ZLIB_VERSION}/.done ]; then
6262
echo "Building ZLib"
63-
curl -O -L https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
64-
tar xfz zlib-$ZLIB_VERSION.tar.gz
63+
download_dependency $ROOT_DIR/dependencies.yaml zlib
6564
pushd zlib-$ZLIB_VERSION
6665
CFLAGS="-fPIC -O3 -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" ./configure --prefix=$PREFIX
6766
make -j16
@@ -102,7 +101,7 @@ fi
102101
OPENSSL_VERSION_UNDERSCORE=$(echo $OPENSSL_VERSION | sed 's/\./_/g')
103102
if [ ! -f openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.done ]; then
104103
echo "Building OpenSSL"
105-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
104+
download_dependency $ROOT_DIR/dependencies.yaml openssl
106105
# -arch arm64 -arch x86_64
107106
tar xfz OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
108107

@@ -140,8 +139,7 @@ fi
140139
BOOST_VERSION_=${BOOST_VERSION//./_}
141140
if [ ! -f boost/.done ]; then
142141
echo "Building Boost for Py $PYTHON_VERSION"
143-
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_}.tar.gz
144-
tar xfz boost_${BOOST_VERSION_}.tar.gz
142+
download_dependency $ROOT_DIR/dependencies.yaml boost
145143
cp -rf boost_${BOOST_VERSION_}/boost $PREFIX/include/
146144
mkdir -p boost
147145
touch .done
@@ -150,8 +148,7 @@ fi
150148
###############################################################################
151149
if [ ! -f protobuf-${PROTOBUF_VERSION}/.done ]; then
152150
echo "Building Protobuf"
153-
curl -O -L https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
154-
tar xfz protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
151+
download_dependency $ROOT_DIR/dependencies.yaml protobuf
155152
pushd protobuf-${PROTOBUF_VERSION}
156153
CXXFLAGS="-fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
157154
./configure --prefix=$PREFIX
@@ -166,8 +163,7 @@ fi
166163
###############################################################################
167164
if [ ! -f zstd-${ZSTD_VERSION}/.done ]; then
168165
echo "Building ZStd"
169-
curl -O -L https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz
170-
tar xfz zstd-${ZSTD_VERSION}.tar.gz
166+
download_dependency $ROOT_DIR/dependencies.yaml zstd
171167
pushd zstd-${ZSTD_VERSION}
172168
CFLAGS="-fPIC -O3 -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" PREFIX=$PREFIX \
173169
make -j16 -C lib install-static install-includes
@@ -180,8 +176,7 @@ fi
180176
###############################################################################
181177
if [ ! -f snappy-${SNAPPY_VERSION}/.done ]; then
182178
echo "Building Snappy"
183-
curl -O -L https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz
184-
tar xfz ${SNAPPY_VERSION}.tar.gz
179+
download_dependency $ROOT_DIR/dependencies.yaml snappy
185180
pushd snappy-${SNAPPY_VERSION}
186181
CXXFLAGS="-fPIC -O3 -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
187182
cmake . -DCMAKE_INSTALL_PREFIX=$PREFIX -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF
@@ -197,8 +192,7 @@ fi
197192
if [ ! -f curl-${CURL_VERSION}/.done ]; then
198193
echo "Building LibCurl"
199194
CURL_VERSION_=${CURL_VERSION//./_}
200-
curl -O -L https://github.com/curl/curl/releases/download/curl-${CURL_VERSION_}/curl-${CURL_VERSION}.tar.gz
201-
tar xfz curl-${CURL_VERSION}.tar.gz
195+
download_dependency $ROOT_DIR/dependencies.yaml curl
202196
pushd curl-${CURL_VERSION}
203197
CFLAGS="-fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
204198
./configure --with-ssl=$PREFIX \

pkg/mac/build-pulsar-cpp.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
2424
cd "${ROOT_DIR}"
2525

2626
source pkg/mac/common.sh
27+
source build-support/dep-url.sh
2728

2829
PULSAR_CPP_VERSION=$(./build-support/dep-version.py pulsar-cpp)
2930

@@ -36,8 +37,7 @@ PREFIX=$CACHE_DIR_CPP_CLIENT/install
3637
DEPS_PREFIX=${CACHE_DIR_DEPS}/install
3738

3839
###############################################################################
39-
40-
curl -O -L https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-cpp-${PULSAR_CPP_VERSION}/apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}.tar.gz
40+
download_dependency $ROOT_DIR/dependencies.yaml pulsar-cpp
4141
tar xfz apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}.tar.gz
4242

4343
if [ ! -f apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}/.done ]; then

pkg/manylinux2014/Dockerfile

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,62 +36,56 @@ RUN pip3 install pyyaml
3636

3737
ADD .build/dependencies.yaml /
3838
ADD .build/dep-version.py /usr/local/bin
39+
ADD .build/dep-url.sh /
3940

4041
# Download and install boost
4142
RUN BOOST_VERSION=$(dep-version.py boost) && \
4243
BOOST_VERSION_UNDESRSCORE=$(echo $BOOST_VERSION | sed 's/\./_/g') && \
43-
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_UNDESRSCORE}.tar.gz && \
44-
tar xfz boost_${BOOST_VERSION_UNDESRSCORE}.tar.gz && \
44+
. /dep-url.sh && download_dependency /dependencies.yaml boost && \
4545
cp -r boost_${BOOST_VERSION_UNDESRSCORE}/boost /usr/include/ && \
4646
rm -rf /boost_${BOOST_VERSION_UNDESRSCORE}.tar.gz /boost_${BOOST_VERSION_UNDESRSCORE}
4747

4848
RUN CMAKE_VERSION=$(dep-version.py cmake) && \
49-
curl -O -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-${ARCH}.tar.gz && \
50-
tar xfz cmake-${CMAKE_VERSION}-linux-${ARCH}.tar.gz && \
49+
. /dep-url.sh && ARCH=${ARCH} download_dependency /dependencies.yaml cmake && \
5150
cp cmake-${CMAKE_VERSION}-linux-${ARCH}/bin/* /usr/bin/ && \
5251
cp -r cmake-${CMAKE_VERSION}-linux-${ARCH}/share/cmake-* /usr/share/ && \
5352
rm -rf cmake-${CMAKE_VERSION}-linux-${ARCH} cmake-${CMAKE_VERSION}-linux-${ARCH}.tar.gz
5453

5554
# Download and compile protobuf
5655
RUN PROTOBUF_VERSION=$(dep-version.py protobuf) && \
57-
curl -O -L https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz && \
58-
tar xfz protobuf-cpp-${PROTOBUF_VERSION}.tar.gz && \
56+
. /dep-url.sh && download_dependency /dependencies.yaml protobuf && \
5957
cd protobuf-${PROTOBUF_VERSION}/ && \
6058
CXXFLAGS=-fPIC ./configure && \
6159
make -j8 && make install && ldconfig && \
6260
rm -rf /protobuf-cpp-${PROTOBUF_VERSION}.tar.gz /protobuf-${PROTOBUF_VERSION}
6361

6462
# ZLib
6563
RUN ZLIB_VERSION=$(dep-version.py zlib) && \
66-
curl -O -L https://github.com/madler/zlib/archive/v${ZLIB_VERSION}.tar.gz && \
67-
tar xfz v${ZLIB_VERSION}.tar.gz && \
64+
. /dep-url.sh && download_dependency /dependencies.yaml zlib && \
6865
cd zlib-${ZLIB_VERSION} && \
6966
CFLAGS="-fPIC -O3" ./configure && \
7067
make -j8 && make install && \
7168
rm -rf /v${ZLIB_VERSION}.tar.gz /zlib-${ZLIB_VERSION}
7269

7370
# Zstandard
7471
RUN ZSTD_VERSION=$(dep-version.py zstd) && \
75-
curl -O -L https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz && \
76-
tar xfz zstd-${ZSTD_VERSION}.tar.gz && \
72+
. /dep-url.sh && download_dependency /dependencies.yaml zstd && \
7773
cd zstd-${ZSTD_VERSION} && \
7874
CFLAGS="-fPIC -O3" make -j8 && \
7975
make install && \
8076
rm -rf /zstd-${ZSTD_VERSION} /zstd-${ZSTD_VERSION}.tar.gz
8177

8278
# Snappy
8379
RUN SNAPPY_VERSION=$(dep-version.py snappy) && \
84-
curl -O -L https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz && \
85-
tar xfz ${SNAPPY_VERSION}.tar.gz && \
80+
. /dep-url.sh && download_dependency /dependencies.yaml snappy && \
8681
cd snappy-${SNAPPY_VERSION} && \
8782
CXXFLAGS="-fPIC -O3" cmake . -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF && \
8883
make -j8 && make install && \
8984
rm -rf /snappy-${SNAPPY_VERSION} /${SNAPPY_VERSION}.tar.gz
9085

9186
RUN OPENSSL_VERSION=$(dep-version.py openssl) && \
9287
OPENSSL_VERSION_UNDERSCORE=$(echo $OPENSSL_VERSION | sed 's/\./_/g') && \
93-
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz && \
94-
tar xfz OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz && \
88+
. /dep-url.sh && download_dependency /dependencies.yaml openssl && \
9589
cd openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}/ && \
9690
./config -fPIC --prefix=/usr/local/ssl/ && \
9791
make -j8 && make install && \
@@ -102,18 +96,15 @@ ENV OPENSSL_ROOT_DIR /usr/local/ssl/
10296

10397
# LibCurl
10498
RUN CURL_VERSION=$(dep-version.py curl) && \
105-
CURL_VERSION_UNDERSCORE=$(echo $CURL_VERSION | sed 's/\./_/g') && \
106-
curl -O -L https://github.com/curl/curl/releases/download/curl-${CURL_VERSION_UNDERSCORE}/curl-${CURL_VERSION}.tar.gz && \
107-
tar xfz curl-${CURL_VERSION}.tar.gz && \
99+
. /dep-url.sh && download_dependency /dependencies.yaml curl && \
108100
cd curl-${CURL_VERSION} && \
109101
CFLAGS=-fPIC ./configure --with-ssl=/usr/local/ssl/ --without-zstd && \
110102
make -j8 && make install && \
111103
rm -rf /curl-${CURL_VERSION}.tar.gz /curl-${CURL_VERSION}
112104

113105
# Pulsar client C++
114106
RUN PULSAR_CPP_VERSION=$(dep-version.py pulsar-cpp) && \
115-
curl -O -L https://archive.apache.org/dist/pulsar/pulsar-client-cpp-${PULSAR_CPP_VERSION}/apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}.tar.gz && \
116-
tar xfz apache-pulsar-client-cpp-${PULSAR_CPP_VERSION}.tar.gz && \
107+
. /dep-url.sh && download_dependency /dependencies.yaml pulsar-cpp && \
117108
cd apache-pulsar-client-cpp-${PULSAR_CPP_VERSION} && \
118109
cmake . -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_STATIC_LIB=OFF -DLINK_STATIC=ON && \
119110
make -j8 && \

0 commit comments

Comments
 (0)