From 79584862f6f90b208054bf7be8604ab5efcda1b5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 18 Dec 2019 17:12:52 +0800 Subject: [PATCH] src,qa: install python bindings into lib/cython_modules/lib.3 instead of checking for the WITH_PYTHON* options, just hardwire to lib.3 Signed-off-by: Kefu Chai --- cmake/modules/AddCephTest.cmake | 2 +- cmake/modules/Distutils.cmake | 4 ++-- qa/run-standalone.sh | 12 ++-------- qa/tasks/vstart_runner.py | 4 ++-- qa/workunits/rbd/rbd-ggate.sh | 5 +--- qa/workunits/rbd/rbd-nbd.sh | 5 +--- qa/workunits/rbd/rbd_mirror_helpers.sh | 5 +--- src/init-ceph.in | 2 +- .../mgr/dashboard/run-backend-api-tests.sh | 23 ++----------------- src/pybind/mgr/insights/tox.ini | 3 +-- src/pybind/mgr/orchestrator_cli/tox.ini | 3 +-- src/test/run-rbd-tests | 5 +--- src/vstart.sh | 12 +--------- 13 files changed, 17 insertions(+), 68 deletions(-) diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index 9e2f6463890ae..66f7d8cbb31f5 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -15,7 +15,7 @@ function(add_ceph_test test_name test_path) CEPH_BUILD_DIR=${CMAKE_BINARY_DIR} LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:${CMAKE_SOURCE_DIR}/src:$ENV{PATH} - PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.${Python${PYTHON_VERSION}_VERSION_MAJOR}:${CMAKE_SOURCE_DIR}/src/pybind + PYTHONPATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules/lib.3:${CMAKE_SOURCE_DIR}/src/pybind CEPH_BUILD_VIRTUALENV=${CEPH_BUILD_VIRTUALENV}) # none of the tests should take more than 1 hour to complete set_property(TEST diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index b47d14b1465ab..5fe929499d3cd 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -69,7 +69,7 @@ function(distutils_add_cython_module target name src) if(NOT result EQUAL 0) message(FATAL_ERROR "Unable to tell python extension's suffix: ${error}") endif() - set(output_dir "${CYTHON_MODULE_DIR}/lib.${Python${python_version}_VERSION_MAJOR}") + set(output_dir "${CYTHON_MODULE_DIR}/lib.3") set(setup_py ${CMAKE_CURRENT_SOURCE_DIR}/setup.py) add_custom_command( OUTPUT ${output_dir}/${name}${ext_suffix} @@ -120,7 +120,7 @@ function(distutils_install_cython_module name) COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py build --verbose --build-base ${CYTHON_MODULE_DIR} - --build-platlib ${CYTHON_MODULE_DIR}/lib.${Python${python_version}_VERSION_MAJOR} + --build-platlib ${CYTHON_MODULE_DIR}/lib.3 build_ext --cython-c-in-temp --build-temp ${CMAKE_CURRENT_BINARY_DIR} --cython-include-dirs ${PROJECT_SOURCE_DIR}/src/pybind/rados install \${options} --single-version-externally-managed --record /dev/null egg_info --egg-base ${CMAKE_CURRENT_BINARY_DIR} diff --git a/qa/run-standalone.sh b/qa/run-standalone.sh index 449c23bf91ba8..9daaabfa1c9d8 100755 --- a/qa/run-standalone.sh +++ b/qa/run-standalone.sh @@ -12,21 +12,13 @@ function get_cmake_variable() { } function get_python_path() { - local py_ver=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1) - if [ -z "${py_ver}" ]; then - if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then - py_ver=2 - else - py_ver=3 - fi - fi python_common=$(realpath ../src/python-common) - echo $(realpath ../src/pybind):$(pwd)/lib/cython_modules/lib.$py_ver:$python_common + echo $(realpath ../src/pybind):$(pwd)/lib/cython_modules/lib.3:$python_common } if [ `uname` = FreeBSD ]; then # otherwise module prettytable will not be found - export PYTHONPATH=$(get_python_path):/usr/local/lib/python2.7/site-packages + export PYTHONPATH=$(get_python_path):/usr/local/lib/python3.6/site-packages exec_mode=+111 KERNCORE="kern.corefile" COREPATTERN="core.%N.%P" diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 5b85c1b96dd6d..dfb67908c5f00 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -15,7 +15,7 @@ Simple usage (assuming teuthology and ceph checked out in ~/git): Alternative usage: # Alternatively, if you use different paths, specify them as follows: - LD_LIBRARY_PATH=`pwd`/lib PYTHONPATH=~/git/teuthology:~/git/ceph/qa:`pwd`/../src/pybind:`pwd`/lib/cython_modules/lib.2 python ~/git/ceph/qa/tasks/vstart_runner.py + LD_LIBRARY_PATH=`pwd`/lib PYTHONPATH=~/git/teuthology:~/git/ceph/qa:`pwd`/../src/pybind:`pwd`/lib/cython_modules/lib.3 python ~/git/ceph/qa/tasks/vstart_runner.py # If you wish to drop to a python shell on failures, use --interactive: python ~/git/ceph/qa/tasks/vstart_runner.py --interactive @@ -100,7 +100,7 @@ if os.path.exists("./CMakeCache.txt") and os.path.exists("./bin"): # A list of candidate paths for each package we need guesses = [ ["~/git/teuthology", "~/scm/teuthology", "~/teuthology"], - ["lib/cython_modules/lib.2"], + ["lib/cython_modules/lib.3"], ["../src/pybind"], ] diff --git a/qa/workunits/rbd/rbd-ggate.sh b/qa/workunits/rbd/rbd-ggate.sh index 9b60158d8f908..1bf89da382c2a 100755 --- a/qa/workunits/rbd/rbd-ggate.sh +++ b/qa/workunits/rbd/rbd-ggate.sh @@ -63,10 +63,7 @@ setup() CEPH_BIN=${CEPH_ROOT}/bin export LD_LIBRARY_PATH=${CEPH_ROOT}/lib:${LD_LIBRARY_PATH} - export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind - for x in ${CEPH_ROOT}/lib/cython_modules/lib* ; do - PYTHONPATH="${PYTHONPATH}:${x}" - done + export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind:${CEPH_ROOT}/lib/cython_modules/lib.3 PATH=${CEPH_BIN}:${PATH} fi diff --git a/qa/workunits/rbd/rbd-nbd.sh b/qa/workunits/rbd/rbd-nbd.sh index 2ed1618c1a778..2d718b3e26a0c 100755 --- a/qa/workunits/rbd/rbd-nbd.sh +++ b/qa/workunits/rbd/rbd-nbd.sh @@ -39,10 +39,7 @@ setup() CEPH_BIN=${CEPH_ROOT}/bin export LD_LIBRARY_PATH=${CEPH_ROOT}/lib:${LD_LIBRARY_PATH} - export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind - for x in ${CEPH_ROOT}/lib/cython_modules/lib* ; do - PYTHONPATH="${PYTHONPATH}:${x}" - done + export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind:${CEPH_ROOT}/lib/cython_modules/lib.3 PATH=${CEPH_BIN}:${PATH} fi diff --git a/qa/workunits/rbd/rbd_mirror_helpers.sh b/qa/workunits/rbd/rbd_mirror_helpers.sh index d766798b3171b..4cbf02b033aad 100755 --- a/qa/workunits/rbd/rbd_mirror_helpers.sh +++ b/qa/workunits/rbd/rbd_mirror_helpers.sh @@ -101,10 +101,7 @@ if [ -e CMakeCache.txt ]; then # needed for ceph CLI under cmake export LD_LIBRARY_PATH=${CEPH_ROOT}/lib:${LD_LIBRARY_PATH} - export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind - for x in ${CEPH_ROOT}/lib/cython_modules/lib* ; do - export PYTHONPATH="${PYTHONPATH}:${x}" - done + export PYTHONPATH=${PYTHONPATH}:${CEPH_SRC}/pybind:${CEPH_ROOT}/lib/cython_modules/lib.3 fi # These vars facilitate running this script in an environment with diff --git a/src/init-ceph.in b/src/init-ceph.in index e1915bbfb6d6d..bd4ddcf0e5a2f 100755 --- a/src/init-ceph.in +++ b/src/init-ceph.in @@ -36,7 +36,7 @@ else ETCDIR=. ASSUME_DEV=1 CEPH_LIB=$CEPH_ROOT/${BUILD_DIR}/lib - echo "$PYTHONPATH" | grep -q $CEPH_LIB || export PYTHONPATH=$CEPH_LIB/cython_modules/lib.@MGR_PYTHON_VERSION_MAJOR@:$PYTHONPATH + echo "$PYTHONPATH" | grep -q $CEPH_LIB || export PYTHONPATH=$CEPH_LIB/cython_modules/lib.3:$PYTHONPATH echo "$LD_LIBRARY_PATH" | grep -q $CEPH_LIB || export LD_LIBRARY_PATH=$CEPH_LIB:$LD_LIBRARY_PATH echo "$DYLD_LIBRARY_PATH" | grep -q $CEPH_LIB || export DYLD_LIBRARY_PATH=$CEPH_LIB:$DYLD_LIBRARY_PATH else diff --git a/src/pybind/mgr/dashboard/run-backend-api-tests.sh b/src/pybind/mgr/dashboard/run-backend-api-tests.sh index c7b9e3f07bcf7..9afa0ec71904f 100755 --- a/src/pybind/mgr/dashboard/run-backend-api-tests.sh +++ b/src/pybind/mgr/dashboard/run-backend-api-tests.sh @@ -35,23 +35,6 @@ get_cmake_variable() { [ -z "$BUILD_DIR" ] && BUILD_DIR=build -get_build_py_version() { - CURR_DIR=`pwd` - LOCAL_BUILD_DIR="$CURR_DIR/../../../../$BUILD_DIR" - cd "$LOCAL_BUILD_DIR" - - CEPH_MGR_PY_VERSION_MAJOR=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f1) - if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then - CEPH_PY_VERSION_MAJOR=${CEPH_MGR_PY_VERSION_MAJOR} - else - if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then - CEPH_PY_VERSION_MAJOR=2 - else - CEPH_PY_VERSION_MAJOR=3 - fi - fi -} - setup_teuthology() { TEMP_DIR=`mktemp -d` cd $TEMP_DIR @@ -116,7 +99,7 @@ run_teuthology_tests() { export PATH=$LOCAL_BUILD_DIR/bin:$PATH source $TEMP_DIR/venv/bin/activate # Run after setting PATH as it does the last PATH export. - export LD_LIBRARY_PATH=$LOCAL_BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$LOCAL_BUILD_DIR/lib + export LD_LIBRARY_PATH=$LOCAL_BUILD_DIR/lib/cython_modules/lib.3/:$LOCAL_BUILD_DIR/lib local source_dir=$(dirname "$LOCAL_BUILD_DIR") local pybind_dir=$source_dir/src/pybind local python_common_dir=$source_dir/src/python-common @@ -125,7 +108,7 @@ run_teuthology_tests() { export PYBIND=$LOCAL_BUILD_DIR/src/pybind pybind_dir=$PYBIND fi - export PYTHONPATH=$source_dir/qa:$LOCAL_BUILD_DIR/lib/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}/:$pybind_dir:$python_common_dir:${COVERAGE_PATH} + export PYTHONPATH=$source_dir/qa:$LOCAL_BUILD_DIR/lib/cython_modules/lib.3/:$pybind_dir:$python_common_dir:${COVERAGE_PATH} export RGW=${RGW:-1} export COVERAGE_ENABLED=true @@ -157,7 +140,6 @@ cleanup_teuthology() { unset CURR_DIR unset LOCAL_BUILD_DIR unset COVERAGE_PATH - unset get_build_py_version unset setup_teuthology unset setup_coverage unset on_tests_error @@ -165,7 +147,6 @@ cleanup_teuthology() { unset cleanup_teuthology } -get_build_py_version setup_teuthology setup_coverage run_teuthology_tests --create-cluster-only diff --git a/src/pybind/mgr/insights/tox.ini b/src/pybind/mgr/insights/tox.ini index 207e6fb923498..9c74a8df0a0e6 100644 --- a/src/pybind/mgr/insights/tox.ini +++ b/src/pybind/mgr/insights/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py3 +envlist = py3 skipsdist = true toxworkdir = {env:CEPH_BUILD_DIR}/insights minversion = 2.8.1 @@ -10,7 +10,6 @@ deps = mock setenv= UNITTEST = true - py27: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.2 py3: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3 commands= {envbindir}/py.test tests/ diff --git a/src/pybind/mgr/orchestrator_cli/tox.ini b/src/pybind/mgr/orchestrator_cli/tox.ini index cbec129837500..60a6902c5f252 100644 --- a/src/pybind/mgr/orchestrator_cli/tox.ini +++ b/src/pybind/mgr/orchestrator_cli/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py3 +envlist = py3 skipsdist = true toxworkdir = {env:CEPH_BUILD_DIR}/orchestrator_cli minversion = 2.5 @@ -8,7 +8,6 @@ minversion = 2.5 deps = -rrequirements.txt setenv= UNITTEST = true - py27: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.2 py3: PYTHONPATH = {toxinidir}/../../../../build/lib/cython_modules/lib.3 commands= diff --git a/src/test/run-rbd-tests b/src/test/run-rbd-tests index 21913bfc51385..149fbf2ae7d70 100755 --- a/src/test/run-rbd-tests +++ b/src/test/run-rbd-tests @@ -11,10 +11,7 @@ else CYTHON_MODULES_DIR=$CEPH_SRC/build fi -export PYTHONPATH="$CEPH_SRC/pybind:$CEPH_SRC/test/pybind" -for x in $CYTHON_MODULES_DIR/lib* ; do - PYTHONPATH="${PYTHONPATH}:${x}" -done +export PYTHONPATH="$CEPH_SRC/pybind:$CEPH_SRC/test/pybind:$CYTHON_MODULES_DIR/lib.3" recreate_pool() { POOL_NAME=$1 diff --git a/src/vstart.sh b/src/vstart.sh index 19cb4d95f04fa..4e031b66ac95f 100755 --- a/src/vstart.sh +++ b/src/vstart.sh @@ -56,16 +56,6 @@ if [ -e CMakeCache.txt ]; then CEPH_ROOT=$(get_cmake_variable ceph_SOURCE_DIR) CEPH_BUILD_DIR=`pwd` [ -z "$MGR_PYTHON_PATH" ] && MGR_PYTHON_PATH=$CEPH_ROOT/src/pybind/mgr - CEPH_MGR_PY_VERSION_MAJOR=$(get_cmake_variable MGR_PYTHON_VERSION | cut -d '.' -f 1) - if [ -n "$CEPH_MGR_PY_VERSION_MAJOR" ]; then - CEPH_PY_VERSION_MAJOR=${CEPH_MGR_PY_VERSION_MAJOR} - else - if [ $(get_cmake_variable WITH_PYTHON2) = ON ]; then - CEPH_PY_VERSION_MAJOR=2 - else - CEPH_PY_VERSION_MAJOR=3 - fi - fi fi # use CEPH_BUILD_ROOT to vstart from a 'make install' @@ -94,7 +84,7 @@ fi [ -z "$PYBIND" ] && PYBIND=./pybind [ -n "$CEPH_PYTHON_COMMON" ] && CEPH_PYTHON_COMMON="$CEPH_PYTHON_COMMON:" -CYTHON_PYTHONPATH="$CEPH_LIB/cython_modules/lib.${CEPH_PY_VERSION_MAJOR}" +CYTHON_PYTHONPATH="$CEPH_LIB/cython_modules/lib.3" export PYTHONPATH=$PYBIND:$CYTHON_PYTHONPATH:$CEPH_PYTHON_COMMON$PYTHONPATH export LD_LIBRARY_PATH=$CEPH_LIB:$LD_LIBRARY_PATH -- 2.39.5