From bdbf498f6c16e87499633ae7111a704c859ccbac Mon Sep 17 00:00:00 2001 From: nsalwan Date: Thu, 14 Jan 2021 15:52:54 -0600 Subject: [PATCH 1/4] Fix for Issue 8622 --- pulsar-client-cpp/docker/build-wheels.sh | 3 --- pulsar-client-cpp/python/CMakeLists.txt | 11 +++++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pulsar-client-cpp/docker/build-wheels.sh b/pulsar-client-cpp/docker/build-wheels.sh index 84e550f021b0a..40f56da243ade 100755 --- a/pulsar-client-cpp/docker/build-wheels.sh +++ b/pulsar-client-cpp/docker/build-wheels.sh @@ -27,9 +27,6 @@ ROOT_DIR=$(git rev-parse --show-toplevel) cd $ROOT_DIR PYTHON_VERSIONS=( - '2.7 cp27-cp27mu' - '2.7 cp27-cp27m' - '3.5 cp35-cp35m' '3.6 cp36-cp36m' '3.7 cp37-cp37m' '3.8 cp38-cp38' diff --git a/pulsar-client-cpp/python/CMakeLists.txt b/pulsar-client-cpp/python/CMakeLists.txt index 70b5bc130ae74..f62ca0db64256 100644 --- a/pulsar-client-cpp/python/CMakeLists.txt +++ b/pulsar-client-cpp/python/CMakeLists.txt @@ -27,7 +27,7 @@ SET(CMAKE_SHARED_LIBRARY_PREFIX ) SET(CMAKE_SHARED_LIBRARY_SUFFIX .so) -if (NOT APPLE AND NOT MSVC) +if (CMAKE_CXX_FLAGS_PYTHON) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_PYTHON}") endif() @@ -36,8 +36,8 @@ 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}) +if (NOT DEFINED ${Boost_PYTHON36-MT_LIBRARY}) + set(Boost_PYTHON36-MT_LIBRARY ${Boost_PYTHON36_LIBRARY}) endif() if (NOT DEFINED ${Boost_PYTHON37-MT_LIBRARY}) @@ -50,13 +50,12 @@ 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_PYTHON37-MT_LIBRARY} ${Boost_PYTHON36_LIBRARY} ${Boost_PYTHON38_LIBRARY}) if (APPLE) set(PYTHON_WRAPPER_LIBS ${PYTHON_WRAPPER_LIBS} - ${Boost_PYTHON27-MT_LIBRARY_RELEASE} + ${Boost_PYTHON36-MT_LIBRARY_RELEASE} ${Boost_PYTHON37-MT_LIBRARY_RELEASE} ${Boost_PYTHON38-MT_LIBRARY_RELEASE}) From 954fcd5e49a5dc332e0681f9c787b4cebc8fb832 Mon Sep 17 00:00:00 2001 From: nsalwan Date: Thu, 14 Jan 2021 16:03:50 -0600 Subject: [PATCH 2/4] sample test --- pulsar-client-cpp/python/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/pulsar-client-cpp/python/CMakeLists.txt b/pulsar-client-cpp/python/CMakeLists.txt index f62ca0db64256..ec6b5ca55df47 100644 --- a/pulsar-client-cpp/python/CMakeLists.txt +++ b/pulsar-client-cpp/python/CMakeLists.txt @@ -75,6 +75,7 @@ if (NOT PYTHON_WRAPPER_LIBS) MESSAGE(FATAL_ERROR "Could not find Boost Python library") endif () + if (APPLE) set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") target_link_libraries(_pulsar -Wl,-all_load pulsarStatic ${PYTHON_WRAPPER_LIBS} ${COMMON_LIBS} ${ICU_LIBS}) From 5d4fee47819d7fafa2c26ab5fc5c016894169fc7 Mon Sep 17 00:00:00 2001 From: nsalwan Date: Thu, 14 Jan 2021 16:22:59 -0600 Subject: [PATCH 3/4] sample test1 --- pulsar-client-cpp/python/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/pulsar-client-cpp/python/CMakeLists.txt b/pulsar-client-cpp/python/CMakeLists.txt index ec6b5ca55df47..f62ca0db64256 100644 --- a/pulsar-client-cpp/python/CMakeLists.txt +++ b/pulsar-client-cpp/python/CMakeLists.txt @@ -75,7 +75,6 @@ if (NOT PYTHON_WRAPPER_LIBS) MESSAGE(FATAL_ERROR "Could not find Boost Python library") endif () - if (APPLE) set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") target_link_libraries(_pulsar -Wl,-all_load pulsarStatic ${PYTHON_WRAPPER_LIBS} ${COMMON_LIBS} ${ICU_LIBS}) From 459aac6a304ab34771d7d03127f0be781ee6e331 Mon Sep 17 00:00:00 2001 From: nsalwan Date: Mon, 25 Jan 2021 13:52:07 -0600 Subject: [PATCH 4/4] removed more 2.7 related stuff --- pulsar-client-cpp/CMakeLists.txt | 19 +++++++------------ pulsar-client-cpp/homebrew/libpulsar.rb | 6 +----- .../python/pkg/osx/vagrant-build.sh | 14 -------------- pulsar-functions/scripts/python/generate.sh | 4 ++-- site2/docs/functions-develop.md | 2 +- .../version-2.7.1/functions-develop.md | 2 +- 6 files changed, 12 insertions(+), 35 deletions(-) diff --git a/pulsar-client-cpp/CMakeLists.txt b/pulsar-client-cpp/CMakeLists.txt index 4716dd7109bbb..77c7942bf5a85 100644 --- a/pulsar-client-cpp/CMakeLists.txt +++ b/pulsar-client-cpp/CMakeLists.txt @@ -162,18 +162,13 @@ 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;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 () + 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;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}) diff --git a/pulsar-client-cpp/homebrew/libpulsar.rb b/pulsar-client-cpp/homebrew/libpulsar.rb index 1642a79538354..2f75827466502 100644 --- a/pulsar-client-cpp/homebrew/libpulsar.rb +++ b/pulsar-client-cpp/homebrew/libpulsar.rb @@ -51,11 +51,7 @@ class Libpulsar < Formula 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 + python_include_dir = '/usr/local/Frameworks/Python.framework/Versions/3.7/include/python3.7m' if build.with? "log4cxx" system "cmake", ".", "-DBUILD_TESTS=OFF", "-DLINK_STATIC=ON", "-DUSE_LOG4CXX", "-DPYTHON_INCLUDE_DIR=" + python_include_dir diff --git a/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh b/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh index a3edb497978c8..ac71a5eaf679f 100644 --- a/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh +++ b/pulsar-client-cpp/python/pkg/osx/vagrant-build.sh @@ -35,20 +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 diff --git a/pulsar-functions/scripts/python/generate.sh b/pulsar-functions/scripts/python/generate.sh index 776f48cbd5edf..7258c27e32c3c 100644 --- a/pulsar-functions/scripts/python/generate.sh +++ b/pulsar-functions/scripts/python/generate.sh @@ -29,8 +29,8 @@ 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 python setup.py sdist +/usr/bin/env python setup.py bdist_wheel mkdir -p $OUTPUT_DIR cp $PF_DIR/dist/pulsarfunction-*-py2-*.whl $OUTPUT_DIR cp $PF_DIR/dist/pulsarfunction-*.tar.gz $OUTPUT_DIR diff --git a/site2/docs/functions-develop.md b/site2/docs/functions-develop.md index de059b8320bef..1263ef9dda57a 100644 --- a/site2/docs/functions-develop.md +++ b/site2/docs/functions-develop.md @@ -38,7 +38,7 @@ def process(input): For complete code, see [here](https://github.com/apache/pulsar/blob/master/pulsar-functions/python-examples/native_exclamation_function.py). > Note -> You can write Pulsar Functions in python2 or python3. However, Pulsar only looks for `python` as the interpreter. +> You can write Pulsar Functions in python3. However, Pulsar only looks for `python` as the interpreter. > > If you're running Pulsar Functions on an Ubuntu system that only supports python3, you might fail to > start the functions. In this case, you can create a symlink. Your system will fail if diff --git a/site2/website/versioned_docs/version-2.7.1/functions-develop.md b/site2/website/versioned_docs/version-2.7.1/functions-develop.md index 565f1aae87676..ba9a741338315 100644 --- a/site2/website/versioned_docs/version-2.7.1/functions-develop.md +++ b/site2/website/versioned_docs/version-2.7.1/functions-develop.md @@ -39,7 +39,7 @@ def process(input): For complete code, see [here](https://github.com/apache/pulsar/blob/master/pulsar-functions/python-examples/native_exclamation_function.py). > Note -> You can write Pulsar Functions in python2 or python3. However, Pulsar only looks for `python` as the interpreter. +> You can write Pulsar Functions in python3. However, Pulsar only looks for `python` as the interpreter. > > If you're running Pulsar Functions on an Ubuntu system that only supports python3, you might fail to > start the functions. In this case, you can create a symlink. Your system will fail if