This is an automated email from the ASF dual-hosted git repository. cml pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/qpid-interop-test.git
commit 402fb98659e8244eddfac938ecc0db4f40edbbcc Author: Kim van der Riet <[email protected]> AuthorDate: Fri Jan 17 12:17:33 2020 -0500 QPIDIT-139: Improving install's detection of Python 2 and Python 3, preparing for swith to Python 3 tests. QPIDIT-135: Minor improvements to handling of Python 2 and Python 3 shims. The presence of PYTHON2PATH and PYTHON3PATH in env controls the running of the shims. QPIDIT-138: Minor improvements to messages during cmake run. --- CMakeLists.txt | 105 +++++++++++++++++++---------- config.sh.in | 26 +++++-- shims/amqpnetlite/src/CMakeLists.txt | 8 +-- src/python/qpid_interop_test/qit_common.py | 22 +++--- src/python/qpid_interop_test/qit_shim.py | 2 + 5 files changed, 108 insertions(+), 55 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48506a8..8cb607b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,37 +23,58 @@ cmake_minimum_required(VERSION 2.8.7 FATAL_ERROR) set (ErrorFlag FALSE) -# Find xpath - -find_program(Xpath xpath) -if (Xpath STREQUAL "Xpath-NOTFOUND") - message(WARNING "xpath not found") +# Find Python +# Older cmakes (2.8.x used on RHEL/CentOS 7) don't do Python2 +# vs Python3 cleanly. So we must improvise... +MACRO (find_python + py_exec # Python executable (eg python, python3) + found_var_name # Variable name indicating python executable found + version_var_name # Variable name containing python version + site_dir_var_name) # Variable name containing site_packages dir name + execute_process (COMMAND ${py_exec} --version + RESULT_VARIABLE res + OUTPUT_VARIABLE ov + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE ev + ERROR_STRIP_TRAILING_WHITESPACE) + if (res STREQUAL "0") + set (${found_var_name} ON) + # Some versions of Python print version info to stdout, others to stderr + if (ov STREQUAL "") + if (ev STREQUAL "") + message (WARNING "Unable to obtain python version string") + else () + set(ov ${ev}) + endif () + endif () + message (STATUS "${ov} found") + string (REGEX MATCH "[0-9]+(\\.[0-9]+)" ver_str "${ov}") + set (${version_var_name} ${ver_str}) + string (REGEX MATCH "[0-9]+" maj_ver_str ${ver_str}) + execute_process (COMMAND ${CMAKE_SOURCE_DIR}/get-python-dir-name ${maj_ver_str} + OUTPUT_VARIABLE dir_name) + set (${site_dir_var_name} ${dir_name}) + else () + message (STATUS "${py_exec} not found") + set (${found_var_name} ${py_exec}-NOTFOUND) + endif () +ENDMACRO () + +find_python(python "PYTHON2_FOUND" "PYTHON2_VER" "PYTHON2_SITE_DIR_NAME") +# Python2 is required to run main QIT program +if (NOT PYTHON2_FOUND) + message(STATUS "ERROR: Python 2.x not found, but is required") set (ErrorFlag TRUE) -else () - message(STATUS "xpath found: ${Xpath}") endif () - -# Find Python 2.7.x install path - -find_package( PythonInterp 2.7 REQUIRED ) -execute_process(COMMAND ${CMAKE_SOURCE_DIR}/get-python-dir-name 2 - OUTPUT_VARIABLE PYTHON2_DIR_NAME) -message(STATUS "Python 2 install directory name: ${PYTHON2_DIR_NAME}") -execute_process(COMMAND ${CMAKE_SOURCE_DIR}/get-python-dir-name 3 - OUTPUT_VARIABLE PYTHON3_DIR_NAME) -message(STATUS "Python 3 install directory name: ${PYTHON3_DIR_NAME}") +find_python(python3 "PYTHON3_FOUND" "PYTHON3_VER" "PYTHON3_SITE_DIR_NAME") # Find Java find_package(Java 1.8 COMPONENTS Development) # RHEL7 bug: Java_FOUND is not being set, so workaround: -if (DEFINED Java_JAVA_EXECUTABLE AND DEFINED Java_JAVAC_EXECUTABLE AND DEFINED Java_JAR_EXECUTABLE) - message(STATUS "Java ${Java_VERSION_STRING} found") - message(STATUS "Java executable: ${Java_JAVA_EXECUTABLE}") - message(STATUS "Java compiler: ${Java_JAVAC_EXECUTABLE}") - message(STATUS "Java archiver: ${Java_JAR_EXECUTABLE}") -else () - message(WARNING "Java compiler not found") +#if (NOT DEFINED Java_JAVA_EXECUTABLE OR NOT DEFINED Java_JAVAC_EXECUTABLE OR NOT DEFINED Java_JAR_EXECUTABLE) +if (NOT Java_FOUND) + message(STATUS "ERROR: Java compiler not found, but is required") set (ErrorFlag TRUE) endif () @@ -62,36 +83,52 @@ endif () find_program(Maven mvn HINT /usr/local/maven/bin) # common location for local install if (Maven STREQUAL "Maven-NOTFOUND") - message (WARNING "Maven not found") + message (STATUS "ERROR: Maven not found, but is required") set (ErrorFlag TRUE) else () message (STATUS "Maven found: ${Maven}") endif () +# Find xpath + +find_program(Xpath xpath) +if (Xpath STREQUAL "Xpath-NOTFOUND") + message(STATUS "ERROR: xpath not found, but is required") + set (ErrorFlag TRUE) +else () + message(STATUS "xpath found: ${Xpath}") +endif () + # Find Proton components -find_package(Proton 0.17) +find_package(Proton 0.30) if (Proton_FOUND) get_filename_component(PROTON_INSTALL_DIR ${Proton_INCLUDE_DIRS} PATH CACHE PATH "Proton install directory") message(STATUS "Qpid proton found. Version ${Proton_VERSION} at ${Proton_INCLUDE_DIRS}") else () - message(WARNING "Qpid proton not found.") + message(STATUS "ERROR: Qpid proton not found, but is required") set (ErrorFlag TRUE) endif () -find_package(ProtonCpp 0.17) +find_package(ProtonCpp 0.30) if (ProtonCpp_FOUND) get_filename_component(PROTON_CPP_INSTALL_DIR ${ProtonCpp_INCLUDE_DIRS} PATH CACHE PATH "ProtonCpp install directory") message(STATUS "Qpid proton c++ binding found. Version ${ProtonCpp_VERSION} at ${ProtonCpp_INCLUDE_DIRS}") else() - message(WARNING "Qpid proton c++ binding not found.") + message(STATUS "ERROR: Qpid proton c++ binding not found, but is required") set (ErrorFlag TRUE) endif () if (ErrorFlag) - message(FATAL_ERROR "Required component(s) missing, aborting configuration.") + message(FATAL_ERROR "Required component(s) missing, aborting configuration. See above for errors.") endif () +add_subdirectory(shims/qpid-proton-cpp/src) +add_subdirectory(shims/qpid-jms) +add_subdirectory(shims/amqpnetlite/src) +add_subdirectory(shims/rhea-js) +add_subdirectory(docs) + # Generate data code files for amqp_complex_types_test execute_process(COMMAND python3 src/python/qpid_interop_test/amqp_complex_types_test_generator.py --gen cpp --src-dir src/python/qpid_interop_test --gen-dir shims/qpid-proton-cpp/src/qpidit/amqp_complex_types_test WORKING_DIRECTORY ../ @@ -125,12 +162,6 @@ if(NOT "${retcode}" STREQUAL "0") message(FATAL_ERROR "Data code file generation for .Net failed: ${retcode}") endif() -add_subdirectory(shims/qpid-proton-cpp/src) -add_subdirectory(shims/qpid-jms) -add_subdirectory(shims/amqpnetlite/src) -add_subdirectory(shims/rhea-js) -add_subdirectory(docs) - # Install files using python setup.py install(CODE "MESSAGE(STATUS \"Python install dir: ${CMAKE_INSTALL_PREFIX}/lib/${PYTHON2_DIR_NAME}/site-packages/qpid_interop_test/\")") install(CODE "execute_process(COMMAND python setup.py install --prefix ${CMAKE_INSTALL_PREFIX} @@ -152,4 +183,4 @@ install(CODE "execute_process(COMMAND ln -s ${CMAKE_INSTALL_PREFIX}/lib/${PYTHON install(CODE "execute_process(COMMAND bash -c \"chmod +x *_test.py\" WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib/${PYTHON2_DIR_NAME}/site-packages/qpid_interop_test/)") -configure_file(config.sh.in config.sh) +configure_file(config.sh.in config.sh @ONLY) diff --git a/config.sh.in b/config.sh.in index f7bd3c2..a159a50 100644 --- a/config.sh.in +++ b/config.sh.in @@ -1,3 +1,5 @@ +#! /bin/bash + # 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. @@ -18,14 +20,26 @@ export QPID_INTEROP_TEST_HOME=@CMAKE_SOURCE_DIR@ export QIT_INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ -CURRENT_PYTHONPATH=$PYTHONPATH -export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON2_DIR_NAME@/site-packages:@CMAKE_INSTALL_PREFIX@/libexec/qpid_interop_test/shims/qpid-proton-python:$CURRENT_PYTHONPATH -if [[ "@PYTHON3_DIR_NAME@" == "NOT_FOUND" ]]; then - unset PYTHON3PATH + +# Set PYTHON2PATH and PYTHON3PATH for respective python shims + +unset PYTHON2PATH +py2_found_str="@PYTHON2_FOUND@" +if [[ "${py2_found_str#*-}" == "NOTFOUND" ]]; then + echo "No Python 2.x found, Python 2 shims disabled" +else + export PYTHON2PATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON2_SITE_DIR_NAME@/site-packages:@CMAKE_INSTALL_PREFIX@/libexec/qpid_interop_test/shims/qpid-proton-python +fi + +unset PYTHON3PATH +py3_found_str="@PYTHON3_FOUND@" +if [[ "${py3_found_str#*-}" == "NOTFOUND" ]]; then echo "No Python 3.x found, Python 3 shims disabled" else - CURRENT_PYTHON3PATH=$PYTHON3PATH - export PYTHON3PATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python3:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON3_DIR_NAME@/site-packages:@CMAKE_INSTALL_PREFIX@/libexec/qpid_interop_test/shims/qpid-proton-python:$CURRENT_PYTHON3PATH + export PYTHON3PATH=@CMAKE_INSTALL_PREFIX@/lib64/proton/bindings/python3:@CMAKE_INSTALL_PREFIX@/lib/@PYTHON3_SITE_DIR_NAME@/site-packages:@CMAKE_INSTALL_PREFIX@/libexec/qpid_interop_test/shims/qpid-proton-python fi +# To run the main program use python 2 +export PYTHONPATH=$PYTHON2PATH + export LD_LIBRARY_PATH=@CMAKE_INSTALL_PREFIX@/lib64:$LD_LIBRARY_PATH export PATH=@CMAKE_INSTALL_PREFIX@/lib/@PYTHON_DIR_NAME@/site-packages/qpid_interop_test:$PATH diff --git a/shims/amqpnetlite/src/CMakeLists.txt b/shims/amqpnetlite/src/CMakeLists.txt index c01b8dd..49db295 100644 --- a/shims/amqpnetlite/src/CMakeLists.txt +++ b/shims/amqpnetlite/src/CMakeLists.txt @@ -108,21 +108,21 @@ set(BUILD_CONFIG Release) # Debug or Release # 1. Find dotnet find_program(DOTNET dotnet) if (DOTNET STREQUAL "DOTNET-NOTFOUND") - message(STATUS "Program 'dotnet' not found.") + message(STATUS "dotnet not found.") set(build_amqpnetlite_default OFF) else() # 2. dotnet found. Check required version exists execute_process(COMMAND dotnet --version OUTPUT_VARIABLE ov) if("${ov}" STREQUAL "") - message(STATUS "'dotnet' appears to be installed but version is not detected. 'dotnet' version ${REQUIRED_DOTNET_VERSION} required.") + message(STATUS "dotnet appears to be installed but version is not detected. dotnet version ${REQUIRED_DOTNET_VERSION} required.") set(build_amqpnetlite_default OFF) else() # 3. dotnet version string obtained, isolate version number as string, check version requirement string(REGEX MATCH "[0-9]+(\\.[0-9]+)" dotnet_ver "${ov}") if (${dotnet_ver} VERSION_EQUAL "${REQUIRED_DOTNET_VERSION}") - message(STATUS "'dotnet' version ${dotnet_ver} found.") + message(STATUS "dotnet version ${dotnet_ver} found.") else() - message(STATUS "'dotnet' version ${dotnet_ver} found. 'dotnet' version ${REQUIRED_DOTNET_VERSION} required.") + message(STATUS "dotnet version ${dotnet_ver} found. dotnet version ${REQUIRED_DOTNET_VERSION} required.") set(build_amqpnetlite_default OFF) endif() endif() diff --git a/src/python/qpid_interop_test/qit_common.py b/src/python/qpid_interop_test/qit_common.py index bd066da..675bcd0 100644 --- a/src/python/qpid_interop_test/qit_common.py +++ b/src/python/qpid_interop_test/qit_common.py @@ -37,6 +37,7 @@ QIT_INSTALL_PREFIX = getenv('QIT_INSTALL_PREFIX') if QIT_INSTALL_PREFIX is None: print('ERROR: Environment variable QIT_INSTALL_PREFIX is not set') sys.exit(1) +QIT_ENABLE_PYTHON2_SHIM = getenv('PYTHON2PATH') is not None QIT_ENABLE_PYTHON3_SHIM = getenv('PYTHON3PATH') is not None QIT_TEST_SHIM_HOME = path.join(QIT_INSTALL_PREFIX, 'libexec', 'qpid_interop_test', 'shims') @@ -312,21 +313,26 @@ class QitTest(object): def _create_shim_map(self): """Create a shim map {'shim_name': <shim_instance>}""" + # Proton C++ shim proton_cpp_rcv_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-cpp', self.TEST_NAME, 'Receiver') proton_cpp_snd_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-cpp', self.TEST_NAME, 'Sender') - proton_python_rcv_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-python', self.TEST_NAME, 'Receiver.py') - proton_python_snd_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-python', self.TEST_NAME, 'Sender.py') - self.shim_map = {qpid_interop_test.qit_shim.ProtonCppShim.NAME: \ qpid_interop_test.qit_shim.ProtonCppShim(proton_cpp_snd_shim, proton_cpp_rcv_shim), - qpid_interop_test.qit_shim.ProtonPython2Shim.NAME: \ - qpid_interop_test.qit_shim.ProtonPython2Shim(proton_python_snd_shim, proton_python_rcv_shim), -# qpid_interop_test.qit_shim.ProtonPython3Shim.NAME: \ -# qpid_interop_test.qit_shim.ProtonPython3Shim(proton_python_snd_shim, proton_python_rcv_shim), } + + # Python shims + proton_python_rcv_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-python', self.TEST_NAME, 'Receiver.py') + proton_python_snd_shim = path.join(QIT_TEST_SHIM_HOME, 'qpid-proton-python', self.TEST_NAME, 'Sender.py') + if QIT_ENABLE_PYTHON2_SHIM: + self.shim_map[qpid_interop_test.qit_shim.ProtonPython2Shim.NAME] = \ + qpid_interop_test.qit_shim.ProtonPython2Shim(proton_python_snd_shim, proton_python_rcv_shim) + else: + print('Python 2 shim disabled: no PYTHON2PATH in environment') if QIT_ENABLE_PYTHON3_SHIM: self.shim_map[qpid_interop_test.qit_shim.ProtonPython3Shim.NAME] = \ qpid_interop_test.qit_shim.ProtonPython3Shim(proton_python_snd_shim, proton_python_rcv_shim) + else: + print('Python 3 shim disabled: no PYTHON3PATH in environment') # Add shims that need detection during installation only if the necessary bits are present # Rhea Javascript client @@ -348,7 +354,7 @@ class QitTest(object): print('WARNING: AMQP DotNetLite shims not found') def _modify_shim_map(self): - """Modify shim_map based on args""" + """Modify shim_map based on command-line args --include-shim or --exclude-shim""" # Use only shims included from the command-line if self.args.include_shim is not None: temp_shim_map = {} diff --git a/src/python/qpid_interop_test/qit_shim.py b/src/python/qpid_interop_test/qit_shim.py index 4cdb639..1a4ea97 100644 --- a/src/python/qpid_interop_test/qit_shim.py +++ b/src/python/qpid_interop_test/qit_shim.py @@ -38,6 +38,8 @@ class ShimProcess(subprocess.Popen): self.env = copy.deepcopy(os.environ) if python3_flag: self.env['PYTHONPATH'] = self.env['PYTHON3PATH'] + else: + self.env['PYTHONPATH'] = self.env['PYTHON2PATH'] super(ShimProcess, self).__init__(params, stdout=subprocess.PIPE, stderr=subprocess.PIPE, preexec_fn=os.setsid, env=self.env) --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
