Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions pulsar-client-cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
3 changes: 0 additions & 3 deletions pulsar-client-cpp/docker/build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 1 addition & 5 deletions pulsar-client-cpp/homebrew/libpulsar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 5 additions & 6 deletions pulsar-client-cpp/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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})
Expand All @@ -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})

Expand Down
14 changes: 0 additions & 14 deletions pulsar-client-cpp/python/pkg/osx/vagrant-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pulsar-functions/scripts/python/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion site2/docs/functions-develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down