onnxruntime/cmake/flake8.cmake
Changming Sun b854f2399d
Update manylinux build scripts and GPU CUDA version from 11.0 to 11.1 (#7632)
1. Update manylinux build scripts. This will add [PEP600](https://www.python.org/dev/peps/pep-0600/)(manylinux2 tags) support. numpy has adopted this new feature, we should do the same. The old build script files were copied from https://github.com/pypa/manylinux, but they has been deleted and replaced in the upstream repo. The manylinux repo doesn't have a manylinux2014 branch anymore. So I'm removing the obsolete code, sync the files with the latest master.
2. Update GPU CUDA version from 11.0 to 11.1(after a discussion with PMs). 
3. Delete tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cuda10_2.  (Merged the content to tools/ci_build/github/linux/docker/Dockerfile.manylinux2014_cuda11)
4. Modernize the cmake code of how to locate python devel files. It was suggested in https://github.com/onnx/onnx/pull/1631 .
5. Remove `onnxruntime_MSVC_STATIC_RUNTIME` and `onnxruntime_GCC_STATIC_CPP_RUNTIME` build options. Now cmake has builtin support for it. Starting from cmake 3.15, we can use `CMAKE_MSVC_RUNTIME_LIBRARY` cmake variable to choose which MSVC runtime library we want to use. 
6. Update Ubuntu docker images that used in our CI build from Ubuntu 18.04 to Ubuntu 20.04.
7. Update GCC version in CUDA 11.1 pipelines from 8.x to 9.3.1
8. Split Linux GPU CI pipeline to two jobs: build the code on a CPU machine then run the tests on another GPU machines.  In the past we didn't test our python packages. We only tested the pre-packed files. So we didn't catch the rpath issue in CI build. 
9. Add a CentOS machine pool and test our Linux GPU build on real CentOS machines. 
10. Rework ARM64 Linux GPU python packaging pipeline. Previously it uses cross-compiling therefore we must static link to C Runtime. But now have pluggable EP API and it doesn't support static link. So I changed to use qemu emulation instead. Now the build is 10x slower than before. But it is more extensible.
2021-06-02 23:36:49 -07:00

76 lines
3 KiB
CMake

#
# Setup running flake8 on python scripts to enforce PEP8
# NOTE: Currently skips the check if flake8 is not installed. PRs editing python scripts are rare
# so don't want to add a hard dependency on flake8 to all builds.
#
find_program(flake8_BIN NAMES flake8)
if(flake8_BIN)
exec_program(${flake8_BIN} ARGS "--version" OUTPUT_VARIABLE FLAKE8_VERSION)
else()
# see if we can run the python module instead if there's no executable
set(FLAKE8_NOT_FOUND false)
exec_program("${Python_EXECUTABLE}"
ARGS "-m flake8 --version"
OUTPUT_VARIABLE FLAKE8_VERSION
RETURN_VALUE FLAKE8_NOT_FOUND)
if(${FLAKE8_NOT_FOUND})
message(WARNING "Could not find 'flake8' to check python scripts. Please install flake8 using pip.")
else()
set(flake8_BIN ${Python_EXECUTABLE} "-m" "flake8")
endif(${FLAKE8_NOT_FOUND})
endif()
if(flake8_BIN)
# check flake8 version
string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.([0-9])+" _flake8_ver_check "${FLAKE8_VERSION}")
if(NOT "${_flake8_ver_check}" STREQUAL "")
set(FLAKE8_VERSION_MAJOR ${CMAKE_MATCH_1})
set(FLAKE8_VERSION_MINOR ${CMAKE_MATCH_2})
else()
set(FLAKE8_VERSION_MAJOR 0)
set(FLAKE8_VERSION_MINOR 0)
endif()
math(EXPR FLAKE8_VERSION_DECIMAL "(${FLAKE8_VERSION_MAJOR} * 100) + ${FLAKE8_VERSION_MINOR}")
# require minimum version that we've tested with (3.8)
if (${FLAKE8_VERSION_DECIMAL} GREATER_EQUAL 308)
# need to exclude a subset of scripts from ${ONNXRUNTIME_ROOT} so create a complete
# list and then filter it
file(GLOB_RECURSE python_scripts CONFIGURE_DEPENDS
"${ONNXRUNTIME_ROOT}/*.py"
)
# generated flatbuffer schema files
list(FILTER python_scripts EXCLUDE REGEX "onnxruntime/core/flatbuffers/ort_flatbuffers_py")
# scripts in these directories still need updating
list(FILTER python_scripts EXCLUDE REGEX "onnxruntime/core/providers/nuphar")
list(FILTER python_scripts EXCLUDE REGEX "onnxruntime/python/tools")
list(FILTER python_scripts EXCLUDE REGEX "onnxruntime/test")
# can just add the 'tools' directory and flake8 will recurse into it
list(APPEND python_scripts ${REPO_ROOT}/tools/)
# Training scripts need updating to make PEP8 compliant.
# file(GLOB_RECURSE training_scripts CONFIGURE_DEPENDS
# "${ORTTRAINING_ROOT}/*.py"
# )
source_group(TREE ${REPO_ROOT} FILES ${python_scripts})
add_custom_target(pep8_check
ALL
DEPENDS ${python_scripts}
WORKING_DIRECTORY
COMMAND echo "Checking python scripts for PEP8 conformance using flake8"
#MESSAGE(${python_scripts})
COMMAND ${flake8_BIN} "--config" "${REPO_ROOT}/.flake8" ${python_scripts}
VERBATIM
)
else()
message(WARNING "'flake8' version is too old. Requires 3.8 or later. Found ${FLAKE8_VERSION}")
endif()
endif()