From 1419d2889f1c94992ab7a55bf5399b261324c7f1 Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Thu, 25 Feb 2021 17:08:18 +0800 Subject: [PATCH] [CI][C++] Force CMake to find Python2 (#9690) Fixes #9682 ### Motivation Currently, ci-cpp-tests uses `pulsar-build` image that is from `ubuntu:16.04` to build C++/Python client. The image uses `libboost-all-dev` for CMake to find boost dependencies. However, the Boost.Python library from Ubuntu 16.04's apt source only supports Python 2. ### Modifications - Specifying `PYTHON_INCLUDE_DIR` and `PYTHON_LIBRARY` could indicate the installation of Python to use. Since the `pulsar-build` image only contains Python binary but not the Python2 library (`libpython2.7so`), this PR installs `libpython-dev` to setup the Python2 library. Otherwise, CMake would still find the Python3 library(`libpython3.5.so`). - Remove redundant C++ client dependencies like `libjsoncpp-dev` and replace `libboost-all-dev` with the specific `libboost-xxx-dev`. ### Verifying this change - [ ] Make sure that the change passes the CI checks. *(Please pick either of the following options)* This change is a trivial rework / code cleanup without any test coverage. --- .github/workflows/ci-cpp.yaml | 2 +- build/docker/Dockerfile | 8 +++++--- pulsar-client-cpp/docker-build.sh | 2 +- pulsar-client-cpp/docker-tests.sh | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci-cpp.yaml b/.github/workflows/ci-cpp.yaml index d73d799e33774..1887b4333910d 100644 --- a/.github/workflows/ci-cpp.yaml +++ b/.github/workflows/ci-cpp.yaml @@ -81,7 +81,7 @@ jobs: if: steps.docs.outputs.changed_only == 'no' run: | echo "Build C++ client library" - export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_DYNAMIC_LIB=OFF" + export CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Debug -DBUILD_DYNAMIC_LIB=OFF -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so" pulsar-client-cpp/docker-build.sh - name: run c++ tests diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 013bfdd35da24..26e6a7d4976f3 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -28,10 +28,11 @@ RUN apt-get update && \ add-apt-repository ppa:openjdk-r/ppa && \ apt-get update && \ apt-get install -y tig g++ cmake libssl-dev libcurl4-openssl-dev \ - liblog4cxx-dev libprotobuf-dev libboost-all-dev google-mock libgtest-dev \ - libjsoncpp-dev libxml2-utils protobuf-compiler wget \ + liblog4cxx-dev libprotobuf-dev google-mock libgtest-dev \ + libboost-dev libboost-program-options-dev libboost-system-dev libboost-python-dev \ + libxml2-utils protobuf-compiler wget \ curl doxygen openjdk-8-jdk-headless openjdk-11-jdk-headless clang-format-5.0 \ - gnupg2 golang-1.13-go zip unzip libzstd-dev libsnappy-dev python3-pip + gnupg2 golang-1.13-go zip unzip libzstd-dev libsnappy-dev python3-pip libpython-dev # Compile and install gtest RUN cd /usr/src/gtest && cmake . && make && cp libgtest.a /usr/lib @@ -66,6 +67,7 @@ RUN wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb RUN dpkg -i crowdin.deb # Install PIP and PDoc +RUN wget https://bootstrap.pypa.io/2.7/get-pip.py && python get-pip.py && rm get-pip.py RUN pip3 install pdoc # Install Protobuf doc generator (requires Go) diff --git a/pulsar-client-cpp/docker-build.sh b/pulsar-client-cpp/docker-build.sh index 31fa5d9d1b31a..b615ae595985f 100755 --- a/pulsar-client-cpp/docker-build.sh +++ b/pulsar-client-cpp/docker-build.sh @@ -27,7 +27,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR/pulsar-client-cpp BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}" -BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04}" +BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04-py2}" IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION" diff --git a/pulsar-client-cpp/docker-tests.sh b/pulsar-client-cpp/docker-tests.sh index e5fd3e80969f8..0969c1c4c53f9 100755 --- a/pulsar-client-cpp/docker-tests.sh +++ b/pulsar-client-cpp/docker-tests.sh @@ -34,7 +34,7 @@ ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR/pulsar-client-cpp BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-build}" -BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04}" +BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-16.04-py2}" IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION"