-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/deprecation-function
- Loading branch information
Showing
276 changed files
with
5,745 additions
and
3,629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# Copyright (C) 2018-2022 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
# | ||
# ov_check_pip_package(REQUIREMENT <single requirement> | ||
# RESULT_VAR <result var name> | ||
# [WARNING_MESSAGE <message>] | ||
# [MESSAGE_MODE <WARNING | FATAL_ERROR | TRACE>]) | ||
# | ||
function(ov_check_pip_package) | ||
find_package(PythonInterp 3 QUIET) | ||
|
||
set(oneValueOptionalArgs | ||
MESSAGE_MODE # Set the type of message: { FATAL_ERROR | WARNING | ... } | ||
WARNING_MESSAGE # callback message | ||
) | ||
set(oneValueRequiredArgs | ||
REQUIREMENT # Requirement-specifier to check | ||
RESULT_VAR # Result varibale to set return code {ON | OFF} | ||
) | ||
set(multiValueArgs) | ||
|
||
cmake_parse_arguments(ARG "" "${oneValueRequiredArgs};${oneValueOptionalArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
foreach(argName ${oneValueRequiredArgs}) | ||
if (NOT ARG_${argName}) | ||
message(SEND_ERROR "Argument '${argName}' is required.") | ||
endif() | ||
endforeach() | ||
|
||
if(NOT ARG_MESSAGE_MODE) | ||
set(ARG_MESSAGE_MODE WARNING) | ||
elseif(CMAKE_VERSION VERSION_LESS 3.15 AND ARG_MESSAGE_MODE STREQUAL "TRACE") | ||
set(ARG_MESSAGE_MODE WARNING) | ||
endif() | ||
|
||
if(ARG_UNPARSED_ARGUMENTS) | ||
message(SEND_ERROR "Unexpected parameters have passed to the function: ${ARG_UNPARSED_ARGUMENTS}") | ||
endif() | ||
|
||
# quote '3.x' with \'3.x\' | ||
string(REPLACE "'" "\\'" REQ "${ARG_REQUIREMENT}") | ||
|
||
if(PYTHONINTERP_FOUND) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -c "import pkg_resources ; pkg_resources.require('${REQ}')" | ||
RESULT_VARIABLE EXIT_CODE | ||
OUTPUT_VARIABLE OUTPUT_TEXT | ||
ERROR_VARIABLE ERROR_TEXT) | ||
endif() | ||
|
||
if(NOT EXIT_CODE EQUAL 0) | ||
set(${ARG_RESULT_VAR} OFF PARENT_SCOPE) | ||
message(${ARG_MESSAGE_MODE} "Python module '${REQ}' is missed, ${ARG_WARNING_MESSAGE}") | ||
else() | ||
set(${ARG_RESULT_VAR} ON PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
# | ||
# ov_check_pip_packages(REQUIREMENTS_FILE <requirements.txt file> | ||
# RESULT_VAR <result var name> | ||
# [WARNING_MESSAGE <message>] | ||
# [MESSAGE_MODE <WARNING | FATAL_ERROR | TRACE>]) | ||
# | ||
function(ov_check_pip_packages) | ||
find_package(PythonInterp 3 QUIET) | ||
|
||
set(oneValueOptionalArgs | ||
MESSAGE_MODE # Set the type of message: { FATAL_ERROR | WARNING | ... } | ||
WARNING_MESSAGE # callback message | ||
) | ||
set(oneValueRequiredArgs | ||
REQUIREMENTS_FILE # File with requirement-specifiers to check | ||
RESULT_VAR # Result varibale to set return code {ON | OFF} | ||
) | ||
set(multiValueArgs) | ||
|
||
cmake_parse_arguments(ARG "" "${oneValueOptionalArgs};${oneValueRequiredArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
foreach(argName ${oneValueRequiredArgs}) | ||
if (NOT ARG_${argName}) | ||
message(SEND_ERROR "Argument '${argName}' is required.") | ||
endif() | ||
endforeach() | ||
|
||
if(NOT ARG_MESSAGE_MODE) | ||
set(ARG_MESSAGE_MODE WARNING) | ||
elseif(CMAKE_VERSION VERSION_LESS 3.15 AND ARG_MESSAGE_MODE STREQUAL "TRACE") | ||
set(ARG_MESSAGE_MODE WARNING) | ||
endif() | ||
|
||
if(ARG_UNPARSED_ARGUMENTS) | ||
message(SEND_ERROR "Unexpected parameters have passed to the function: ${ARG_UNPARSED_ARGUMENTS}") | ||
endif() | ||
|
||
if(PYTHONINTERP_FOUND) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} -c "import pkg_resources ; pkg_resources.require(open('${ARG_REQUIREMENTS_FILE}', mode='r'))" | ||
RESULT_VARIABLE EXIT_CODE | ||
OUTPUT_VARIABLE OUTPUT_TEXT | ||
ERROR_VARIABLE ERROR_TEXT) | ||
endif() | ||
|
||
if(NOT EXIT_CODE EQUAL 0) | ||
set(${ARG_RESULT_VAR} OFF PARENT_SCOPE) | ||
message(${ARG_MESSAGE_MODE} "Python requirement file ${ARG_REQUIREMENTS_FILE} is not installed, ${ARG_WARNING_MESSAGE}") | ||
else() | ||
set(${ARG_RESULT_VAR} ON PARENT_SCOPE) | ||
endif() | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.