Skip to content

Commit

Permalink
[CI][C++] Force CMake to find Python2 (apache#9690)
Browse files Browse the repository at this point in the history
Fixes apache#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.
  • Loading branch information
BewareMyPower authored Feb 25, 2021
1 parent 371b311 commit 1419d28
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions build/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pulsar-client-cpp/docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion pulsar-client-cpp/docker-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 1419d28

Please sign in to comment.