From 625d4fc8843435a505adeec752d5f17e1c153cef Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 5 Mar 2021 12:54:51 +0000 Subject: [PATCH] cmake: update Python linters handling - exclude from getBuildInformation() - fix pylint version --- CMakeLists.txt | 12 ++++++------ cmake/FindPylint.cmake | 2 +- cmake/OpenCVPylint.cmake | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65933cdeef..f6a2da5310 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1000,6 +1000,12 @@ if(COMMAND ocv_pylint_finalize) ocv_pylint_add_directory_recurse(${CMAKE_CURRENT_LIST_DIR}/samples/python/tutorial_code) ocv_pylint_finalize() endif() +if(TARGET check_pylint) + message(STATUS "Registered 'check_pylint' target: using ${PYLINT_EXECUTABLE} (ver: ${PYLINT_VERSION}), checks: ${PYLINT_TOTAL_TARGETS}") +endif() +if(TARGET check_flake8) + message(STATUS "Registered 'check_flake8' target: using ${FLAKE8_EXECUTABLE} (ver: ${FLAKE8_VERSION})") +endif() if(OPENCV_GENERATE_SETUPVARS) include(cmake/OpenCVGenSetupVars.cmake) @@ -1633,12 +1639,6 @@ endif() status("") status(" Python (for build):" PYTHON_DEFAULT_AVAILABLE THEN "${PYTHON_DEFAULT_EXECUTABLE}" ELSE NO) -if(PYLINT_FOUND AND PYLINT_EXECUTABLE) - status(" Pylint:" PYLINT_FOUND THEN "${PYLINT_EXECUTABLE} (ver: ${PYLINT_VERSION}, checks: ${PYLINT_TOTAL_TARGETS})" ELSE NO) -endif() -if(FLAKE8_FOUND AND FLAKE8_EXECUTABLE) - status(" Flake8:" FLAKE8_FOUND THEN "${FLAKE8_EXECUTABLE} (ver: ${FLAKE8_VERSION})" ELSE NO) -endif() # ========================== java ========================== if(BUILD_JAVA) diff --git a/cmake/FindPylint.cmake b/cmake/FindPylint.cmake index 5731ba493a..ef4b4394ff 100644 --- a/cmake/FindPylint.cmake +++ b/cmake/FindPylint.cmake @@ -16,7 +16,7 @@ if(PYLINT_EXECUTABLE AND NOT DEFINED PYLINT_VERSION) execute_process(COMMAND ${PYLINT_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE PYLINT_VERSION_RAW) if(NOT _result EQUAL 0) ocv_clear_vars(PYLINT_EXECUTABLE PYLINT_VERSION) - elseif(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])") + elseif(PYLINT_VERSION_RAW MATCHES "pylint([^,\n]*) ([0-9\\.]+[0-9])") set(PYLINT_VERSION "${CMAKE_MATCH_2}") else() set(PYLINT_VERSION "unknown") diff --git a/cmake/OpenCVPylint.cmake b/cmake/OpenCVPylint.cmake index 50da730946..928926d340 100644 --- a/cmake/OpenCVPylint.cmake +++ b/cmake/OpenCVPylint.cmake @@ -122,7 +122,6 @@ function(ocv_pylint_finalize) list(LENGTH PYLINT_TARGET_ID __total) set(PYLINT_TOTAL_TARGETS "${__total}" CACHE INTERNAL "") - message(STATUS "Pylint: registered ${__total} targets. Build 'check_pylint' target to run checks (\"cmake --build . --target check_pylint\" or \"make check_pylint\")") configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/pylint.cmake.in" "${CMAKE_BINARY_DIR}/pylint.cmake" @ONLY) add_custom_target(check_pylint