This is an automated email from the ASF dual-hosted git repository.

mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new 2b2e0c50183 PIP-155: Removed Python 2 support (#15376)
2b2e0c50183 is described below

commit 2b2e0c50183c71e954f5c6e8bfcd7e36130279a5
Author: Matteo Merli <[email protected]>
AuthorDate: Wed May 4 23:01:13 2022 -0700

    PIP-155: Removed Python 2 support (#15376)
    
    * Remove Pulsar Client Build for Python 2.7
    
    * Remove outdated homebrew files (source of truth is upstream homebrew)
    
    * Remove Python 2.7 build references; print error in some cases
    
    * Update python client tests to run with python client for python 3.5m
    
    * PIP-155: Removed Python 2 support
    
    * Fixed invocation in pulsar-build image
    
    * Fixed clang-format-10 indent differences
    
    * Fixed script invocation with wrong python
    
    * We don't need to rebuild the manylinux image each time
    
    * Fixed image name
    
    * Reverted back to use newer protobuf
    
    * Fixed image name
    
    * Fixed missing python3 in centos:7 image
    
    * Use python3 for gtest-parallel
    
    * Show bash commands in docker-tests.sh
    
    * Fixed gh action issue with git directory permissions
    
    * Fixed python to 3
    
    * Fixed custom_logger_test.py
    
    * Fixed path in run_python_instance_tests.sh
    
    * Function runtime should use python3
    
    * Fixed function runtime test python expectation
    
    * Fixed presto worker launcher
    
    * Fixed notes on how to format C++ code
    
    Co-authored-by: Michael Marshall <[email protected]>
---
 .github/workflows/ci-cpp.yaml                      |  1 -
 bin/pulsar                                         |  2 +-
 bin/pulsar-managed-ledger-admin                    |  2 +-
 build/docker/Dockerfile                            | 39 ++++++------
 docker/pulsar/Dockerfile                           |  2 -
 .../scripts/apply-config-from-env-with-prefix.py   |  2 +-
 docker/pulsar/scripts/apply-config-from-env.py     |  2 +-
 docker/pulsar/scripts/gen-yml-from-env.py          |  2 +-
 docker/pulsar/scripts/watch-znode.py               |  2 +-
 pulsar-client-cpp/CMakeLists.txt                   | 30 +++------
 pulsar-client-cpp/README.md                        | 23 +------
 .../build-support/run_clang_format.py              |  2 +-
 pulsar-client-cpp/docker-build-centos7.sh          |  5 +-
 pulsar-client-cpp/docker-build-python3.9.sh        | 17 ++---
 pulsar-client-cpp/docker-build.sh                  |  2 +-
 pulsar-client-cpp/docker-format.sh                 |  2 +-
 pulsar-client-cpp/docker-tests.sh                  |  4 +-
 pulsar-client-cpp/docker/centos-7/Dockerfile       |  3 +
 pulsar-client-cpp/docker/python-versions.sh        |  5 +-
 pulsar-client-cpp/homebrew/libpulsar.rb            | 72 ----------------------
 .../include/pulsar/c/client_configuration.h        |  8 ++-
 .../include/pulsar/c/consumer_configuration.h      |  9 ++-
 .../include/pulsar/c/producer_configuration.h      | 19 ++++--
 pulsar-client-cpp/include/pulsar/c/result.h        |  3 +-
 pulsar-client-cpp/lib/CMakeLists.txt               |  2 +-
 pulsar-client-cpp/lib/LogUtils.cc                  |  2 +-
 pulsar-client-cpp/lib/checksum/crc32c_arm.h        | 10 +--
 pulsar-client-cpp/lib/lz4/lz4.cc                   | 42 ++++++++++---
 pulsar-client-cpp/lib/lz4/lz4.h                    |  2 +-
 pulsar-client-cpp/python/CMakeLists.txt            | 11 ----
 pulsar-client-cpp/python/custom_logger_test.py     |  4 +-
 pulsar-client-cpp/python/examples/rpc_client.py    |  2 +-
 pulsar-client-cpp/python/examples/rpc_server.py    |  2 +-
 pulsar-client-cpp/python/pkg/osx/vagrant-build.sh  | 22 -------
 pulsar-client-cpp/python/pulsar/__init__.py        |  2 +-
 .../python/pulsar/functions/__init__.py            |  1 -
 .../python/pulsar/functions/context.py             |  1 -
 .../python/pulsar/functions/function.py            |  1 -
 pulsar-client-cpp/python/pulsar/functions/serde.py |  1 -
 pulsar-client-cpp/python/pulsar_test.py            |  2 +-
 pulsar-client-cpp/python/schema_test.py            |  2 +-
 pulsar-client-cpp/python/test_consumer.py          |  2 +-
 pulsar-client-cpp/python/test_producer.py          |  2 +-
 pulsar-client-cpp/run-unit-tests.sh                | 22 +++----
 pulsar-client-cpp/tests/ProducerTest.cc            |  3 +-
 pulsar-client-cpp/tests/PulsarFriend.h             |  2 +-
 pulsar-client-cpp/wireshark/pulsarDissector.cc     |  4 +-
 .../instance/src/main/python/__init__.py           |  1 -
 .../instance/src/main/python/contextimpl.py        |  1 -
 pulsar-functions/instance/src/main/python/log.py   |  1 -
 .../instance/src/main/python/python_instance.py    |  1 -
 .../src/main/python/python_instance_main.py        |  2 +-
 .../instance/src/main/python/secretsprovider.py    |  1 -
 .../instance/src/main/python/server.py             |  1 -
 .../instance/src/main/python/state_context.py      |  1 -
 pulsar-functions/instance/src/main/python/util.py  |  1 -
 .../src/scripts/run_python_instance_tests.sh       |  8 +--
 .../config_based_append_function.py                |  1 -
 .../python-examples/custom_object_function.py      |  1 -
 .../python-examples/exclamation_function.py        |  1 -
 .../python-examples/logging_function.py            |  1 -
 .../python-examples/native_exclamation_function.py |  1 -
 .../python-examples/publish_function.py            |  1 -
 pulsar-functions/python-examples/thumbnailer.py    |  1 -
 .../typed_message_builder_publish.py               |  1 -
 pulsar-functions/python-examples/user_exception.py |  1 -
 pulsar-functions/python-examples/void_function.py  |  1 -
 .../python-examples/wordcount_function.py          |  1 -
 .../pulsar/functions/runtime/RuntimeUtils.java     |  2 +-
 .../runtime/kubernetes/KubernetesRuntimeTest.java  |  2 +-
 .../runtime/process/ProcessRuntimeTest.java        |  2 +-
 pulsar-functions/scripts/python/generate.sh        |  6 +-
 site2/docs/client-libraries-python.md              |  5 +-
 src/gen-pulsar-version-macro.py                    |  2 +-
 src/get-project-version.py                         |  2 +-
 src/set-project-version.sh                         |  2 +-
 .../python-examples/consumer_schema.py             |  2 +-
 .../python-examples/exception_function.py          |  1 -
 .../python-examples/exclamation_lib.py             |  1 -
 .../python-examples/exclamation_with_extra_deps.py |  1 -
 .../python-examples/producer_schema.py             |  2 +-
 81 files changed, 162 insertions(+), 299 deletions(-)

diff --git a/.github/workflows/ci-cpp.yaml b/.github/workflows/ci-cpp.yaml
index 8647cf8ecc9..1f9dc8b31ba 100644
--- a/.github/workflows/ci-cpp.yaml
+++ b/.github/workflows/ci-cpp.yaml
@@ -91,7 +91,6 @@ jobs:
         if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
         run: |
           echo "Build C++ client library"
-          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/bin/pulsar b/bin/pulsar
index 7c1133549a6..5371ef2e6ea 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -388,7 +388,7 @@ elif [ $COMMAND == "sql" ]; then
     exec $JAVA -cp "${PRESTO_HOME}/lib/*" io.prestosql.cli.Presto --server 
localhost:8081 "${@}"
 elif [ $COMMAND == "sql-worker" ]; then
     check_presto_libraries
-    exec ${PRESTO_HOME}/bin/launcher --etc-dir ${PULSAR_PRESTO_CONF} "${@}"
+    exec python3 ${PRESTO_HOME}/bin/launcher.py --etc-dir 
${PULSAR_PRESTO_CONF} "${@}"
 elif [ $COMMAND == "tokens" ]; then
     exec $JAVA $OPTS org.apache.pulsar.utils.auth.tokens.TokensCliUtils $@
 elif [ $COMMAND == "version" ]; then
diff --git a/bin/pulsar-managed-ledger-admin b/bin/pulsar-managed-ledger-admin
index 36ff51569cd..abe7f7b034c 100755
--- a/bin/pulsar-managed-ledger-admin
+++ b/bin/pulsar-managed-ledger-admin
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile
index 4b6b8a3a847..21868cc8b15 100644
--- a/build/docker/Dockerfile
+++ b/build/docker/Dockerfile
@@ -17,7 +17,7 @@
 # under the License.
 #
 
-FROM ubuntu:16.04
+FROM ubuntu:20.04
 
 # prepare the directory for pulsar related files
 RUN mkdir /pulsar
@@ -29,9 +29,18 @@ RUN apt-get update && \
     apt-get install -y tig g++ cmake libssl-dev libcurl4-openssl-dev \
                 liblog4cxx-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 libpython-dev wireshark-dev
+                libxml2-utils wget \
+                curl doxygen openjdk-17-jdk-headless clang-format \
+                gnupg2 golang-go zip unzip libzstd-dev libsnappy-dev 
wireshark-dev
+
+# Compile and install gtest & gmock
+RUN cd /usr/src/googletest && \
+    cmake . && \
+    make && \
+    make install
+
+# Include gtest parallel to speed up unit tests
+RUN git clone https://github.com/google/gtest-parallel.git
 
 # Build protobuf 3.x.y from source since the default protobuf from Ubuntu's 
apt source is 2.x.y
 RUN curl -O -L 
https://github.com/protocolbuffers/protobuf/releases/download/v3.17.3/protobuf-cpp-3.17.3.tar.gz
 && \
@@ -42,18 +51,6 @@ RUN curl -O -L 
https://github.com/protocolbuffers/protobuf/releases/download/v3.
     cd .. && rm -rf protobuf-3.17.3/ protobuf-cpp-3.17.3.tar.gz
 ENV LD_LIBRARY_PATH /usr/local/lib
 
-# Compile and install gtest
-RUN cd /usr/src/gtest && cmake . && make && cp libgtest.a /usr/lib
-
-# Compile and install google-mock
-RUN cd /usr/src/gmock && cmake . && make && cp libgmock.a /usr/lib
-
-# Include gtest parallel to speed up unit tests
-RUN git clone https://github.com/google/gtest-parallel.git
-
-ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
-ENV JAVA_HOME_11=/usr/lib/jvm/java-1.11.0-openjdk-amd64
-
 ## Website build dependencies
 
 # Install Ruby-2.4.1
@@ -74,21 +71,21 @@ RUN apt-get update && apt-get install yarn
 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/pip/2.7/get-pip.py && python get-pip.py && 
rm get-pip.py
+# Install PIP
+RUN curl https://bootstrap.pypa.io/get-pip.py  | python3 -
 RUN pip3 install pdoc
-
+#
 # Installation
 ARG MAVEN_VERSION=3.6.3
 ARG MAVEN_FILENAME="apache-maven-${MAVEN_VERSION}-bin.tar.gz"
 ARG MAVEN_HOME=/opt/maven
 ARG 
MAVEN_URL="http://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/${MAVEN_FILENAME}";
 ARG MAVEN_TMP="/tmp/${MAVEN_FILENAME}"
-RUN wget --no-verbose -O ${MAVEN_TMP} ${MAVEN_URL} 
+RUN wget --no-verbose -O ${MAVEN_TMP} ${MAVEN_URL}
 
 # Cleanup
 RUN tar xzf ${MAVEN_TMP}  -C /opt/ \
         && ln -s /opt/apache-maven-${MAVEN_VERSION} ${MAVEN_HOME} \
-        && ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin 
+        && ln -s ${MAVEN_HOME}/bin/mvn /usr/local/bin
 
 RUN unset MAVEN_VERSION
diff --git a/docker/pulsar/Dockerfile b/docker/pulsar/Dockerfile
index 1c053a751aa..769135d878f 100644
--- a/docker/pulsar/Dockerfile
+++ b/docker/pulsar/Dockerfile
@@ -62,8 +62,6 @@ RUN sed -i 
"s|http://archive\.ubuntu\.com/ubuntu/|${UBUNTU_MIRROR:-mirror://mirr
      && apt-get clean \
      && rm -rf /var/lib/apt/lists/*
 
-RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 10
-
 # Pulsar currently writes to the below directories, assuming the default 
configuration.
 # Note that number 4 is the reason that pulsar components need write access to 
the /pulsar directory.
 # 1. /pulsar/data - both bookkeepers and zookeepers use this directory
diff --git a/docker/pulsar/scripts/apply-config-from-env-with-prefix.py 
b/docker/pulsar/scripts/apply-config-from-env-with-prefix.py
index 3f6bc2e4d3b..31c53770895 100755
--- a/docker/pulsar/scripts/apply-config-from-env-with-prefix.py
+++ b/docker/pulsar/scripts/apply-config-from-env-with-prefix.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/docker/pulsar/scripts/apply-config-from-env.py 
b/docker/pulsar/scripts/apply-config-from-env.py
index a802ca6fdbe..b8b479fc15b 100755
--- a/docker/pulsar/scripts/apply-config-from-env.py
+++ b/docker/pulsar/scripts/apply-config-from-env.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/docker/pulsar/scripts/gen-yml-from-env.py 
b/docker/pulsar/scripts/gen-yml-from-env.py
index 4534ea9c168..ce19436b7e0 100755
--- a/docker/pulsar/scripts/gen-yml-from-env.py
+++ b/docker/pulsar/scripts/gen-yml-from-env.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/docker/pulsar/scripts/watch-znode.py 
b/docker/pulsar/scripts/watch-znode.py
index 8bef9a649cb..1183eb45353 100755
--- a/docker/pulsar/scripts/watch-znode.py
+++ b/docker/pulsar/scripts/watch-znode.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt
index 4fd18082f6c..1975cd64bf7 100644
--- a/pulsar-client-cpp/CMakeLists.txt
+++ b/pulsar-client-cpp/CMakeLists.txt
@@ -22,7 +22,7 @@ cmake_minimum_required(VERSION 3.4)
 project (pulsar-cpp)
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules")
 
-execute_process(COMMAND python 
${CMAKE_SOURCE_DIR}/../src/gen-pulsar-version-macro.py 
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PVM)
+execute_process(COMMAND ${CMAKE_SOURCE_DIR}/../src/gen-pulsar-version-macro.py 
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PVM)
 set(PVM_COMMENT "This is generated from Version.h.in by CMAKE. DO NOT EDIT 
DIRECTLY")
 configure_file(templates/Version.h.in include/pulsar/Version.h @ONLY)
 
@@ -269,18 +269,12 @@ if (BUILD_PYTHON_WRAPPER)
     find_package(PythonLibs REQUIRED)
     MESSAGE(STATUS "PYTHON: " ${PYTHONLIBS_VERSION_STRING})
 
-    if (PYTHONLIBS_VERSION_STRING MATCHES "^3.+$")
-        MESSAGE(STATUS "DETECTED Python 3")
-        string(REPLACE "." ";" PYTHONLIBS_VERSION_NO_LIST 
${PYTHONLIBS_VERSION_STRING})
-        list(GET PYTHONLIBS_VERSION_NO_LIST 0 PYTHONLIBS_VERSION_MAJOR)
-        list(GET PYTHONLIBS_VERSION_NO_LIST 1 PYTHONLIBS_VERSION_MINOR)
-        set(BOOST_PYTHON_NAME_POSTFIX 
${PYTHONLIBS_VERSION_MAJOR}${PYTHONLIBS_VERSION_MINOR})
-        # For python3 the lib name is boost_python3
-        set(BOOST_PYTHON_NAME_LIST 
python36;python37;python38;python39;python310;python3;python3-mt;python-py${BOOST_PYTHON_NAME_POSTFIX};python${BOOST_PYTHON_NAME_POSTFIX}-mt;python${BOOST_PYTHON_NAME_POSTFIX})
-    else ()
-        # Regular boost_python
-        set(BOOST_PYTHON_NAME_LIST 
python;python-mt;python-py27;python27-mt;python27)
-    endif ()
+    string(REPLACE "." ";" PYTHONLIBS_VERSION_NO_LIST 
${PYTHONLIBS_VERSION_STRING})
+    list(GET PYTHONLIBS_VERSION_NO_LIST 0 PYTHONLIBS_VERSION_MAJOR)
+    list(GET PYTHONLIBS_VERSION_NO_LIST 1 PYTHONLIBS_VERSION_MINOR)
+    set(BOOST_PYTHON_NAME_POSTFIX 
${PYTHONLIBS_VERSION_MAJOR}${PYTHONLIBS_VERSION_MINOR})
+    # For python3 the lib name is boost_python3
+    set(BOOST_PYTHON_NAME_LIST 
python37;python38;python39;python310;python3;python3-mt;python-py${BOOST_PYTHON_NAME_POSTFIX};python${BOOST_PYTHON_NAME_POSTFIX}-mt;python${BOOST_PYTHON_NAME_POSTFIX})
 
     foreach (BOOST_PYTHON_NAME IN LISTS BOOST_PYTHON_NAME_LIST)
         find_package(Boost QUIET COMPONENTS ${BOOST_PYTHON_NAME})
@@ -443,15 +437,9 @@ if (BUILD_WIRESHARK)
     add_subdirectory(wireshark)
 endif()
 
-# `make format` option
-if (NOT APPLE AND NOT WIN32)
-    set(CLANG_FORMAT_VERSION "5.0")
-endif()
-
-
 find_package(ClangTools)
 set(BUILD_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/build-support")
-add_custom_target(format python ${BUILD_SUPPORT_DIR}/run_clang_format.py
+add_custom_target(format ${BUILD_SUPPORT_DIR}/run_clang_format.py
         ${CLANG_FORMAT_BIN}
         0
         ${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
@@ -464,7 +452,7 @@ add_custom_target(format python 
${BUILD_SUPPORT_DIR}/run_clang_format.py
         ${CMAKE_SOURCE_DIR}/wireshark)
 
 # `make check-format` option (for CI test)
-add_custom_target(check-format python ${BUILD_SUPPORT_DIR}/run_clang_format.py
+add_custom_target(check-format ${BUILD_SUPPORT_DIR}/run_clang_format.py
         ${CLANG_FORMAT_BIN}
         1
         ${BUILD_SUPPORT_DIR}/clang_format_exclusions.txt
diff --git a/pulsar-client-cpp/README.md b/pulsar-client-cpp/README.md
index e7e55d24c0d..5c5330e37b3 100644
--- a/pulsar-client-cpp/README.md
+++ b/pulsar-client-cpp/README.md
@@ -274,26 +274,9 @@ ${PULSAR_PATH}/pulsar-test-service-stop.sh
 
 ## Requirements for Contributors
 
-It's recommended to install [LLVM](https://llvm.org/builds/) for `clang-tidy` 
and `clang-format`. Pulsar C++ client use `clang-format` 5.0 to format files, 
which is a little different with latest `clang-format`.
+It's recommended to install [LLVM](https://llvm.org/builds/) for `clang-tidy` 
and `clang-format`. Pulsar C++ client use `clang-format` 6.0+ to format files. 
 
-We welcome contributions from the open source community, kindly make sure your 
changes are backward compatible with GCC 4.8 and Boost 1.53.
-
-### Install `clang-format` on macOS
+Use `pulsar-client-cpp/docker-format.sh` to ensure the C++ sources are 
correctly formatted.
 
-`homebrew-core` does not have `clang-format@5`. You can install 
`clang-format@5` on your macOS using the tap below.
-```shell
-# Step 1: Add tap
-brew tap demogorgon314/clang-format
-
-# Step 2: Install clang-format@5
-brew install clang-format@5
-```
-### Install `clang-format` on Ubuntu 18.04
-You can find pre-built binaries on the LLVM website: 
https://releases.llvm.org/download.html#5.0.2
-
-Or you want to use apt install clang-format-5.0.
-```shell
-sudo apt update
-sudo apt install clang-format-5.0
-```
+We welcome contributions from the open source community, kindly make sure your 
changes are backward compatible with GCC 4.8 and Boost 1.53.
 
diff --git a/pulsar-client-cpp/build-support/run_clang_format.py 
b/pulsar-client-cpp/build-support/run_clang_format.py
index 21e5bbe338d..3c9949429d2 100755
--- a/pulsar-client-cpp/build-support/run_clang_format.py
+++ b/pulsar-client-cpp/build-support/run_clang_format.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/docker-build-centos7.sh 
b/pulsar-client-cpp/docker-build-centos7.sh
index e97e374181b..f93d379880c 100755
--- a/pulsar-client-cpp/docker-build-centos7.sh
+++ b/pulsar-client-cpp/docker-build-centos7.sh
@@ -26,9 +26,8 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
 cd $ROOT_DIR/pulsar-client-cpp
 
 IMAGE="${BUILD_IMAGE_NAME:-apachepulsar/pulsar-cpp-build-centos7}"
-cd ./docker/centos-7
-docker build -t "${IMAGE}" .
-cd -
+
+docker pull "${IMAGE}"
 
 VOLUME_OPTION=${VOLUME_OPTION:-"-v $ROOT_DIR:/pulsar"}
 COMMAND="cd /pulsar/pulsar-client-cpp && mkdir -p _builds && cd _builds &&
diff --git a/pulsar-client-cpp/docker-build-python3.9.sh 
b/pulsar-client-cpp/docker-build-python3.9.sh
index db5c9abd82a..cbad25c1284 100755
--- a/pulsar-client-cpp/docker-build-python3.9.sh
+++ b/pulsar-client-cpp/docker-build-python3.9.sh
@@ -26,24 +26,15 @@ ROOT_DIR=$(git rev-parse --show-toplevel)
 cd $ROOT_DIR/pulsar-client-cpp
 
 
-# Build manylinux2014 build image
+# Use manylinux2014 build image
 PYTHON_VERSION="3.9"
 PYTHON_SPEC="cp39-cp39"
 ARCH="x86_64"
-IMAGE_NAME=pulsar-build:manylinux-$PYTHON_SPEC-$ARCH
-
-docker build -t $IMAGE_NAME ./docker/manylinux2014 \
-        --build-arg PYTHON_VERSION=$PYTHON_VERSION \
-        --build-arg PYTHON_SPEC=$PYTHON_SPEC \
-        --build-arg ARCH=$ARCH
-
-
-# Build wheel file
-BUILD_IMAGE_NAME="${BUILD_IMAGE_NAME:-pulsar-build}"
-IMAGE=$BUILD_IMAGE_NAME:manylinux-$PYTHON_SPEC-$ARCH
+IMAGE_NAME=apachepulsar/pulsar-build
+IMAGE=$IMAGE_NAME:manylinux-$PYTHON_SPEC-$ARCH
 
 VOLUME_OPTION=${VOLUME_OPTION:-"-v $ROOT_DIR:/pulsar"}
 COMMAND="/pulsar/pulsar-client-cpp/docker/build-wheel-file-within-docker.sh"
-DOCKER_CMD="docker run -i ${VOLUME_OPTION} -e USE_FULL_POM_NAME -e 
NAME_POSTFIX ${IMAGE}"
+DOCKER_CMD="docker run -i ${VOLUME_OPTION} -e USE_FULL_POM_NAME -e 
NAME_POSTFIX -e ARCH=${ARCH} ${IMAGE}"
 
 $DOCKER_CMD bash -c "${COMMAND}"
diff --git a/pulsar-client-cpp/docker-build.sh 
b/pulsar-client-cpp/docker-build.sh
index f3b0a5f98db..649945eee04 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-pb3}"
+BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-20.04}"
 
 IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION"
 
diff --git a/pulsar-client-cpp/docker-format.sh 
b/pulsar-client-cpp/docker-format.sh
index b11f09cad04..9fe2866a46f 100755
--- a/pulsar-client-cpp/docker-format.sh
+++ b/pulsar-client-cpp/docker-format.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-pb3}"
+BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-20.04}"
 
 IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION"
 
diff --git a/pulsar-client-cpp/docker-tests.sh 
b/pulsar-client-cpp/docker-tests.sh
index 13de4cc08b5..e0296fdd307 100755
--- a/pulsar-client-cpp/docker-tests.sh
+++ b/pulsar-client-cpp/docker-tests.sh
@@ -21,7 +21,7 @@
 # Run C++ unit tests within a Docker container
 
 # Fail script in case of errors
-set -e
+set -e -x
 
 if [ "$1" = "--help" ]; then
     echo "Usage:"
@@ -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-pb3}"
+BUILD_IMAGE_VERSION="${BUILD_IMAGE_VERSION:-ubuntu-20.04}"
 
 IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION"
 
diff --git a/pulsar-client-cpp/docker/centos-7/Dockerfile 
b/pulsar-client-cpp/docker/centos-7/Dockerfile
index 690e8f1f73f..f7b86d8d941 100644
--- a/pulsar-client-cpp/docker/centos-7/Dockerfile
+++ b/pulsar-client-cpp/docker/centos-7/Dockerfile
@@ -42,3 +42,6 @@ RUN curl -O -L 
https://github.com/google/googletest/archive/refs/tags/release-1.
   && cd googletest-release-1.10.0 \
   && mkdir build && cd build \
   && /opt/cmake/cmake-3.4.0-Linux-x86_64/bin/cmake .. && make install
+
+
+RUN yum install -y python3
\ No newline at end of file
diff --git a/pulsar-client-cpp/docker/python-versions.sh 
b/pulsar-client-cpp/docker/python-versions.sh
index 246eae914a3..e83d5d9c67b 100644
--- a/pulsar-client-cpp/docker/python-versions.sh
+++ b/pulsar-client-cpp/docker/python-versions.sh
@@ -18,14 +18,11 @@
 #
 
 PYTHON_VERSIONS=(
-   '2.7  cp27-cp27mu manylinux1    x86_64'
-   '2.7  cp27-cp27m  manylinux1    x86_64'
-   '3.5  cp35-cp35m  manylinux1    x86_64'
-   '3.6  cp36-cp36m  manylinux2014 x86_64'
    '3.7  cp37-cp37m  manylinux2014 x86_64'
    '3.8  cp38-cp38   manylinux2014 x86_64'
    '3.9  cp39-cp39   manylinux2014 x86_64'
    '3.10 cp310-cp310 manylinux2014 x86_64'
+
    '3.7  cp37-cp37m  manylinux2014 aarch64'
    '3.8  cp38-cp38   manylinux2014 aarch64'
    '3.9  cp39-cp39   manylinux2014 aarch64'
diff --git a/pulsar-client-cpp/homebrew/libpulsar.rb 
b/pulsar-client-cpp/homebrew/libpulsar.rb
deleted file mode 100644
index 1642a795383..00000000000
--- a/pulsar-client-cpp/homebrew/libpulsar.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-class Libpulsar < Formula
-  desc "Apache Pulsar C++ library"
-  homepage "https://pulsar.apache.org";
-
-  head "https://github.com/apache/pulsar.git";
-
-  version "2.2.1"
-  url 
"https://www.apache.org/dyn/mirrors/mirrors.cgi?action=download&filename=pulsar/pulsar-#{version}/apache-pulsar-#{version}-src.tar.gz";
-  sha256 "3a365368f0d7beba091ba3a6d0f703dcc77545c8b454e5e33b72c1a29905232e"
-
-  option "with-python3", "Use Boost with Python-3.x"
-  option "with-log4cxx", "Enable Log4cxx logger"
-
-  depends_on "pkg-config" => :build
-  depends_on "cmake" => :build
-  depends_on "openssl" => :build
-  depends_on "boost" => :build
-  depends_on "jsoncpp" => :build
-  depends_on "[email protected]" => :build
-
-  if build.with? "python3"
-      depends_on "boost-python3" => :build
-  else
-      depends_on "python@2" => :build
-      depends_on "boost-python" => :build
-  end
-
-  if build.with? "log4cxx"
-      depends_on "log4cxx" => :build
-  end
-
-  def install
-    Dir.chdir('pulsar-client-cpp')
-
-    if build.with? "python3"
-        python_include_dir = 
'/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m'
-    else
-        python_include_dir = 
'/usr/local/Frameworks/Python.framework/Versions/2.7/include/python2.7/'
-    end
-
-    if build.with? "log4cxx"
-      system "cmake", ".", "-DBUILD_TESTS=OFF", "-DLINK_STATIC=ON", 
"-DUSE_LOG4CXX", "-DPYTHON_INCLUDE_DIR=" + python_include_dir
-    else
-      system "cmake", ".", "-DBUILD_TESTS=OFF", "-DLINK_STATIC=ON", 
"-DPYTHON_INCLUDE_DIR=" + python_include_dir
-    end
-    system "make", "pulsarShared", "pulsarStatic"
-
-    include.install "include/pulsar"
-    lib.install "lib/libpulsar.#{version}.dylib"
-    lib.install "lib/libpulsar.dylib"
-    lib.install "lib/libpulsar.a"
-  end
-end
diff --git a/pulsar-client-cpp/include/pulsar/c/client_configuration.h 
b/pulsar-client-cpp/include/pulsar/c/client_configuration.h
index 0c9fbb8d2e7..3bf94322641 100644
--- a/pulsar-client-cpp/include/pulsar/c/client_configuration.h
+++ b/pulsar-client-cpp/include/pulsar/c/client_configuration.h
@@ -25,7 +25,13 @@
 extern "C" {
 #endif
 
-typedef enum { pulsar_DEBUG = 0, pulsar_INFO = 1, pulsar_WARN = 2, 
pulsar_ERROR = 3 } pulsar_logger_level_t;
+typedef enum
+{
+    pulsar_DEBUG = 0,
+    pulsar_INFO = 1,
+    pulsar_WARN = 2,
+    pulsar_ERROR = 3
+} pulsar_logger_level_t;
 
 typedef void (*pulsar_logger)(pulsar_logger_level_t level, const char *file, 
int line, const char *message,
                               void *ctx);
diff --git a/pulsar-client-cpp/include/pulsar/c/consumer_configuration.h 
b/pulsar-client-cpp/include/pulsar/c/consumer_configuration.h
index a11e11e480f..b3433cfddfd 100644
--- a/pulsar-client-cpp/include/pulsar/c/consumer_configuration.h
+++ b/pulsar-client-cpp/include/pulsar/c/consumer_configuration.h
@@ -28,7 +28,8 @@ extern "C" {
 
 typedef struct _pulsar_consumer_configuration pulsar_consumer_configuration_t;
 
-typedef enum {
+typedef enum
+{
     /**
      * There can be only 1 consumer on the same topic with the same 
consumerName
      */
@@ -52,7 +53,8 @@ typedef enum {
     pulsar_ConsumerKeyShared
 } pulsar_consumer_type;
 
-typedef enum {
+typedef enum
+{
     /**
      * the latest position which means the start consuming position will be 
the last message
      */
@@ -63,7 +65,8 @@ typedef enum {
     initial_position_earliest
 } initial_position;
 
-typedef enum {
+typedef enum
+{
     // This is the default option to fail consume until crypto succeeds
     pulsar_ConsumerFail,
     // Message is silently acknowledged and not delivered to the application
diff --git a/pulsar-client-cpp/include/pulsar/c/producer_configuration.h 
b/pulsar-client-cpp/include/pulsar/c/producer_configuration.h
index cf62baafe1f..0501bfe2838 100644
--- a/pulsar-client-cpp/include/pulsar/c/producer_configuration.h
+++ b/pulsar-client-cpp/include/pulsar/c/producer_configuration.h
@@ -28,15 +28,22 @@
 extern "C" {
 #endif
 
-typedef enum {
+typedef enum
+{
     pulsar_UseSinglePartition,
     pulsar_RoundRobinDistribution,
     pulsar_CustomPartition
 } pulsar_partitions_routing_mode;
 
-typedef enum { pulsar_Murmur3_32Hash, pulsar_BoostHash, pulsar_JavaStringHash 
} pulsar_hashing_scheme;
+typedef enum
+{
+    pulsar_Murmur3_32Hash,
+    pulsar_BoostHash,
+    pulsar_JavaStringHash
+} pulsar_hashing_scheme;
 
-typedef enum {
+typedef enum
+{
     pulsar_CompressionNone = 0,
     pulsar_CompressionLZ4 = 1,
     pulsar_CompressionZLib = 2,
@@ -44,7 +51,8 @@ typedef enum {
     pulsar_CompressionSNAPPY = 4
 } pulsar_compression_type;
 
-typedef enum {
+typedef enum
+{
     pulsar_None = 0,
     pulsar_String = 1,
     pulsar_Json = 2,
@@ -63,7 +71,8 @@ typedef enum {
     pulsar_AutoPublish = -4,
 } pulsar_schema_type;
 
-typedef enum {
+typedef enum
+{
     // This is the default option to fail send if crypto operation fails
     pulsar_ProducerFail,
     // Ignore crypto failure and proceed with sending unencrypted messages
diff --git a/pulsar-client-cpp/include/pulsar/c/result.h 
b/pulsar-client-cpp/include/pulsar/c/result.h
index 22cdb4c0f3d..ea9321cfd84 100644
--- a/pulsar-client-cpp/include/pulsar/c/result.h
+++ b/pulsar-client-cpp/include/pulsar/c/result.h
@@ -25,7 +25,8 @@
 extern "C" {
 #endif
 
-typedef enum {
+typedef enum
+{
     pulsar_result_Ok,  /// Operation successful
 
     pulsar_result_UnknownError,  /// Unknown error happened on broker
diff --git a/pulsar-client-cpp/lib/CMakeLists.txt 
b/pulsar-client-cpp/lib/CMakeLists.txt
index 39156f93f29..f3f4f79bb45 100644
--- a/pulsar-client-cpp/lib/CMakeLists.txt
+++ b/pulsar-client-cpp/lib/CMakeLists.txt
@@ -19,7 +19,7 @@
 
 file(GLOB PULSAR_SOURCES *.cc *.h lz4/*.cc lz4/*.h checksum/*.cc checksum/*.h 
stats/*.cc stats/*.h c/*.cc c/*.h auth/*.cc auth/*.h auth/athenz/*.cc 
auth/athenz/*.h)
 
-execute_process(COMMAND python 
${CMAKE_SOURCE_DIR}/../src/get-project-version.py 
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PV)
+execute_process(COMMAND ${CMAKE_SOURCE_DIR}/../src/get-project-version.py 
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE PV)
 set (CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} 
-D_PULSAR_VERSION_INTERNAL_=\\\"${PV}\\\"")
 
 if (NOT PROTOC_PATH)
diff --git a/pulsar-client-cpp/lib/LogUtils.cc 
b/pulsar-client-cpp/lib/LogUtils.cc
index 7967fbe7545..31746087b92 100644
--- a/pulsar-client-cpp/lib/LogUtils.cc
+++ b/pulsar-client-cpp/lib/LogUtils.cc
@@ -27,7 +27,7 @@
 namespace pulsar {
 
 void LogUtils::init(const std::string& logfilePath) {
-// If this is called explicitely, we fallback to Log4cxx config, if enabled
+    // If this is called explicitely, we fallback to Log4cxx config, if enabled
 
 #ifdef USE_LOG4CXX
     if (!logfilePath.empty()) {
diff --git a/pulsar-client-cpp/lib/checksum/crc32c_arm.h 
b/pulsar-client-cpp/lib/checksum/crc32c_arm.h
index 4848fc04c18..86221528839 100644
--- a/pulsar-client-cpp/lib/checksum/crc32c_arm.h
+++ b/pulsar-client-cpp/lib/checksum/crc32c_arm.h
@@ -37,11 +37,11 @@
 #define crc32c_u16(crc, v) __crc32ch(crc, v)
 #define crc32c_u32(crc, v) __crc32cw(crc, v)
 #define crc32c_u64(crc, v) __crc32cd(crc, v)
-#define PREF4X64L1(buffer, PREF_OFFSET, ITR)                                   
                           \
-    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [c] 
"I"((PREF_OFFSET) + ((ITR) + 0) * 64)); \
-    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [c] 
"I"((PREF_OFFSET) + ((ITR) + 1) * 64)); \
-    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [c] 
"I"((PREF_OFFSET) + ((ITR) + 2) * 64)); \
-    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [c] 
"I"((PREF_OFFSET) + ((ITR) + 3) * 64));
+#define PREF4X64L1(buffer, PREF_OFFSET, ITR)                                   
                             \
+    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [ c ] 
"I"((PREF_OFFSET) + ((ITR) + 0) * 64)); \
+    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [ c ] 
"I"((PREF_OFFSET) + ((ITR) + 1) * 64)); \
+    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [ c ] 
"I"((PREF_OFFSET) + ((ITR) + 2) * 64)); \
+    __asm__("PRFM PLDL1KEEP, [%x[v],%[c]]" ::[v] "r"(buffer), [ c ] 
"I"((PREF_OFFSET) + ((ITR) + 3) * 64));
 
 #define PREF1KL1(buffer, PREF_OFFSET)    \
     PREF4X64L1(buffer, (PREF_OFFSET), 0) \
diff --git a/pulsar-client-cpp/lib/lz4/lz4.cc b/pulsar-client-cpp/lib/lz4/lz4.cc
index 0baa5751bc1..d63b977ac89 100644
--- a/pulsar-client-cpp/lib/lz4/lz4.cc
+++ b/pulsar-client-cpp/lib/lz4/lz4.cc
@@ -366,14 +366,40 @@ typedef struct {
     U32 dictSize;
 } LZ4_stream_t_internal;
 
-typedef enum { notLimited = 0, limitedOutput = 1 } limitedOutput_directive;
-typedef enum { byPtr, byU32, byU16 } tableType_t;
-
-typedef enum { noDict = 0, withPrefix64k, usingExtDict } dict_directive;
-typedef enum { noDictIssue = 0, dictSmall } dictIssue_directive;
-
-typedef enum { endOnOutputSize = 0, endOnInputSize = 1 } 
endCondition_directive;
-typedef enum { full = 0, partial = 1 } earlyEnd_directive;
+typedef enum
+{
+    notLimited = 0,
+    limitedOutput = 1
+} limitedOutput_directive;
+typedef enum
+{
+    byPtr,
+    byU32,
+    byU16
+} tableType_t;
+
+typedef enum
+{
+    noDict = 0,
+    withPrefix64k,
+    usingExtDict
+} dict_directive;
+typedef enum
+{
+    noDictIssue = 0,
+    dictSmall
+} dictIssue_directive;
+
+typedef enum
+{
+    endOnOutputSize = 0,
+    endOnInputSize = 1
+} endCondition_directive;
+typedef enum
+{
+    full = 0,
+    partial = 1
+} earlyEnd_directive;
 
 /**************************************
  *  Local Utils
diff --git a/pulsar-client-cpp/lib/lz4/lz4.h b/pulsar-client-cpp/lib/lz4/lz4.h
index 04f144c8f2a..e5fb5a4784b 100644
--- a/pulsar-client-cpp/lib/lz4/lz4.h
+++ b/pulsar-client-cpp/lib/lz4/lz4.h
@@ -402,4 +402,4 @@ int LZ4_decompress_safe_withPrefix64k(const char *src, char 
*dst, int compressed
 LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead")
 
 int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst, int 
originalSize);
-}
\ No newline at end of file
+}  // namespace pulsar
\ No newline at end of file
diff --git a/pulsar-client-cpp/python/CMakeLists.txt 
b/pulsar-client-cpp/python/CMakeLists.txt
index ee4a6b2b032..a9dbfe8d8e9 100644
--- a/pulsar-client-cpp/python/CMakeLists.txt
+++ b/pulsar-client-cpp/python/CMakeLists.txt
@@ -44,10 +44,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
 endif()
 
 # Newer boost versions don't use the -mt suffix
-if (NOT DEFINED ${Boost_PYTHON27-MT_LIBRARY})
-  set(Boost_PYTHON27-MT_LIBRARY ${Boost_PYTHON27_LIBRARY})
-endif()
-
 if (NOT DEFINED ${Boost_PYTHON37-MT_LIBRARY})
   set(Boost_PYTHON37-MT_LIBRARY ${Boost_PYTHON37_LIBRARY})
 endif()
@@ -67,20 +63,13 @@ endif()
 # Try all possible boost-python variable namings
 set(PYTHON_WRAPPER_LIBS ${Boost_PYTHON_LIBRARY}
                         ${Boost_PYTHON3_LIBRARY}
-                        ${Boost_PYTHON27-MT_LIBRARY}
                         ${Boost_PYTHON37-MT_LIBRARY}
-                        ${Boost_PYTHON34_LIBRARY}
-                        ${Boost_PYTHON35_LIBRARY}
-                        ${Boost_PYTHON36_LIBRARY}
                         ${Boost_PYTHON38_LIBRARY}
                         ${Boost_PYTHON39_LIBRARY}
                         ${Boost_PYTHON310_LIBRARY}
     )
 
 if (APPLE)
-    if (Boost_PYTHON27-MT_LIBRARY_RELEASE)
-        set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} 
${Boost_PYTHON27-MT_LIBRARY_RELEASE})
-    endif ()
     if (Boost_PYTHON37-MT_LIBRARY_RELEASE)
         set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} 
${Boost_PYTHON37-MT_LIBRARY_RELEASE})
     endif ()
diff --git a/pulsar-client-cpp/python/custom_logger_test.py 
b/pulsar-client-cpp/python/custom_logger_test.py
old mode 100644
new mode 100755
index de0600cc1f1..60f331592e3
--- a/pulsar-client-cpp/python/custom_logger_test.py
+++ b/pulsar-client-cpp/python/custom_logger_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
@@ -50,5 +50,5 @@ class CustomLoggingTest(TestCase):
         client.close()
 
 if __name__ == '__main__':
-    logging.basicConfig(encoding='utf-8', level=logging.DEBUG)
+    logging.basicConfig(level=logging.DEBUG)
     main()
diff --git a/pulsar-client-cpp/python/examples/rpc_client.py 
b/pulsar-client-cpp/python/examples/rpc_client.py
index 048e50a4687..fceac5480f4 100755
--- a/pulsar-client-cpp/python/examples/rpc_client.py
+++ b/pulsar-client-cpp/python/examples/rpc_client.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/examples/rpc_server.py 
b/pulsar-client-cpp/python/examples/rpc_server.py
index 3e4e83ab9b6..d5c445f929b 100755
--- a/pulsar-client-cpp/python/examples/rpc_server.py
+++ b/pulsar-client-cpp/python/examples/rpc_server.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh 
b/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh
index a3edb497978..54edac43858 100644
--- a/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh
+++ b/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh
@@ -35,28 +35,6 @@ cd pulsar/pulsar-client-cpp
 brew link --force boost
 brew link --force protobuf260 || true ## Older images have protobuf 2.6.0 and 
not linked
 
-# Python 2
-brew unlink python
-brew unlink boost-python3
-brew link --force python@2
-brew link --force boost-python
-
-cmake . -DBUILD_TESTS=OFF \
-               -DLINK_STATIC=ON  \
-               
-DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib
-make _pulsar -j8
-pushd python
-python2 setup.py bdist_wheel
-popd
-
-#### Python 3
-brew unlink python@2
-brew unlink boost-python
-brew link --force python
-brew link --force boost-python3
-
-make clean
-rm CMakeCache.txt
 cmake . -DBUILD_TESTS=OFF \
                -DLINK_STATIC=ON  \
                
-DPYTHON_LIBRARY=/usr/local/Frameworks/Python.framework/Versions/3.7/lib/libpython3.7.dylib
 \
diff --git a/pulsar-client-cpp/python/pulsar/__init__.py 
b/pulsar-client-cpp/python/pulsar/__init__.py
index 31ddad5274d..3721e62df2e 100644
--- a/pulsar-client-cpp/python/pulsar/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/__init__.py
@@ -21,7 +21,7 @@
 The Pulsar Python client library is based on the existing C++ client library.
 All the same features are exposed through the Python interface.
 
-Currently, the supported Python versions are 2.7, 3.5, 3.6, 3.7 and 3.8.
+Currently, the supported Python versions are 3.7, 3.8, 3.9 and 3.10.
 
 ## Install from PyPI
 
diff --git a/pulsar-client-cpp/python/pulsar/functions/__init__.py 
b/pulsar-client-cpp/python/pulsar/functions/__init__.py
index b14a93244ff..47c179a51ed 100644
--- a/pulsar-client-cpp/python/pulsar/functions/__init__.py
+++ b/pulsar-client-cpp/python/pulsar/functions/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/pulsar/functions/context.py 
b/pulsar-client-cpp/python/pulsar/functions/context.py
index fa9647913cb..c1f6801c722 100644
--- a/pulsar-client-cpp/python/pulsar/functions/context.py
+++ b/pulsar-client-cpp/python/pulsar/functions/context.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/pulsar/functions/function.py 
b/pulsar-client-cpp/python/pulsar/functions/function.py
index dde92b8a55f..ce2919d08ca 100644
--- a/pulsar-client-cpp/python/pulsar/functions/function.py
+++ b/pulsar-client-cpp/python/pulsar/functions/function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/pulsar/functions/serde.py 
b/pulsar-client-cpp/python/pulsar/functions/serde.py
index 968c1c9bc3a..7b07673a770 100644
--- a/pulsar-client-cpp/python/pulsar/functions/serde.py
+++ b/pulsar-client-cpp/python/pulsar/functions/serde.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/pulsar_test.py 
b/pulsar-client-cpp/python/pulsar_test.py
index 0da904fd339..dbdd6be59c7 100755
--- a/pulsar-client-cpp/python/pulsar_test.py
+++ b/pulsar-client-cpp/python/pulsar_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/schema_test.py 
b/pulsar-client-cpp/python/schema_test.py
index 077f2bb0763..c36a55eb0eb 100755
--- a/pulsar-client-cpp/python/schema_test.py
+++ b/pulsar-client-cpp/python/schema_test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/test_consumer.py 
b/pulsar-client-cpp/python/test_consumer.py
index 495dfc0188c..8c2985e6ca2 100755
--- a/pulsar-client-cpp/python/test_consumer.py
+++ b/pulsar-client-cpp/python/test_consumer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/python/test_producer.py 
b/pulsar-client-cpp/python/test_producer.py
index 29e2616b0fb..c3f7eaeb7c0 100755
--- a/pulsar-client-cpp/python/test_producer.py
+++ b/pulsar-client-cpp/python/test_producer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-client-cpp/run-unit-tests.sh 
b/pulsar-client-cpp/run-unit-tests.sh
index f31202cc44a..cd5e28814e6 100755
--- a/pulsar-client-cpp/run-unit-tests.sh
+++ b/pulsar-client-cpp/run-unit-tests.sh
@@ -19,6 +19,7 @@
 #
 
 set -e
+git config --global --add safe.directory /pulsar
 
 ROOT_DIR=$(git rev-parse --show-toplevel)
 cd $ROOT_DIR/pulsar-client-cpp
@@ -44,7 +45,7 @@ if [ -f /gtest-parallel/gtest-parallel ]; then
         tests="--gtest_filter=$1"
         echo "Running tests: $1"
     fi
-    /gtest-parallel/gtest-parallel $tests 
--dump_json_test_results=/tmp/gtest_parallel_results.json \
+    python3 /gtest-parallel/gtest-parallel $tests 
--dump_json_test_results=/tmp/gtest_parallel_results.json \
       --workers=$gtest_workers --retry_failed=$RETRY_FAILED -d /tmp \
       ./main
     RES=$?
@@ -58,18 +59,14 @@ popd
 if [ $RES -eq 0 ]; then
     pushd python
     echo "---- Build Python Wheel file"
-    python setup.py bdist_wheel
+    python3 setup.py bdist_wheel
 
     echo "---- Installing Python Wheel file"
     ls -lha dist
     WHEEL_FILE=$(ls dist/ | grep whl)
     echo "${WHEEL_FILE}"
     echo "dist/${WHEEL_FILE}[all]"
-    # Protobuf 3.18 only works with Python3. Since we're still using Python2 
in CI, 
-    # let's pin the Python version to the previous one
-    pip install protobuf==3.17.3
-
-    pip install dist/${WHEEL_FILE}[all]
+    pip3 install dist/${WHEEL_FILE}[all]
 
     echo "---- Running Python unit tests"
 
@@ -78,14 +75,11 @@ if [ $RES -eq 0 ]; then
     cp *_test.py /tmp
     pushd /tmp
 
-    # TODO: this test requires asyncio module that is supported by Python >= 
3.3.
-    #  Hoeever, CI doesn't support Python3 yet, we should uncomment following
-    #  lines after Python3 CI script is added.
-    #python custom_logger_test.py
-    #RES=$?
-    #echo "custom_logger_test.py: $RES"
+    python3 custom_logger_test.py
+    RES=$?
+    echo "custom_logger_test.py: $RES"
 
-    python pulsar_test.py
+    python3 pulsar_test.py
     RES=$?
     echo "pulsar_test.py: $RES"
 
diff --git a/pulsar-client-cpp/tests/ProducerTest.cc 
b/pulsar-client-cpp/tests/ProducerTest.cc
index 65676f8b6ef..9bf863994a8 100644
--- a/pulsar-client-cpp/tests/ProducerTest.cc
+++ b/pulsar-client-cpp/tests/ProducerTest.cc
@@ -177,8 +177,7 @@ TEST(ProducerTest, testBacklogQuotasExceeded) {
     LOG_INFO("Created topic " << topic << " with 5 partitions");
 
     auto setBacklogPolicy = [&ns](const std::string& policy, int limitSize) {
-        const auto body =
-            R"({"policy":")" + policy + R"(","limitSize":)" + 
std::to_string(limitSize) + "}";
+        const auto body = R"({"policy":")" + policy + R"(","limitSize":)" + 
std::to_string(limitSize) + "}";
         int res = makePostRequest(adminUrl + "admin/v2/namespaces/" + ns + 
"/backlogQuota", body);
         LOG_INFO(res << " | Change the backlog policy to: " << body);
         ASSERT_TRUE(res == 204 || res == 409);
diff --git a/pulsar-client-cpp/tests/PulsarFriend.h 
b/pulsar-client-cpp/tests/PulsarFriend.h
index a12f0581321..bc79fce0c4f 100644
--- a/pulsar-client-cpp/tests/PulsarFriend.h
+++ b/pulsar-client-cpp/tests/PulsarFriend.h
@@ -86,7 +86,7 @@ class PulsarFriend {
 
     static ReaderImplWeakPtr getReaderImplWeakPtr(Reader reader) { return 
reader.impl_; }
 
-    static decltype(ConsumerImpl::chunkedMessageCache_) & 
getChunkedMessageCache(Consumer consumer) {
+    static decltype(ConsumerImpl::chunkedMessageCache_)& 
getChunkedMessageCache(Consumer consumer) {
         auto consumerImpl = getConsumerImplPtr(consumer);
         ConsumerImpl::Lock lock(consumerImpl->chunkProcessMutex_);
         return consumerImpl->chunkedMessageCache_;
diff --git a/pulsar-client-cpp/wireshark/pulsarDissector.cc 
b/pulsar-client-cpp/wireshark/pulsarDissector.cc
index 1e9ea608d4b..9ff311e2e68 100644
--- a/pulsar-client-cpp/wireshark/pulsarDissector.cc
+++ b/pulsar-client-cpp/wireshark/pulsarDissector.cc
@@ -296,7 +296,7 @@ static void dissect_message_metadata(proto_tree* 
frame_tree, tvbuff_t* tvb, int
 #endif
 
     if (offset + metadataSize > maxOffset) {
-    // Not enough data to dissect metadata
+        // Not enough data to dissect metadata
 #ifdef DEBUG
         proto_tree_add_debug_text(frame_tree, "[DEBUG] Not enough data to 
dissect message metadata");
 #endif
@@ -488,7 +488,7 @@ static int dissect_pulsar_message(tvbuff_t* tvb, 
packet_info* pinfo, proto_tree*
     offset += 4;
 
     if (offset + cmdSize > maxOffset) {
-    // Not enough data to dissect
+        // Not enough data to dissect
 #ifdef DEBUG
         proto_tree_add_debug_text(tree, "[Debug] Not enough data to dissect 
command");
 #endif
diff --git a/pulsar-functions/instance/src/main/python/__init__.py 
b/pulsar-functions/instance/src/main/python/__init__.py
old mode 100644
new mode 100755
index d70b15fbd16..62cfb0625e0
--- a/pulsar-functions/instance/src/main/python/__init__.py
+++ b/pulsar-functions/instance/src/main/python/__init__.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/contextimpl.py 
b/pulsar-functions/instance/src/main/python/contextimpl.py
old mode 100644
new mode 100755
index 27618626cf7..84a7d898395
--- a/pulsar-functions/instance/src/main/python/contextimpl.py
+++ b/pulsar-functions/instance/src/main/python/contextimpl.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/log.py 
b/pulsar-functions/instance/src/main/python/log.py
index 5dfee700bba..fcf1bdc95a8 100644
--- a/pulsar-functions/instance/src/main/python/log.py
+++ b/pulsar-functions/instance/src/main/python/log.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/python_instance.py 
b/pulsar-functions/instance/src/main/python/python_instance.py
old mode 100644
new mode 100755
index 54e4a347c05..1a04029ed81
--- a/pulsar-functions/instance/src/main/python/python_instance.py
+++ b/pulsar-functions/instance/src/main/python/python_instance.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/python_instance_main.py 
b/pulsar-functions/instance/src/main/python/python_instance_main.py
old mode 100644
new mode 100755
index 627013489ab..5817e5958e6
--- a/pulsar-functions/instance/src/main/python/python_instance_main.py
+++ b/pulsar-functions/instance/src/main/python/python_instance_main.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/secretsprovider.py 
b/pulsar-functions/instance/src/main/python/secretsprovider.py
index db8e68c094f..c31058d711c 100644
--- a/pulsar-functions/instance/src/main/python/secretsprovider.py
+++ b/pulsar-functions/instance/src/main/python/secretsprovider.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/server.py 
b/pulsar-functions/instance/src/main/python/server.py
index 58d43d204d4..2a9ea2cf01f 100644
--- a/pulsar-functions/instance/src/main/python/server.py
+++ b/pulsar-functions/instance/src/main/python/server.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/state_context.py 
b/pulsar-functions/instance/src/main/python/state_context.py
old mode 100644
new mode 100755
index 87dcb5369b5..e04574ef4b4
--- a/pulsar-functions/instance/src/main/python/state_context.py
+++ b/pulsar-functions/instance/src/main/python/state_context.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/main/python/util.py 
b/pulsar-functions/instance/src/main/python/util.py
old mode 100644
new mode 100755
index 390aed1b774..782c15c0e8c
--- a/pulsar-functions/instance/src/main/python/util.py
+++ b/pulsar-functions/instance/src/main/python/util.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh 
b/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh
old mode 100644
new mode 100755
index 7005b9bfe88..8f1191cfd80
--- a/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh
+++ b/pulsar-functions/instance/src/scripts/run_python_instance_tests.sh
@@ -20,12 +20,12 @@
 
 
 # Make sure dependencies are installed
-pip install mock --user
-pip install protobuf --user
-pip install fastavro --user
+pip3 install mock --user
+pip3 install protobuf --user
+pip3 install fastavro --user
 
 CUR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
 PULSAR_HOME=$CUR_DIR/../../../../
 
 # run instance tests
-PULSAR_HOME=${PULSAR_HOME} 
PYTHONPATH=${PULSAR_HOME}/pulsar-functions/instance/target/python-instance 
python -m unittest discover -v 
${PULSAR_HOME}/pulsar-functions/instance/target/python-instance/tests
+PULSAR_HOME=${PULSAR_HOME} 
PYTHONPATH=${PULSAR_HOME}/pulsar-functions/instance/target/python-instance 
python3 -m unittest discover -v 
${PULSAR_HOME}/pulsar-functions/instance/target/python-instance/tests
diff --git a/pulsar-functions/python-examples/config_based_append_function.py 
b/pulsar-functions/python-examples/config_based_append_function.py
index 03aa775add7..955d95f2997 100755
--- a/pulsar-functions/python-examples/config_based_append_function.py
+++ b/pulsar-functions/python-examples/config_based_append_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/custom_object_function.py 
b/pulsar-functions/python-examples/custom_object_function.py
index 0da0c92ffd1..8e020b3c9d8 100755
--- a/pulsar-functions/python-examples/custom_object_function.py
+++ b/pulsar-functions/python-examples/custom_object_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/exclamation_function.py 
b/pulsar-functions/python-examples/exclamation_function.py
index 5df5de55b5d..e63bd4bd7a7 100755
--- a/pulsar-functions/python-examples/exclamation_function.py
+++ b/pulsar-functions/python-examples/exclamation_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/logging_function.py 
b/pulsar-functions/python-examples/logging_function.py
index 54f247389e2..a8cd699fe52 100755
--- a/pulsar-functions/python-examples/logging_function.py
+++ b/pulsar-functions/python-examples/logging_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/native_exclamation_function.py 
b/pulsar-functions/python-examples/native_exclamation_function.py
index 3baac705bd3..7a07a169673 100755
--- a/pulsar-functions/python-examples/native_exclamation_function.py
+++ b/pulsar-functions/python-examples/native_exclamation_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/publish_function.py 
b/pulsar-functions/python-examples/publish_function.py
index e06a61c5582..09735ce705a 100755
--- a/pulsar-functions/python-examples/publish_function.py
+++ b/pulsar-functions/python-examples/publish_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/thumbnailer.py 
b/pulsar-functions/python-examples/thumbnailer.py
index 3448aac0ee8..0001c161c24 100755
--- a/pulsar-functions/python-examples/thumbnailer.py
+++ b/pulsar-functions/python-examples/thumbnailer.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/typed_message_builder_publish.py 
b/pulsar-functions/python-examples/typed_message_builder_publish.py
index c6697a716d0..896c145572e 100644
--- a/pulsar-functions/python-examples/typed_message_builder_publish.py
+++ b/pulsar-functions/python-examples/typed_message_builder_publish.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/user_exception.py 
b/pulsar-functions/python-examples/user_exception.py
index 0eaea93781e..de3e4b4a506 100644
--- a/pulsar-functions/python-examples/user_exception.py
+++ b/pulsar-functions/python-examples/user_exception.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/void_function.py 
b/pulsar-functions/python-examples/void_function.py
index afa44df820c..6f281349b99 100755
--- a/pulsar-functions/python-examples/void_function.py
+++ b/pulsar-functions/python-examples/void_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/pulsar-functions/python-examples/wordcount_function.py 
b/pulsar-functions/python-examples/wordcount_function.py
index 22cf4d76290..7fbeeb157a5 100644
--- a/pulsar-functions/python-examples/wordcount_function.py
+++ b/pulsar-functions/python-examples/wordcount_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git 
a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
 
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
index 332dc439f20..1fb7650b1e8 100644
--- 
a/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
+++ 
b/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
@@ -340,7 +340,7 @@ public class RuntimeUtils {
             args.add("--jar");
             args.add(originalCodeFileName);
         } else if (instanceConfig.getFunctionDetails().getRuntime() == 
Function.FunctionDetails.Runtime.PYTHON) {
-            args.add("python");
+            args.add("python3");
             if 
(!isEmpty(instanceConfig.getFunctionDetails().getRuntimeFlags())) {
                 for (String runtimeFlagArg : 
splitRuntimeArgs(instanceConfig.getFunctionDetails().getRuntimeFlags())) {
                     args.add(runtimeFlagArg);
diff --git 
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
 
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
index 18e3d9954aa..8a35c0e9b40 100644
--- 
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
+++ 
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/kubernetes/KubernetesRuntimeTest.java
@@ -505,7 +505,7 @@ public class KubernetesRuntimeTest {
 
         assertEquals(args.size(), totalArgs,
                 "Actual args : " + StringUtils.join(args, " "));
-        String expectedArgs = pythonPath + "exec python " + pythonInstanceFile
+        String expectedArgs = pythonPath + "exec python3 " + pythonInstanceFile
                 + " --py " + pulsarRootDir + "/" + userJarFile
                 + " --logging_directory " + logDirectory
                 + " --logging_file " + config.getFunctionDetails().getName()
diff --git 
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/process/ProcessRuntimeTest.java
 
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/process/ProcessRuntimeTest.java
index 955f2bb5399..8ae3350fb49 100644
--- 
a/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/process/ProcessRuntimeTest.java
+++ 
b/pulsar-functions/runtime/src/test/java/org/apache/pulsar/functions/runtime/process/ProcessRuntimeTest.java
@@ -366,7 +366,7 @@ public class ProcessRuntimeTest {
         int configArg = 9;
 
         assertEquals(args.size(), totalArgs);
-        String expectedArgs = pythonPath + "python " + pythonInstanceFile
+        String expectedArgs = pythonPath + "python3 " + pythonInstanceFile
                 + " --py " + userJarFile + " --logging_directory "
                 + logDirectory + "/functions" + " --logging_file " + 
config.getFunctionDetails().getName()
                 + " --logging_config_file " + args.get(configArg) + " 
--instance_id "
diff --git a/pulsar-functions/scripts/python/generate.sh 
b/pulsar-functions/scripts/python/generate.sh
old mode 100644
new mode 100755
index 776f48cbd5e..a3ee121240a
--- a/pulsar-functions/scripts/python/generate.sh
+++ b/pulsar-functions/scripts/python/generate.sh
@@ -29,10 +29,10 @@ echo 
"__import__(\'pkg_resources\').declare_namespace(__name__)" > $PF_DIR/pulsa
 sed "s/VERSION/$VERSION/" setup.py.template > $PF_DIR/setup.py
 cp requirements.txt $PF_DIR
 cd $PF_DIR
-/usr/bin/env python2.7 setup.py sdist
-/usr/bin/env python2.7 setup.py bdist_wheel
+/usr/bin/env python3 setup.py sdist
+/usr/bin/env python3 setup.py bdist_wheel
 mkdir -p $OUTPUT_DIR
-cp $PF_DIR/dist/pulsarfunction-*-py2-*.whl $OUTPUT_DIR
+cp $PF_DIR/dist/pulsarfunction-*-py*-*.whl $OUTPUT_DIR
 cp $PF_DIR/dist/pulsarfunction-*.tar.gz $OUTPUT_DIR
 touch $OUTPUT_DIR/pulsarfunction.whl
 rm -rf $TMP_DIR
diff --git a/site2/docs/client-libraries-python.md 
b/site2/docs/client-libraries-python.md
index 8bd098259e2..245fc70b38a 100644
--- a/site2/docs/client-libraries-python.md
+++ b/site2/docs/client-libraries-python.md
@@ -40,8 +40,9 @@ Installation via PyPi is available for the following Python 
versions:
 
 Platform | Supported Python versions
 :--------|:-------------------------
-MacOS <br />  10.13 (High Sierra), 10.14 (Mojave) <br /> | 2.7, 3.7, 3.8, 3.9
-Linux | 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9
+MacOS >= 11.0 | 3.7, 3.8, 3.9 and 3.10
+Linux (including Alpine Linux) | 3.7, 3.8, 3.9 and 3.10
+
 
 ### Install from source
 
diff --git a/src/gen-pulsar-version-macro.py b/src/gen-pulsar-version-macro.py
index f32df91772f..85fb637d670 100755
--- a/src/gen-pulsar-version-macro.py
+++ b/src/gen-pulsar-version-macro.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/src/get-project-version.py b/src/get-project-version.py
index 631cd68f02a..d0fec36a7ce 100755
--- a/src/get-project-version.py
+++ b/src/get-project-version.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git a/src/set-project-version.sh b/src/set-project-version.sh
index 924cc2a450a..cf67e37682f 100755
--- a/src/set-project-version.sh
+++ b/src/set-project-version.sh
@@ -34,7 +34,7 @@ TERRAFORM_DIR=${ROOT_DIR}/deployment/terraform-ansible
 pushd ${ROOT_DIR}
 
 # Get the current version
-OLD_VERSION=`python ${ROOT_DIR}/src/get-project-version.py`
+OLD_VERSION=`python3 ${ROOT_DIR}/src/get-project-version.py`
 
 mvn versions:set -DnewVersion=$NEW_VERSION
 mvn versions:set -DnewVersion=$NEW_VERSION -pl buildtools
diff --git 
a/tests/docker-images/latest-version-image/python-examples/consumer_schema.py 
b/tests/docker-images/latest-version-image/python-examples/consumer_schema.py
index 64efcbecead..0cd59ddacd5 100755
--- 
a/tests/docker-images/latest-version-image/python-examples/consumer_schema.py
+++ 
b/tests/docker-images/latest-version-image/python-examples/consumer_schema.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git 
a/tests/docker-images/latest-version-image/python-examples/exception_function.py
 
b/tests/docker-images/latest-version-image/python-examples/exception_function.py
old mode 100644
new mode 100755
index b14f3897500..b2e09083bfa
--- 
a/tests/docker-images/latest-version-image/python-examples/exception_function.py
+++ 
b/tests/docker-images/latest-version-image/python-examples/exception_function.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git 
a/tests/docker-images/latest-version-image/python-examples/exclamation_lib.py 
b/tests/docker-images/latest-version-image/python-examples/exclamation_lib.py
old mode 100644
new mode 100755
index eefda34a6a2..4e129f460a2
--- 
a/tests/docker-images/latest-version-image/python-examples/exclamation_lib.py
+++ 
b/tests/docker-images/latest-version-image/python-examples/exclamation_lib.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git 
a/tests/docker-images/latest-version-image/python-examples/exclamation_with_extra_deps.py
 
b/tests/docker-images/latest-version-image/python-examples/exclamation_with_extra_deps.py
old mode 100644
new mode 100755
index f45d571ccc2..b32f0a17640
--- 
a/tests/docker-images/latest-version-image/python-examples/exclamation_with_extra_deps.py
+++ 
b/tests/docker-images/latest-version-image/python-examples/exclamation_with_extra_deps.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file
diff --git 
a/tests/docker-images/latest-version-image/python-examples/producer_schema.py 
b/tests/docker-images/latest-version-image/python-examples/producer_schema.py
index bc85686e84f..d93078c3d32 100755
--- 
a/tests/docker-images/latest-version-image/python-examples/producer_schema.py
+++ 
b/tests/docker-images/latest-version-image/python-examples/producer_schema.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 #
 # Licensed to the Apache Software Foundation (ASF) under one
 # or more contributor license agreements.  See the NOTICE file

Reply via email to