From 5fc657b40dc7d27e84d4b62b5f37d9c771d74fcd Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 18 Dec 2019 17:08:21 +0800 Subject: [PATCH] cmake: drop WITH_PYTHON2 option * drop WITH_PYTHON2 option * print warning message if WITH_PYTHON3 is disabled * drop MGR_PYTHON_VERSION option, as we don't support use different python version for python binding and ceph-mgr embedded python interpreter anymore. as before switching to python3-only build, we can build python3 and python2 python bindings, and ceph-mgr can use either of them. but after switching to python3-only build, ceph-mgr has to use whatever python version used to build python binding. * move WITH_PYTHON3 option to $top_srcdir/CMakeLists.txt, as ceph-mgr and python binding will share this option. * hardware ${PYTHON_VERSION} to 3 * hardware ${Python${PYTHON_VERSION}_VERSION_MAJOR} to 3 * only build boost library with python3 * s/Python_EXECUTABLE/Python3_EXECUTABLE/ * update the build scripts and packagings accordingly * rename all cython${PYTHON_VERSION}_* targets to cython_* * update distutils_install_module() so it does not take python_version parameter anymore. Signed-off-by: Kefu Chai --- CMakeLists.txt | 33 +++++---- ceph.spec.in | 2 - cmake/modules/AddCephTest.cmake | 11 +-- cmake/modules/BuildBoost.cmake | 10 +-- cmake/modules/Distutils.cmake | 25 ++----- cmake/modules/FindCython.cmake | 2 +- debian/rules | 2 +- do_cmake.sh | 2 +- run-make-check.sh | 2 +- src/CMakeLists.txt | 47 ++---------- src/ceph-crash.in | 2 +- src/ceph-volume/CMakeLists.txt | 9 +-- src/ceph-volume/plugin/zfs/CMakeLists.txt | 3 +- src/ceph.in | 4 +- src/mgr/CMakeLists.txt | 3 +- src/pybind/CMakeLists.txt | 89 +++++++++-------------- src/pybind/cephfs/CMakeLists.txt | 10 +-- src/pybind/mgr/dashboard/HACKING.rst | 2 +- src/pybind/rados/CMakeLists.txt | 10 +-- src/pybind/rbd/CMakeLists.txt | 10 +-- src/python-common/CMakeLists.txt | 12 +-- src/test/CMakeLists.txt | 2 +- src/tools/cephfs/CMakeLists.txt | 3 +- 23 files changed, 101 insertions(+), 194 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bab40cc4965d0..981f81c207bb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -418,23 +418,26 @@ endif (WITH_RADOSGW) #option for CephFS option(WITH_CEPHFS "CephFS is enabled" ON) -#option for Mgr +# Please specify 3.[0-7] if you want to build with a certain version of python3. +set(WITH_PYTHON3 "3" CACHE STRING "build with specified python3 version") +if(NOT WITH_PYTHON3) + message(FATAL_ERROR "WITH_PYTHON3 should always be enabled") +elseif(WITH_PYTHON3 MATCHES "^(1|ON|YES|TRUE|Y)$") + set(WITH_PYTHON3 "3") + message(NOTICE "Please specify a Python3 version instead of a BOOLEAN") +elseif(NOT WITH_PYTHON3 STREQUAL "3") + set(find_python3_exact "EXACT") +endif() +find_package(Python3 ${WITH_PYTHON3} ${find_python3_exact} REQUIRED + COMPONENTS Interpreter Development) +unset(find_python3_exact) + option(WITH_MGR "ceph-mgr is enabled" ON) if(WITH_MGR) - # Please specify 3 or 3.[0-7] if you want to build with python3 support. - # FindPython thinks they belong to different families. - set(MGR_PYTHON_VERSION "2.7" CACHE - STRING "required version of python runtime for running mgr plugins. ") - if(NOT MGR_PYTHON_VERSION MATCHES "^[23]$") - set(find_python_exact "EXACT") - endif() - find_package(Python ${MGR_PYTHON_VERSION} ${find_python_exact} REQUIRED - COMPONENTS Interpreter Development) - unset(find_python_exact) - set(MGR_PYTHON_EXECUTABLE ${Python_EXECUTABLE}) - set(MGR_PYTHON_LIBRARIES ${Python_LIBRARIES}) - set(MGR_PYTHON_VERSION_MAJOR ${Python_VERSION_MAJOR}) - set(MGR_PYTHON_VERSION_MINOR ${Python_VERSION_MINOR}) + set(MGR_PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) + set(MGR_PYTHON_LIBRARIES ${Python3_LIBRARIES}) + set(MGR_PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR}) + set(MGR_PYTHON_VERSION_MINOR ${Python3_VERSION_MINOR}) # Boost dependency check deferred to Boost section endif(WITH_MGR) diff --git a/ceph.spec.in b/ceph.spec.in index 9a690df28fa63..59d539ce3814f 100644 --- a/ceph.spec.in +++ b/ceph.spec.in @@ -1128,8 +1128,6 @@ ${CMAKE} .. \ -DWITH_MANPAGE=ON \ -DWITH_PYTHON3=%{python3_version} \ -DWITH_MGR_DASHBOARD_FRONTEND=OFF \ - -DWITH_PYTHON2=OFF \ - -DMGR_PYTHON_VERSION=3 \ %if 0%{without ceph_test_package} -DWITH_TESTS=OFF \ %endif diff --git a/cmake/modules/AddCephTest.cmake b/cmake/modules/AddCephTest.cmake index ace6053b1fdb4..9e2f6463890ae 100644 --- a/cmake/modules/AddCephTest.cmake +++ b/cmake/modules/AddCephTest.cmake @@ -38,7 +38,7 @@ if(WITH_GTEST_PARALLEL) add_dependencies(tests gtest-parallel_ext) find_package(Python REQUIRED) set(GTEST_PARALLEL_COMMAND - ${Python_EXECUTABLE} ${gtest_parallel_source_dir}/gtest-parallel) + ${Python3_EXECUTABLE} ${gtest_parallel_source_dir}/gtest-parallel) endif() endif() @@ -62,12 +62,7 @@ function(add_tox_test name) else() set(tox_path ${CMAKE_CURRENT_SOURCE_DIR}) endif() - if(WITH_PYTHON2) - list(APPEND tox_envs py27) - endif() - if(WITH_PYTHON3) - list(APPEND tox_envs py3) - endif() + list(APPEND tox_envs py3) if(DEFINED TOXTEST_TOX_ENVS) list(APPEND tox_envs ${TOXTEST_TOX_ENVS}) endif() @@ -75,7 +70,7 @@ function(add_tox_test name) find_package(Python REQUIRED) add_custom_command( OUTPUT ${venv_path}/bin/activate - COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python="${Python_EXECUTABLE}" ${venv_path} + COMMAND ${CMAKE_SOURCE_DIR}/src/tools/setup-virtualenv.sh --python="${Python3_EXECUTABLE}" ${venv_path} WORKING_DIRECTORY ${tox_path} COMMENT "preparing venv for ${name}") add_custom_target(${name}-venv diff --git a/cmake/modules/BuildBoost.cmake b/cmake/modules/BuildBoost.cmake index 34c37b284b9e8..d1c0eba17d82b 100644 --- a/cmake/modules/BuildBoost.cmake +++ b/cmake/modules/BuildBoost.cmake @@ -109,15 +109,15 @@ function(do_build_boost version) " : ${CMAKE_CXX_COMPILER}" " ;\n") if(with_python_version) - find_package(Python ${with_python_version} QUIET REQUIRED + find_package(Python3 ${with_python_version} QUIET REQUIRED COMPONENTS Development) - string(REPLACE ";" " " python_includes "${Python_INCLUDE_DIRS}") + string(REPLACE ";" " " python3_includes "${Python3_INCLUDE_DIRS}") file(APPEND ${user_config} "using python" " : ${with_python_version}" - " : ${Python_EXECUTABLE}" - " : ${python_includes}" - " : ${Python_LIBRARIES}" + " : ${Python3_EXECUTABLE}" + " : ${python3_includes}" + " : ${Python3_LIBRARIES}" " ;\n") endif() list(APPEND b2 --user-config=${user_config}) diff --git a/cmake/modules/Distutils.cmake b/cmake/modules/Distutils.cmake index 3275fa5117456..b47d14b1465ab 100644 --- a/cmake/modules/Distutils.cmake +++ b/cmake/modules/Distutils.cmake @@ -15,12 +15,7 @@ function(distutils_install_module name) add_custom_target(${name}-clone ALL DEPENDS ${py_clone}) endif() - cmake_parse_arguments(DU "" "INSTALL_SCRIPT;PYTHON_VERSION" "" ${ARGN}) - if(DU_PYTHON_VERSION) - set(python_version ${DU_PYTHON_VERSION}) - else() - set(python_version 3) - endif() + cmake_parse_arguments(DU "" "INSTALL_SCRIPT" "" ${ARGN}) install(CODE " set(options --prefix=${CMAKE_INSTALL_PREFIX}) if(DEFINED ENV{DESTDIR}) @@ -35,12 +30,12 @@ function(distutils_install_module name) endif() endif() execute_process( - COMMAND ${Python${python_version}_EXECUTABLE} + COMMAND ${Python3_EXECUTABLE} setup.py install \${options} WORKING_DIRECTORY \"${CMAKE_CURRENT_BINARY_DIR}\")") endfunction(distutils_install_module) -function(distutils_add_cython_module target name src python_version) +function(distutils_add_cython_module target name src) get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE) get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK) # When using ccache, CMAKE_C_COMPILER is ccache executable absolute path @@ -64,12 +59,8 @@ function(distutils_add_cython_module target name src python_version) set(PY_CXX ${compiler_launcher} ${CMAKE_CXX_COMPILER} ${cxx_compiler_arg1}) set(PY_LDSHARED ${link_launcher} ${CMAKE_C_COMPILER} ${c_compiler_arg1} "-shared") - if(${Python${python_version}_VERSION_MAJOR} STREQUAL "2") - set(suffix_var "SO") - else() - set(suffix_var "EXT_SUFFIX") - endif() - execute_process(COMMAND "${Python${python_version}_EXECUTABLE}" -c + set(suffix_var "EXT_SUFFIX") + execute_process(COMMAND "${Python3_EXECUTABLE}" -c "from distutils import sysconfig; print(sysconfig.get_config_var('${suffix_var}'))" RESULT_VARIABLE result OUTPUT_VARIABLE ext_suffix @@ -91,7 +82,7 @@ function(distutils_add_cython_module target name src python_version) LDFLAGS=-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CYTHON_BUILD_DIR=${CMAKE_CURRENT_BINARY_DIR} CEPH_LIBDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} - ${Python${python_version}_EXECUTABLE} ${setup_py} + ${Python3_EXECUTABLE} ${setup_py} build --verbose --build-base ${CYTHON_MODULE_DIR} --build-platlib ${output_dir} MAIN_DEPENDENCY ${src} @@ -101,7 +92,7 @@ function(distutils_add_cython_module target name src python_version) DEPENDS ${output_dir}/${name}${ext_suffix}) endfunction(distutils_add_cython_module) -function(distutils_install_cython_module name python_version) +function(distutils_install_cython_module name) get_property(compiler_launcher GLOBAL PROPERTY RULE_LAUNCH_COMPILE) get_property(link_launcher GLOBAL PROPERTY RULE_LAUNCH_LINK) set(PY_CC "${compiler_launcher} ${CMAKE_C_COMPILER}") @@ -127,7 +118,7 @@ function(distutils_install_cython_module name python_version) endif() execute_process( COMMAND - ${Python${python_version}_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/setup.py + ${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_ext --cython-c-in-temp --build-temp ${CMAKE_CURRENT_BINARY_DIR} --cython-include-dirs ${PROJECT_SOURCE_DIR}/src/pybind/rados diff --git a/cmake/modules/FindCython.cmake b/cmake/modules/FindCython.cmake index f4407e7f96fb4..8eb9e42f40281 100644 --- a/cmake/modules/FindCython.cmake +++ b/cmake/modules/FindCython.cmake @@ -4,7 +4,7 @@ # Try to run Cython, to make sure it works: execute_process( - COMMAND ${Python${PYTHON_VERSION}_EXECUTABLE} -m cython --version + COMMAND ${Python3_EXECUTABLE} -m cython --version RESULT_VARIABLE cython_result ERROR_VARIABLE cython_output) if(cython_result EQUAL 0) diff --git a/debian/rules b/debian/rules index de5f14ace1029..84529306bf0da 100755 --- a/debian/rules +++ b/debian/rules @@ -19,7 +19,7 @@ endif extraopts += -DWITH_OCF=ON -DWITH_LTTNG=ON extraopts += -DWITH_MGR_DASHBOARD_FRONTEND=OFF -extraopts += -DWITH_PYTHON3=3 -DWITH_PYTHON2=OFF -DMGR_PYTHON_VERSION=3 +extraopts += -DWITH_PYTHON3=3 extraopts += -DWITH_CEPHFS_JAVA=ON extraopts += -DWITH_CEPHFS_SHELL=ON extraopts += -DWITH_SYSTEMD=ON -DCEPH_SYSTEMD_ENV_DIR=/etc/default diff --git a/do_cmake.sh b/do_cmake.sh index 2f6e5bbb82ed1..12ab5377f873a 100755 --- a/do_cmake.sh +++ b/do_cmake.sh @@ -42,7 +42,7 @@ else fi if [[ "$PYBUILD" =~ ^3(\..*)?$ ]] ; then - ARGS+=" -DWITH_PYTHON2=OFF -DWITH_PYTHON3=${PYBUILD} -DMGR_PYTHON_VERSION=${PYBUILD}" + ARGS+=" -DWITH_PYTHON3=${PYBUILD}" fi if type ccache > /dev/null 2>&1 ; then diff --git a/run-make-check.sh b/run-make-check.sh index 2763af0456957..4a022fec982bc 100755 --- a/run-make-check.sh +++ b/run-make-check.sh @@ -54,7 +54,7 @@ function main() { fi FOR_MAKE_CHECK=1 prepare # Init defaults after deps are installed. - configure "-DWITH_GTEST_PARALLEL=ON -DWITH_FIO=ON -DWITH_SEASTAR=ON -DWITH_CEPHFS_SHELL=ON -DWITH_SPDK=ON -DENABLE_GIT_VERSION=OFF $@" + configure " -DWITH_PYTHON3=3 -DWITH_GTEST_PARALLEL=ON -DWITH_FIO=ON -DWITH_SEASTAR=ON -DWITH_CEPHFS_SHELL=ON -DWITH_SPDK=ON -DENABLE_GIT_VERSION=OFF $@" build tests && echo "make check: successful run on $(git rev-parse HEAD)" run } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 08c9b094c7057..bb22331d38e1b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -218,42 +218,9 @@ if(WITH_CEPHFS_JAVA) endif() # Python stuff -option(WITH_PYTHON2 "build python2 bindings" ON) +option(WITH_PYTHON2 "build python2 bindings" OFF) if(WITH_PYTHON2) - find_package(Python2 REQUIRED - COMPONENTS Interpreter Development) -endif() - -set(WITH_PYTHON3 "OFF" CACHE STRING "build python3 bindings with specified python3 version") -if(WITH_PYTHON3) - if(WITH_PYTHON3 MATCHES "^(1|ON|YES|TRUE|Y)$") - set(WITH_PYTHON3 "3") - endif() - if(NOT WITH_PYTHON3 STREQUAL "3") - set(find_python3_exact "EXACT") - endif() - find_package(Python3 ${WITH_PYTHON3} ${find_python3_exact} REQUIRED - COMPONENTS Interpreter Development) - unset(find_python3_exact) -endif() - -# the major version of the python bindings as a dependency of other -# targets -if(WITH_PYTHON2) - set(PY_BINDING_INFIX 2) -else() - set(PY_BINDING_INFIX 3) -endif() -# use python2 by default for python bindings, tools and tests, before -# switching to python3 -# Python_EXECUTABLE` can be set by `find_package(Python ...)` also. and we do -# call `find_package(Python ...)` in `ceph/CMakeLists.txt`. but we do so before -# `add_subdirectory(src)` where `Python_EXECUTABLE` is set. so it's safe to -# use this variable name and call `find_package(Python ...)`. -if(WITH_PYTHON2) - set(Python_EXECUTABLE ${Python2_EXECUTABLE}) -else() - set(Python_EXECUTABLE ${Python3_EXECUTABLE}) + message(FATAL_ERROR "Python 2 is not supported anymore") endif() # sort out which allocator to use @@ -787,17 +754,17 @@ add_custom_target(vstart-base DEPENDS monmaptool crushtool rados - cython${PY_BINDING_INFIX}_rados) + cython_rados) if (WITH_MGR) add_dependencies(vstart-base ceph-mgr) endif() add_custom_target(vstart DEPENDS vstart-base) -if (WITH_RBD) - add_dependencies(vstart cython${PY_BINDING_INFIX}_rbd) +if(WITH_RBD) + add_dependencies(vstart cython_rbd) endif() if (WITH_CEPHFS) - add_dependencies(vstart ceph-mds cephfs cython${PY_BINDING_INFIX}_cephfs) + add_dependencies(vstart ceph-mds cephfs cython_cephfs) endif() if(WITH_RADOSGW) add_dependencies(vstart radosgw radosgw-admin) @@ -819,7 +786,7 @@ endif() add_custom_target(cephfs_testing DEPENDS vstart rados - cython${PY_BINDING_INFIX}_modules + cython_modules cephfs cls_cephfs ceph-fuse diff --git a/src/ceph-crash.in b/src/ceph-crash.in index 21f83c81defe9..587f40b76a6af 100755 --- a/src/ceph-crash.in +++ b/src/ceph-crash.in @@ -1,4 +1,4 @@ -#!@Python_EXECUTABLE@ +#!@Python3_EXECUTABLE@ # -*- mode:python -*- # vim: ts=4 sw=4 smarttab expandtab diff --git a/src/ceph-volume/CMakeLists.txt b/src/ceph-volume/CMakeLists.txt index d1217a915c85f..4224499c47498 100644 --- a/src/ceph-volume/CMakeLists.txt +++ b/src/ceph-volume/CMakeLists.txt @@ -1,15 +1,8 @@ include(Distutils) -if(WITH_PYTHON2) - set(python_version_major 2) -else() - set(python_version_major 3) -endif() - distutils_install_module(ceph_volume - INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR} - PYTHON_VERSION ${python_version_major}) + INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR}) if(FREEBSD) add_subdirectory(plugin/zfs) diff --git a/src/ceph-volume/plugin/zfs/CMakeLists.txt b/src/ceph-volume/plugin/zfs/CMakeLists.txt index cafb7382e77ae..da10f46fd09ad 100644 --- a/src/ceph-volume/plugin/zfs/CMakeLists.txt +++ b/src/ceph-volume/plugin/zfs/CMakeLists.txt @@ -1,4 +1,3 @@ distutils_install_module(ceph_volume_zfs - INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR} - PYTHON_VERSION ${python_version}) + INSTALL_SCRIPT ${CMAKE_INSTALL_FULL_SBINDIR}) diff --git a/src/ceph.in b/src/ceph.in index 70119d50a0446..0da8aa1e81eb7 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -1,4 +1,4 @@ -#!@Python_EXECUTABLE@ +#!@Python3_EXECUTABLE@ # -*- mode:python -*- # vim: ts=4 sw=4 smarttab expandtab # @@ -66,7 +66,7 @@ DEVMODEMSG = '*** DEVELOPER MODE: setting PATH, PYTHONPATH and LD_LIBRARY_PATH * def respawn_in_path(lib_path, pybind_path, pythonlib_path, asan_lib_path): execv_cmd = [] if 'CEPH_DBG' in os.environ: - execv_cmd += ['@Python_EXECUTABLE@', '-mpdb'] + execv_cmd += ['@Python3_EXECUTABLE@', '-mpdb'] if platform.system() == "Darwin": lib_path_var = "DYLD_LIBRARY_PATH" diff --git a/src/mgr/CMakeLists.txt b/src/mgr/CMakeLists.txt index 101db6ed88956..f6f9e73d433d9 100644 --- a/src/mgr/CMakeLists.txt +++ b/src/mgr/CMakeLists.txt @@ -30,12 +30,11 @@ if(WITH_MGR) mgr_commands.cc $) add_executable(ceph-mgr ${mgr_srcs}) - target_include_directories(ceph-mgr SYSTEM PRIVATE "${Python_INCLUDE_DIRS}") target_link_libraries(ceph-mgr osdc client heap_profiler global-static ceph-common Boost::python${MGR_PYTHON_VERSION_MAJOR}${MGR_PYTHON_VERSION_MINOR} - ${MGR_PYTHON_LIBRARIES} ${CMAKE_DL_LIBS} ${GSSAPI_LIBRARIES}) + Python3::Python ${CMAKE_DL_LIBS} ${GSSAPI_LIBRARIES}) set_target_properties(ceph-mgr PROPERTIES POSITION_INDEPENDENT_CODE ${EXE_LINKER_USE_PIE}) install(TARGETS ceph-mgr DESTINATION bin) diff --git a/src/pybind/CMakeLists.txt b/src/pybind/CMakeLists.txt index 83496953b3098..86fcc6becade7 100644 --- a/src/pybind/CMakeLists.txt +++ b/src/pybind/CMakeLists.txt @@ -2,70 +2,49 @@ include(Distutils) set(CYTHON_MODULE_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cython_modules) -# Keep the default version last -if(WITH_PYTHON3) - list(APPEND py_vers 3) +find_package(Cython REQUIRED) + +add_subdirectory(rados) +add_custom_target(cython_modules ALL + DEPENDS cython_rados) + +if(WITH_RBD) + add_subdirectory(rbd) + add_dependencies(cython_modules cython_rbd) endif() -if(WITH_PYTHON2) - list(APPEND py_vers 2) +if(WITH_CEPHFS) + add_subdirectory(cephfs) + add_dependencies(cython_modules cython_cephfs) endif() -if(NOT py_vers) - message(FATAL_ERROR "No Python binding enabled. Please enable WITH_PYTHON2 and/or WITH_PYTHON3.") +if(WITH_RADOSGW) + add_subdirectory(rgw) + add_dependencies(cython_modules cython_rgw) endif() -foreach(python_version ${py_vers}) - set(PYTHON_VERSION ${python_version}) - - find_package(Cython REQUIRED) - - add_subdirectory(rados rados${PYTHON_VERSION}) - add_custom_target(cython${PYTHON_VERSION}_modules ALL - DEPENDS cython${PYTHON_VERSION}_rados) - - if(WITH_RBD) - add_subdirectory(rbd rbd${PYTHON_VERSION}) - add_dependencies(cython${PYTHON_VERSION}_modules cython${PYTHON_VERSION}_rbd) - endif() - if(WITH_CEPHFS) - add_subdirectory(cephfs cephfs${PYTHON_VERSION}) - add_dependencies(cython${PYTHON_VERSION}_modules cython${PYTHON_VERSION}_cephfs) - endif() - if(WITH_RADOSGW) - add_subdirectory(rgw rgw${PYTHON_VERSION}) - add_dependencies(cython${PYTHON_VERSION}_modules cython${PYTHON_VERSION}_rgw) - endif() - - # if CMAKE_INSTALL_PREFIX is an empty string, must replace - # it with "/" to make PYTHON_INSTALL_TEMPLATE an absolute path to be - # consistent with all other installation paths. - if(CMAKE_INSTALL_PREFIX) - set(PYTHON_INSTALL_TEMPLATE "${CMAKE_INSTALL_PREFIX}") - else(CMAKE_INSTALL_PREFIX) - set(PYTHON_INSTALL_TEMPLATE "/") - endif(CMAKE_INSTALL_PREFIX) +# if CMAKE_INSTALL_PREFIX is an empty string, must replace +# it with "/" to make PYTHON_INSTALL_TEMPLATE an absolute path to be +# consistent with all other installation paths. +if(CMAKE_INSTALL_PREFIX) + set(PYTHON_INSTALL_TEMPLATE "${CMAKE_INSTALL_PREFIX}") +else(CMAKE_INSTALL_PREFIX) + set(PYTHON_INSTALL_TEMPLATE "/") +endif(CMAKE_INSTALL_PREFIX) - execute_process( - COMMAND - ${Python${PYTHON_VERSION}_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='${PYTHON_INSTALL_TEMPLATE}'))" - OUTPUT_VARIABLE "PYTHON${PYTHON_VERSION}_INSTDIR" - OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND + ${Python3_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(prefix='${PYTHON_INSTALL_TEMPLATE}'))" + OUTPUT_VARIABLE "PYTHON3_INSTDIR" + OUTPUT_STRIP_TRAILING_WHITESPACE) - install(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/ceph_argparse.py - ${CMAKE_CURRENT_SOURCE_DIR}/ceph_daemon.py - ${CMAKE_CURRENT_SOURCE_DIR}/ceph_volume_client.py - DESTINATION ${PYTHON${PYTHON_VERSION}_INSTDIR}) -endforeach() +install(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/ceph_argparse.py + ${CMAKE_CURRENT_SOURCE_DIR}/ceph_daemon.py + ${CMAKE_CURRENT_SOURCE_DIR}/ceph_volume_client.py + DESTINATION ${PYTHON3_INSTDIR}) if(WITH_MGR) - if(NOT WITH_PYTHON2 AND MGR_PYTHON_VERSION_MAJOR EQUAL 2) - message(FATAL_ERROR "mgr plugins require python2 binding") - elseif(NOT WITH_PYTHON3 AND MGR_PYTHON_VERSION_MAJOR EQUAL 3) - message(FATAL_ERROR "mgr plugins require python3 binding") - endif() - execute_process( - COMMAND ${Python${PYTHON_VERSION}_EXECUTABLE} -c "import ssl; print('.'.join(map(str,ssl.OPENSSL_VERSION_INFO[0:3])))" + COMMAND ${Python3_EXECUTABLE} -c "import ssl; print('.'.join(map(str,ssl.OPENSSL_VERSION_INFO[0:3])))" RESULT_VARIABLE PYSSL_RESULT OUTPUT_VARIABLE PYSSL_VER ERROR_QUIET) diff --git a/src/pybind/cephfs/CMakeLists.txt b/src/pybind/cephfs/CMakeLists.txt index 61cf8b4a9ff3c..bd1ed3d55160c 100644 --- a/src/pybind/cephfs/CMakeLists.txt +++ b/src/pybind/cephfs/CMakeLists.txt @@ -1,7 +1,5 @@ -distutils_add_cython_module(cython${PYTHON_VERSION}_cephfs +distutils_add_cython_module(cython_cephfs cephfs - ${CMAKE_CURRENT_SOURCE_DIR}/cephfs.pyx - ${PYTHON_VERSION}) -add_dependencies(cython${PYTHON_VERSION}_cephfs cephfs) -distutils_install_cython_module(cython${PYTHON_VERSION}_cephfs - ${PYTHON_VERSION}) + ${CMAKE_CURRENT_SOURCE_DIR}/cephfs.pyx) +add_dependencies(cython_cephfs cephfs) +distutils_install_cython_module(cython_cephfs) diff --git a/src/pybind/mgr/dashboard/HACKING.rst b/src/pybind/mgr/dashboard/HACKING.rst index da41e8c17b4a4..c567f4c545bdd 100644 --- a/src/pybind/mgr/dashboard/HACKING.rst +++ b/src/pybind/mgr/dashboard/HACKING.rst @@ -741,7 +741,7 @@ To run the tests, run ``src/script/run_tox.sh`` in the dashboard directory (wher $ ../../../script/run_tox.sh --tox-env py3,lint,check ## Run Python 3 arbitrary command (e.g. 1 single test): - $ WITH_PYTHON2=OFF ../../../script/run_tox.sh --tox-env py3 "" tests/test_rgw_client.py::RgwClientTest::test_ssl_verify + $ ../../../script/run_tox.sh --tox-env py3 "" tests/test_rgw_client.py::RgwClientTest::test_ssl_verify You can also run tox instead of ``run_tox.sh``:: diff --git a/src/pybind/rados/CMakeLists.txt b/src/pybind/rados/CMakeLists.txt index b16d3513b55b0..0cd19d0317459 100644 --- a/src/pybind/rados/CMakeLists.txt +++ b/src/pybind/rados/CMakeLists.txt @@ -1,7 +1,5 @@ -distutils_add_cython_module(cython${PYTHON_VERSION}_rados +distutils_add_cython_module(cython_rados rados - ${CMAKE_CURRENT_SOURCE_DIR}/rados.pyx - ${PYTHON_VERSION}) -add_dependencies(cython${PYTHON_VERSION}_rados rados) -distutils_install_cython_module(cython${PYTHON_VERSION}_rados - ${PYTHON_VERSION}) + ${CMAKE_CURRENT_SOURCE_DIR}/rados.pyx) +add_dependencies(cython_rados rados) +distutils_install_cython_module(cython_rados) diff --git a/src/pybind/rbd/CMakeLists.txt b/src/pybind/rbd/CMakeLists.txt index f7d3bb4deb96e..93123234ca8bb 100644 --- a/src/pybind/rbd/CMakeLists.txt +++ b/src/pybind/rbd/CMakeLists.txt @@ -1,7 +1,5 @@ -distutils_add_cython_module(cython${PYTHON_VERSION}_rbd +distutils_add_cython_module(cython_rbd rbd - ${CMAKE_CURRENT_SOURCE_DIR}/rbd.pyx - ${PYTHON_VERSION}) -add_dependencies(cython${PYTHON_VERSION}_rbd librbd) -distutils_install_cython_module(cython${PYTHON_VERSION}_rbd - ${PYTHON_VERSION}) + ${CMAKE_CURRENT_SOURCE_DIR}/rbd.pyx) +add_dependencies(cython_rbd librbd) +distutils_install_cython_module(cython_rbd) diff --git a/src/python-common/CMakeLists.txt b/src/python-common/CMakeLists.txt index 01d3bc582b3d5..e2a248e375d21 100644 --- a/src/python-common/CMakeLists.txt +++ b/src/python-common/CMakeLists.txt @@ -1,15 +1,5 @@ -if(WITH_PYTHON3) - list(APPEND py_vers 3) -endif() -if(WITH_PYTHON2) - list(APPEND py_vers 2) -endif() - include(Distutils) -foreach(python_version ${py_vers}) - distutils_install_module(ceph - PYTHON_VERSION ${python_version}) -endforeach() +distutils_install_module(ceph) if(WITH_TESTS) include(AddCephTest) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index 49bd36dbb446e..b19c73da73902 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -509,7 +509,7 @@ add_dependencies(tests ceph_test_objectstore ceph_erasure_code_non_regression ceph_erasure_code - cython${PY_BINDING_INFIX}_modules) + cython_modules) if (WITH_CEPHFS) add_dependencies(tests ceph-mds) endif() diff --git a/src/tools/cephfs/CMakeLists.txt b/src/tools/cephfs/CMakeLists.txt index d934ea4149108..f980f35f5ff1d 100644 --- a/src/tools/cephfs/CMakeLists.txt +++ b/src/tools/cephfs/CMakeLists.txt @@ -44,8 +44,7 @@ if(WITH_CEPHFS_SHELL) message(WARNING "Please enable WITH_PYTHON3 for cephfs-shell") else() include(Distutils) - distutils_install_module(cephfs-shell - PYTHON_VERSION 3) + distutils_install_module(cephfs-shell) endif() if(WITH_TESTS) include(AddCephTest)