You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2018/11/27 13:34:43 UTC

[GitHub] vongosling closed pull request #4: Add package.sh and refactor build method

vongosling closed pull request #4: Add package.sh and refactor build method
URL: https://github.com/apache/rocketmq-client-python/pull/4
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d450797..cc1149d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,10 +16,12 @@
 #*/
 cmake_minimum_required(VERSION 2.6)
 
+set(CMAKE_MACOSX_RPATH 1)
+
 # CMake complains if we don't have this.
 if (COMMAND cmake_policy)
     cmake_policy(SET CMP0003 NEW)
-endif()
+endif ()
 
 # We're escaping quotes in the Windows version number, because
 # for some reason CMake won't do it at config version 2.4.7
@@ -27,14 +29,15 @@ endif()
 # args are not auto-escaped.
 if (COMMAND cmake_policy)
     cmake_policy(SET CMP0005 NEW)
-endif()
+endif ()
 
 # First, declare project (important for prerequisite checks).
 project(rocketmq-client-python)
 
 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
 set(CMAKE_VERBOSE_MAKEFILE 1)
-
+#Path of custom cmake
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 # put binaries in a different dir to make them easier to find.
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
@@ -48,49 +51,49 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
 #     endif()
 # endif()
 
-if(NOT CMAKE_BUILD_TYPE)
-  set(CMAKE_BUILD_TYPE "Release")
-endif()
+if (NOT CMAKE_BUILD_TYPE)
+    set(CMAKE_BUILD_TYPE "Release")
+endif ()
 
 set(CXX_FLAGS
- -g
- -Wall
- -Wno-deprecated
- -fPIC
- -fno-strict-aliasing
- -Wno-unused-result
- # -finline-limit=1000
- # -Wextra
- # -pedantic
- # -pedantic-errors
- # -D_FILE_OFFSET_BITS=64
- # -DVALGRIND
- # -DCHECK_PTHREAD_RETURN_VALUE
- # -Werror
- # -Wconversion
- # -Wno-unused-parameter
- # -Wunused-but-set-variable
- # -Wold-style-cast
- # -Woverloaded-virtual
- # -Wpointer-arith
- # -Wshadow
- # -Wwrite-strings
- # -Wdeprecated-declarations
- # -march=native
- # -MMD
- # -std=c++0x
- # -rdynamic
- )
-
-if(CMAKE_BUILD_BITS EQUAL 32)
-  list(APPEND CXX_FLAGS "-m32")
-else() #not-condition
-  list(APPEND CXX_FLAGS "-m64")
-endif()
+        #-std=c++0x
+        -g
+        -Wall
+        -Wno-deprecated
+        -fPIC
+        -fno-strict-aliasing
+        -Wno-unused-result
+        # -finline-limit=1000
+        # -Wextra
+        # -pedantic
+        # -pedantic-errors
+        # -D_FILE_OFFSET_BITS=64
+        # -DVALGRIND
+        # -DCHECK_PTHREAD_RETURN_VALUE
+        # -Werror
+        # -Wconversion
+        # -Wno-unused-parameter
+        # -Wunused-but-set-variable
+        # -Wold-style-cast
+        # -Woverloaded-virtual
+        # -Wpointer-arith
+        # -Wshadow
+        # -Wwrite-strings
+        # -Wdeprecated-declarations
+        # -march=native
+        # -MMD
+        # -rdynamic
+        )
+
+if (CMAKE_BUILD_BITS EQUAL 32)
+    list(APPEND CXX_FLAGS "-m32")
+else () #not-condition
+    list(APPEND CXX_FLAGS "-m64")
+endif ()
 
 string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")
 # set(CMAKE_CXX_COMPILER "c++")
