mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
cmake: fix pylint/flake8 detection, update flake8 exclude
This commit is contained in:
parent
ebd91459f2
commit
e448f4f6ef
@ -727,8 +727,15 @@ if(ENABLE_FLAKE8 AND PYTHON_DEFAULT_AVAILABLE)
|
|||||||
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlake8.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlake8.cmake")
|
||||||
endif()
|
endif()
|
||||||
if(FLAKE8_FOUND)
|
if(FLAKE8_FOUND)
|
||||||
|
list(APPEND OPENCV_FLAKE8_EXCLUDES ".git" "__pycache__" "config.py" "*.config.py" "config-*.py")
|
||||||
|
list(APPEND OPENCV_FLAKE8_EXCLUDES "svgfig.py") # 3rdparty
|
||||||
|
if(NOT PYTHON3_VERSION_STRING VERSION_GREATER 3.6)
|
||||||
|
# Python 3.6+ (PEP 526): variable annotations (type hints)
|
||||||
|
list(APPEND OPENCV_FLAKE8_EXCLUDES "samples/dnn/dnn_model_runner/dnn_conversion/common/test/configs")
|
||||||
|
endif()
|
||||||
|
string(REPLACE ";" "," OPENCV_FLAKE8_EXCLUDES_STR "${OPENCV_FLAKE8_EXCLUDES}")
|
||||||
add_custom_target(check_flake8
|
add_custom_target(check_flake8
|
||||||
COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='.git,__pycache__,*.config.py,svgfig.py'
|
COMMAND "${FLAKE8_EXECUTABLE}" . --count --select=E9,E901,E999,F821,F822,F823 --show-source --statistics --exclude='${OPENCV_FLAKE8_EXCLUDES_STR}'
|
||||||
WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
|
WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
|
||||||
COMMENT "Running flake8"
|
COMMENT "Running flake8"
|
||||||
)
|
)
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
|
|
||||||
find_host_program(FLAKE8_EXECUTABLE flake8 PATHS /usr/bin)
|
find_host_program(FLAKE8_EXECUTABLE flake8 PATHS /usr/bin)
|
||||||
|
|
||||||
if(FLAKE8_EXECUTABLE)
|
if(FLAKE8_EXECUTABLE AND NOT DEFINED FLAKE8_VERSION)
|
||||||
execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version OUTPUT_VARIABLE FLAKE8_VERSION_RAW ERROR_QUIET)
|
execute_process(COMMAND ${FLAKE8_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE FLAKE8_VERSION_RAW)
|
||||||
if(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])")
|
if(NOT _result EQUAL 0)
|
||||||
|
ocv_clear_vars(FLAKE8_EXECUTABLE FLAKE8_VERSION)
|
||||||
|
elseif(FLAKE8_VERSION_RAW MATCHES "^([0-9\\.]+[0-9])")
|
||||||
set(FLAKE8_VERSION "${CMAKE_MATCH_1}")
|
set(FLAKE8_VERSION "${CMAKE_MATCH_1}")
|
||||||
else()
|
else()
|
||||||
set(FLAKE8_VERSION "unknown")
|
set(FLAKE8_VERSION "unknown")
|
||||||
@ -22,6 +24,9 @@ if(FLAKE8_EXECUTABLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8 DEFAULT_MSG FLAKE8_EXECUTABLE)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Flake8
|
||||||
|
REQUIRED_VARS FLAKE8_EXECUTABLE
|
||||||
|
VERSION_VAR FLAKE8_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
mark_as_advanced(FLAKE8_EXECUTABLE FLAKE8_VERSION)
|
mark_as_advanced(FLAKE8_EXECUTABLE FLAKE8_VERSION)
|
||||||
|
@ -12,9 +12,11 @@
|
|||||||
|
|
||||||
find_host_program(PYLINT_EXECUTABLE pylint PATHS /usr/bin)
|
find_host_program(PYLINT_EXECUTABLE pylint PATHS /usr/bin)
|
||||||
|
|
||||||
if(PYLINT_EXECUTABLE)
|
if(PYLINT_EXECUTABLE AND NOT DEFINED PYLINT_VERSION)
|
||||||
execute_process(COMMAND ${PYLINT_EXECUTABLE} --version OUTPUT_VARIABLE PYLINT_VERSION_RAW ERROR_QUIET)
|
execute_process(COMMAND ${PYLINT_EXECUTABLE} --version RESULT_VARIABLE _result OUTPUT_VARIABLE PYLINT_VERSION_RAW)
|
||||||
if(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])")
|
if(NOT _result EQUAL 0)
|
||||||
|
ocv_clear_vars(PYLINT_EXECUTABLE PYLINT_VERSION)
|
||||||
|
elseif(PYLINT_VERSION_RAW MATCHES "pylint([^,]*) ([0-9\\.]+[0-9])")
|
||||||
set(PYLINT_VERSION "${CMAKE_MATCH_2}")
|
set(PYLINT_VERSION "${CMAKE_MATCH_2}")
|
||||||
else()
|
else()
|
||||||
set(PYLINT_VERSION "unknown")
|
set(PYLINT_VERSION "unknown")
|
||||||
@ -22,6 +24,9 @@ if(PYLINT_EXECUTABLE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint DEFAULT_MSG PYLINT_EXECUTABLE)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pylint
|
||||||
|
REQUIRED_VARS PYLINT_EXECUTABLE
|
||||||
|
VERSION_VAR PYLINT_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
mark_as_advanced(PYLINT_EXECUTABLE PYLINT_VERSION)
|
mark_as_advanced(PYLINT_EXECUTABLE PYLINT_VERSION)
|
||||||
|
Loading…
Reference in New Issue
Block a user