-set(CMAKE_CXX_FLAGS_DEBUG   "-O0 -DDEBUG")
+set(CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG")
 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
 
 include("cmake/ConfigureChecks.cmake")
@@ -99,55 +102,77 @@ include("cmake/ConfigureChecks.cmake")
 # a more elegant way of doing this; with SCons, when you check for the
 # lib, it is automatically passed to the linker.
 set(deplibs)
-
+#list(APPEND deplibs z)
 # For some reason, the check_function_exists macro doesn't detect
 # the inet_aton on some pure Unix platforms (e.g. sunos5). So we
 # need to do a more detailed check and also include some extra deplibs.
-list(APPEND deplibs nsl)
 
 # pthread is used on both Linux and Mac
 check_library_exists("pthread" pthread_create "" HAVE_PTHREAD)
 if (HAVE_PTHREAD)
     list(APPEND deplibs pthread)
-else()
+else ()
     message(FATAL_ERROR "Missing library: pthread")
-endif()
+endif ()
 
 check_library_exists(dl dlopen "" HAVE_LIBDL)
-if(HAVE_LIBDL)
+if (HAVE_LIBDL)
     list(APPEND deplibs dl)
-else() #not-HAVE_LIBDL
+else () #not-HAVE_LIBDL
     message(FATAL_ERROR "Missing library: dl")
-endif()
-
-
-set(BOOST_INCLUDEDIR /usr/local/include/)
-#set(BOOST_INCLUDEDIR C:/boost_1_56_0/)
-set(Boost_USE_STATIC_LIBS    "only find boost static libs"     OFF) # only find static libs
-set(Boost_USE_MULTITHREADED          ON)
-set(Boost_USE_STATIC_RUNTIME         ON)
-if(WIN32)
-    find_package(Boost 1.53 REQUIRED COMPONENTS python)
-else()
-    #find_package(Boost 1.53 REQUIRED COMPONENTS python)
-    set(Boost_LIBRARIES         "boost_python")
-endif()
-
-#if(Boost_FOUND)
+endif ()
+
+check_library_exists(z compress "" HAVE_LIBZ)
+if (HAVE_LIBZ)
+    list(APPEND deplibs z)
+else () #not-HAVE_LIBDL
+    message(FATAL_ERROR "Missing library: z")
+endif ()
+
+#set(Boost_USE_STATIC_LIBS "only find boost static libs" ON) # only find static libs
+option(Boost_USE_STATIC_LIBS "only find boost static libs" OFF) # only find static libs
+#set(Boost_USE_SHARED_LIBS "only find boost shared libs" ON) # only find shared libs
+
+if (WIN32)
+    find_package(Boost REQUIRED COMPONENTS python)
+elseif (APPLE)
+    find_package(Boost REQUIRED COMPONENTS python27)
+else ()
+    find_package(Boost REQUIRED COMPONENTS python)
+endif (WIN32)
+
+if (Boost_FOUND)
     message(status "** Boost Include dir: ${Boost_INCLUDE_DIR}")
     message(status "** Boost Libraries dir: ${Boost_LIBRARY_DIRS}")
     message(status "** Boost Libraries: ${Boost_LIBRARIES}")
     include_directories(${Boost_INCLUDE_DIRS})
-#endif()
+else ()
+    message(FATAL_ERROR "Missing library: boost_python")
+endif ()
 
 # rocketmq is used on both Linux and Mac
-check_library_exists("rocketmq" CreateMessage "" HAVE_ROCKETMQ)
-if (HAVE_ROCKETMQ)
-    #list(APPEND deplibs rocketmq)
-    message(status "----------------------------------- Find RocketMQ library----------------------------")
-else()
+#check_library_exists("rocketmq" CreateMessage "" HAVE_ROCKETMQ)
+#if (HAVE_ROCKETMQ)
+#    list(APPEND deplibs rocketmq)
+#    message(status "----------------------------------- Find RocketMQ library----------------------------")
+#else ()
+#    message(FATAL_ERROR "Missing library: rocketmq")
+#endif ()
+
+#set(ROCKETMQ_USE_STATIC_LIBS "only find rocketmq static libs" OFF) # only find static libs
+option(ROCKETMQ_USE_STATIC_LIBS "only find rocketmq static libs" ON) # only find static libs
+#set(ROCKETMQ_USE_SHARED_LIBS "only find rocketmq shared libs" ON) # only find shared libs
+
+find_package(rocketmq)
+
+if (ROCKETMQ_FOUND)
+    message(status "** Rocketmq Include dir: ${ROCKETMQ_INCLUDE_DIRS}")
+    message(status "** Rocketmq Libraries dir: ${ROCKETMQ_LIBRARY_DIRS}")
+    message(status "** Rocketmq Libraries: ${ROCKETMQ_LIBRARIES}")
+    include_directories(${ROCKETMQ_INCLUDE_DIRS})
+else ()
     message(FATAL_ERROR "Missing library: rocketmq")
-endif()
+endif ()
 # add include dir for bsd (posix uses /usr/include/)
 set(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH}:/usr/local/include")
 
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake
index fdca98d..c2e0d4a 100644
--- a/cmake/ConfigureChecks.cmake
+++ b/cmake/ConfigureChecks.cmake
@@ -347,8 +347,6 @@ endmacro()
 
 path_to_have(LIBADVAPI32)
 path_to_have(LIBKERNEL32)
-path_to_have(LIBNSL)
-path_to_have(LIBRT)
 path_to_have(LIBPOSIX4)
 path_to_have(LIBCPOSIX)
 path_to_have(LIBSOCKET)
diff --git a/cmake/Findrocketmq.cmake b/cmake/Findrocketmq.cmake
new file mode 100644
index 0000000..2a2824b
--- /dev/null
+++ b/cmake/Findrocketmq.cmake
@@ -0,0 +1,115 @@
+# 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.
+
+# Find RocketMQ Libary
+#
+# Find the rocketmq includes and library
+#
+# if you need to add a custom library search path, do it via CMAKE_PREFIX_PATH
+#
+# -*- cmake -*-
+# - Find Rocketmq
+# Find the Rocketmq includes and library
+# This module defines
+#  ROCKETMQ_INCLUDE_DIRS, where to find CCommon.h, CMessage.h, etc.#include "CCommon.h"
+#  ROCKETMQ_LIBRARIES, the libraries needed to use Rocketmq.
+#  ROCKETMQ_FOUND, If false, do not try to use Rocketmq.
+#  also defined, but not for general use are
+#  ROCKETMQ_LIBRARIES, where to find the rocketmq library.
+
+# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
+if (ROCKETMQ_USE_STATIC_LIBS)
+    set(_rocketmq_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
+    if (WIN32)
+        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
+    else ()
+        set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+    endif ()
+else ()
+    set(_rocketmq_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
+    if (WIN32)
+        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll)
+    elseif (APPLE)
+        set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
+    else ()
+        set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
+    endif (WIN32)
+endif (ROCKETMQ_USE_STATIC_LIBS)
+if (ROCKETMQ_USE_SHARED_LIBS)
+    set(_rocketmq_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES :${CMAKE_FIND_LIBRARY_SUFFIXES})
+    if (WIN32)
+        list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .dll)
+    elseif (APPLE)
+        set(CMAKE_FIND_LIBRARY_SUFFIXES .dylib)
+    else ()
+        set(CMAKE_FIND_LIBRARY_SUFFIXES .so)
+    endif ()
+endif (ROCKETMQ_USE_SHARED_LIBS)
+
+FIND_PATH(ROCKETMQ_INCLUDE_DIRS
+        NAMES
+        CCommon.h
+        PATHS
+        /usr/include
+        /usr/local/include
+        C:/rocketmq/include
+        ${CMAKE_SOURCE_DIR}/win32-deps/include
+        ${ROCKETMQ_LIBRARY_DIRS}
+        PATH_SUFFIXES rocketmq
+        )
+message(status**** "rocketmq include path: ${ROCKETMQ_INCLUDE_DIRS}")
+
+find_library(ROCKETMQ_LIBRARIES
+        NAMES rocketmq
+        PATHS
+        /usr/lib
+        /usr/local/lib
+        C:/rocketmq/lib
+        ${CMAKE_SOURCE_DIR}/win32-deps/lib
+        ${ROCKETMQ_LIBRARY_DIRS}
+        )
+message(status**** "rocketmq libaray: ${ROCKETMQ_LIBRARIES}")
+
+IF (ROCKETMQ_LIBRARIES AND ROCKETMQ_INCLUDE_DIRS)
+    SET(ROCKETMQ_LIBRARIES ${ROCKETMQ_LIBRARIES})
+    SET(ROCKETMQ_FOUND "YES")
+    message(status "Find library: rocketmq")
+ELSE (ROCKETMQ_LIBRARIES AND ROCKETMQ_INCLUDE_DIRS)
+    SET(ROCKETMQ_FOUND "NO")
+    message(FATAL_ERROR "Missing library: rocketmq")
+ENDIF (ROCKETMQ_LIBRARIES AND ROCKETMQ_INCLUDE_DIRS)
+
+
+IF (ROCKETMQ_FOUND)
+    IF (NOT ROCKETMQ_FIND_QUIETLY)
+        MESSAGE(STATUS "Found Rocketmq: ${ROCKETMQ_LIBRARIES}")
+    ENDIF (NOT ROCKETMQ_FIND_QUIETLY)
+ELSE (ROCKETMQ_FOUND)
+    IF (ROCKETMQ_FIND_REQUIRED)
+        MESSAGE(FATAL_ERROR "Could not find ROCKETMQ library include: ${ROCKETMQ_INCLUDE_DIRS}, lib: ${ROCKETMQ_LIBRARIES}")
+    ENDIF (ROCKETMQ_FIND_REQUIRED)
+ENDIF (ROCKETMQ_FOUND)
+
+MARK_AS_ADVANCED(
+        ROCKETMQ_LIBRARIES
+        ROCKETMQ_INCLUDE_DIRS
+)
+
+# Restore the original find library ordering
+if (ROCKETMQ_USE_STATIC_LIBS)
+    set(CMAKE_FIND_LIBRARY_SUFFIXES ${_rocketmq_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+else ()
+    set(CMAKE_FIND_LIBRARY_SUFFIXES ${_rocketmq_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+endif ()
diff --git a/doc/Introduction.md b/doc/Introduction.md
index 8ad2c5f..980269b 100644
--- a/doc/Introduction.md
+++ b/doc/Introduction.md
@@ -16,6 +16,7 @@
 * Install compile tools:
     ```
     - sudo yum install make
+    - sudo yum install cmake
     - sudo yum install gcc-c++
     ```
 * Install dependency:
@@ -44,11 +45,23 @@
     ```
    
       
-* Module make and install
-   ```
-    - make
-    - make install
-   ```
+* Make and install module manually
+   
+   1. Using Dynamic Rocketmq and boost python libraries are recommended.
+      ```
+      - mkdir build
+      - cmake ../ -DBoost_USE_STATIC_LIBS=OFF -DROCKETMQ_USE_STATIC_LIBS=OFF
+      - make
+      - make install
+      ```
+      
+   2. Also you can using static libraries.
+      ```
+         - mkdir build
+         - cmake ../ -DBoost_USE_STATIC_LIBS=ON -DROCKETMQ_USE_STATIC_LIBS=ON
+         - make
+         - make install
+      ```
 * Check verion
    ```
    strings librocketmqclientpython.so |grep PYTHON_CLIENT_VERSION
diff --git a/package.sh b/package.sh
new file mode 100755
index 0000000..f22d293
--- /dev/null
+++ b/package.sh
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+# 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.
+
+function Help()
+{
+    echo "=========================================Package============================================"
+    echo "sh package.sh [shared]"
+    echo "usage: sh package.sh shared"
+    echo "shared: build python client by dynamic boost python and rocketmq library"
+    echo "default: build python client by static boost python and rocketmq library"
+    echo "=========================================Package============================================"
+    echo ""
+}
+
+if [ $# -gt 0 ];then
+    if [ "$1" != "shared" ];then
+        #echo "unsupport para value $1, please see the help"
+        Help
+        exit 1
+    fi
+fi
+
+PACKAGE="rocketmq-client-python"
+VERSION=$(cat src/PythonWrapper.h | grep PYTHON_CLIENT_VERSION | cut -f2 -d"\"")
+CWD_DIR=$(cd "$(dirname "$0")"; pwd)
+DEPLOY_BUILD_HOME=${CWD_DIR}/${PACKAGE}
+
+# ##====================================================================
+#make
+rm -rf ${CWD_DIR}/tmpbuild
+mkdir -p ${CWD_DIR}/tmpbuild
+cd ${CWD_DIR}/tmpbuild
+if [ $1 = "shared" ]; then
+    echo "------------Build Client using dynamic library------------"
+    cmake ${CWD_DIR} -DBoost_USE_STATIC_LIBS=OFF -DROCKETMQ_USE_STATIC_LIBS=OFF
+    RMQ=$(cat CMakeCache.txt | grep ROCKETMQ_LIBRARIES:FILEPATH= | cut -f2 -d "=")
+    echo "Rocketmq Library:${RMQ}"
+else
+    echo "-------------Build Client using static library-------------"
+    cmake ${CWD_DIR} -DBoost_USE_STATIC_LIBS=ON -DROCKETMQ_USE_STATIC_LIBS=ON
+fi
+if [ $? -ne 0 ];then
+        exit 1
+fi
+make
+if [ $? -ne 0 ];then
+        exit 1
+fi
+cd ${CWD_DIR}
+# ##====================================================================
+# # deploy
+echo "Package Library...."
+rm -rf   ${DEPLOY_BUILD_HOME}
+mkdir -p ${DEPLOY_BUILD_HOME}/lib
+if [ $1 = "shared" ];then
+    echo "Copy librocketmq to package...."
+    cp -rf ${RMQ} ${DEPLOY_BUILD_HOME}/lib/
+    #cp -rf /usr/local/lib/libboost_python.*.so.* ${DEPLOY_BUILD_HOME}/lib/
+fi
+cp -rf ${CWD_DIR}/bin/*.so  ${DEPLOY_BUILD_HOME}/lib/
+cp -rf ${CWD_DIR}/sample ${DEPLOY_BUILD_HOME}/
+cp -rf ${CWD_DIR}/doc 	  ${DEPLOY_BUILD_HOME}/
+cp -rf ${CWD_DIR}/changelog  ${DEPLOY_BUILD_HOME}/
+
+
+cd ${CWD_DIR} && tar -cvzf ./${PACKAGE}-${VERSION}.tar.gz ./${VERSION}  >/dev/null 2>&1
+rm -rf ${DEPLOY_BUILD_HOME}
+# # ##====================================================================
+cd ${CWD_DIR}/tmpbuild
+make clean
+cd ${CWD_DIR}
+rm -rf ${CWD_DIR}/tmpbuild
diff --git a/project/CMakeLists.txt b/project/CMakeLists.txt
index 8292708..d317b80 100644
--- a/project/CMakeLists.txt
+++ b/project/CMakeLists.txt
@@ -32,24 +32,24 @@ LIST(APPEND SUB_DIRS ${CMAKE_SOURCE_DIR}/src)
 # include_directories
 include_directories(${CMAKE_SOURCE_DIR}/include)
 include_directories(${SUB_DIRS})
-include_directories(/usr/local/include/rocketmq)
+#include_directories(/usr/local/include/rocketmq)
 include_directories(/usr/include/python2.7)
+include_directories(/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7)
 
 
 # static
 add_library(rocketmqclientpython_static STATIC ${SRC_FILES})
 set_target_properties(rocketmqclientpython_static PROPERTIES OUTPUT_NAME "rocketmqclientpython")
-#add_dependencies(rocketmqclientpython_static)
 target_link_libraries(rocketmqclientpython_static ${deplibs})
-target_link_libraries(rocketmqclientpython_static)
+target_link_libraries(rocketmqclientpython_static ${ROCKETMQ_LIBRARIES})
+target_link_libraries(rocketmqclientpython_static ${Boost_LIBRARIES})
 
 # shared
 set(CMAKE_SHARED_LINKER_FLAGS "-fPIC -shared")
 add_library(rocketmqclientpython_shared SHARED ${SRC_FILES})
 set_target_properties(rocketmqclientpython_shared PROPERTIES OUTPUT_NAME "rocketmqclientpython")
-#add_dependencies(rocketmqclientpython_shared)
 target_link_libraries(rocketmqclientpython_shared ${deplibs})
-target_link_libraries(rocketmqclientpython_shared librocketmq.a)
+target_link_libraries(rocketmqclientpython_shared ${ROCKETMQ_LIBRARIES})
 target_link_libraries(rocketmqclientpython_shared ${Boost_LIBRARIES})
 
 # install
diff --git a/project/Makefile b/project/Makefile
index f80b7e8..c4be14f 100755
--- a/project/Makefile
+++ b/project/Makefile
@@ -51,7 +51,7 @@ CPPFLAGS := -I$(TOPDIR)/include \
 			$(addprefix -I,$(PYTHON_INCLUDE))
 
 LDFLAGS := -shared -Wl,-soname=librocketmqclientpython.so -pthread -fPIC
-LIBPATH := $(addprefix -L, $(ROCKETMQ_LIBD) $(PYTHON_LIBD))
+LIBPATH := $(addprefix -L,$(ROCKETMQ_LIBD) $(PYTHON_LIBD))
 LDLIBS := $(addprefix -l,rocketmq boost_python)
 
 CXX := g++
diff --git a/sample/base.py b/sample/base.py
index 7943b43..4ea4ede 100644
--- a/sample/base.py
+++ b/sample/base.py
@@ -17,33 +17,7 @@
 
 import __init__
 from librocketmqclientpython import *
- 
-def initProducer(name):
-    print("---------Create Producer---------------")
-    producer =CreateProducer(name)
-    SetProducerNameServerAddress(producer,"172.17.0.2:9876")
-    StartProducer(producer)
-    return producer
-
-def testSendMssage(producer,topic,key,body):
-    print("Starting Sending.....")
-    msg = CreateMessage(topic)
-    SetMessageBody(msg, body)
-    SetMessageKeys(msg, key)
-    SetMessageTags(msg, "ThisMessageTag.")
-    result = SendMessageSync(producer,msg)
-    print(result)
-    print("Msgid:")
-    print(result.GetMsgId())
-    print("Offset:")
-    print(result.offset)
-    print("sendStatus:")
-    print(result.sendStatus)
-    DestroyMessage(msg)
-    print("Done...............")
-
-def releaseProducer(producer):
-    ShutdownProducer(producer)
-    DestroyProducer(producer)
-    print("--------Release producer-----------")
 
+def showClientVersion():
+    print("Python Client Version:")
+    print(GetVersion())
diff --git a/sample/testConsumer.py b/sample/testConsumer.py
index 1e0a452..93665ed 100644
--- a/sample/testConsumer.py
+++ b/sample/testConsumer.py
@@ -33,7 +33,7 @@ def consumerMessage(msg):
 
 consumer = CreatePushConsumer("awtTest_Producer_Python_Test")
 print(consumer)
-SetPushConsumerNameServerAddress(consumer,"172.17.0.5:9876")
+SetPushConsumerNameServerAddress(consumer,"172.17.0.2:9876")
 SetPushConsumerThreadCount(consumer,1)
 Subscribe(consumer, "T_TestTopic", "*")
 RegisterMessageCallback(consumer,consumerMessage)
diff --git a/sample/testProducer.py b/sample/testProducer.py
index 1bb2c42..558eb6b 100644
--- a/sample/testProducer.py
+++ b/sample/testProducer.py
@@ -18,7 +18,36 @@
 from base import *
 import time
 
+def initProducer(name):
+    print("---------Create Producer---------------")
+    producer =CreateProducer(name)
+    SetProducerNameServerAddress(producer,"172.17.0.2:9876")
+    StartProducer(producer)
+    return producer
 
+def testSendMssage(producer,topic,key,body):
+    print("Starting Sending.....")
+    msg = CreateMessage(topic)
+    SetMessageBody(msg, body)
+    SetMessageKeys(msg, key)
+    SetMessageTags(msg, "ThisMessageTag.")
+    result = SendMessageSync(producer,msg)
+    print(result)
+    print("Msgid:")
+    print(result.GetMsgId())
+    print("Offset:")
+    print(result.offset)
+    print("sendStatus:")
+    print(result.sendStatus)
+    DestroyMessage(msg)
+    print("Done...............")
+
+def releaseProducer(producer):
+    ShutdownProducer(producer)
+    DestroyProducer(producer)
+    print("--------Release producer-----------")
+
+showClientVersion()
 producer = initProducer("TestPythonProducer")
 topic = "T_TestTopic"
 key = "TestKeys"


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services