Port 2022 3 (#16611)

* Fixed typo in core tests (#16235)

* More accurate hwloc finding in case of dynamic tbbbind (#16488)

* [INSTALL] Fix setupvars (installation for MacOS) and build python  (#16514)

* Fix installation + Python build on MacOS

* Update setupvars.sh

* Update setupvars.sh

* Revert

* revert

* Update scripts/setupvars/setupvars.sh

---------

Co-authored-by: Ilya Lavrenov <ilya.lavrenov@intel.com>

---------

Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
Co-authored-by: Irina Efode <irina.efode@intel.com>
This commit is contained in:
Ilya Lavrenov
2023-03-29 13:58:22 +04:00
committed by GitHub
parent 3e950a52f7
commit 7d28ed499a
6 changed files with 100 additions and 61 deletions

View File

@@ -363,6 +363,8 @@ else()
endif()
endif()
check_cxx_compiler_flag("-Wunused-but-set-variable" UNUSED_BUT_SET_VARIABLE_SUPPORTED)
# Links provided libraries and include their INTERFACE_INCLUDE_DIRECTORIES as SYSTEM
function(link_system_libraries TARGET_NAME)
set(MODE PRIVATE)

View File

@@ -4,12 +4,12 @@
# SPDX-License-Identifier: Apache-2.0
abs_path () {
path=$(eval echo "$1")
directory=$(dirname "$path")
echo "$(cd "$directory" || exit; pwd -P)/$(basename "$path")";
script_path=$(eval echo "$1")
directory=$(dirname "$script_path")
echo "$(cd "$directory" || exit; pwd -P)";
}
SCRIPT_DIR="$( cd "$( dirname "$(abs_path "${BASH_SOURCE[0]}")" )" >/dev/null 2>&1 && pwd )"
SCRIPT_DIR="$(abs_path "${BASH_SOURCE[0]}")" >/dev/null 2>&1
INSTALLDIR="${SCRIPT_DIR}"
export INTEL_OPENVINO_DIR="$INSTALLDIR"
@@ -128,7 +128,12 @@ check_python_version () {
"${PYTHON_VERSION_MAJOR}.${MAX_SUPPORTED_PYTHON_VERSION_MINOR} (64-bit) from https://www.python.org/downloads/"
return 0
fi
python_bitness=$(python"$python_version" -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
if command -v python"$python_version" > /dev/null 2>&1; then
python_interp=python"$python_version"
else
python_interp=python"$python_version_major"
fi
python_bitness=$("$python_interp" -c 'import sys; print(64 if sys.maxsize > 2**32 else 32)')
if [ "$python_bitness" != "" ] && [ "$python_bitness" != "64" ] && [ "$OS_NAME" != "Raspbian" ]; then
echo "[setupvars.sh] WARNING: 64 bitness for Python $python_version is required"
@@ -151,7 +156,7 @@ check_python_version () {
echo "[setupvars.sh] WARNING: OpenVINO Python environment does not set properly"
fi
fi
}
}
python_version_to_check="$python_version"
if [ -z "$python_version" ]; then

View File

@@ -36,7 +36,8 @@ if( PYTHONINTERP_FOUND )
file(TO_CMAKE_PATH "$ENV{HOME}" ENV_HOME)
find_host_program( CYTHON_EXECUTABLE
NAMES cython cython.bat cython3
HINTS ${_python_path} ${ENV_HOME}/.local/bin $ENV{HOMEBREW_OPT}/cython/bin
HINTS ${_python_path} ${ENV_HOME}/.local/bin $ENV{HOMEBREW_OPT}/cython/bin
${ENV_HOME}/Library/Python/${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/bin
)
else()
find_host_program( CYTHON_EXECUTABLE

View File

@@ -17,6 +17,18 @@ file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ie_api.pyx
file(GLOB PYX_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.pyx)
set_source_files_properties(${PYX_SOURCES} PROPERTIES CYTHON_IS_CXX ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# 'argument': conversion from 'size_t' to 'int', possible loss of data
ie_add_compiler_flags(/wd4267)
ie_add_compiler_flags(/wd4244)
endif()
if (OV_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNUCXX)
ie_add_compiler_flags(-Wno-undef)
endif()
if(UNUSED_BUT_SET_VARIABLE_SUPPORTED)
ie_add_compiler_flags(-Wno-unused-but-set-variable)
endif()
# create target
cython_add_module(${TARGET_NAME} ${SOURCES})

View File

@@ -2,6 +2,10 @@
# SPDX-License-Identifier: Apache-2.0
#
if(NOT ANDROID)
find_package(PkgConfig QUIET)
endif()
function(_ov_get_tbb_location tbb_target _tbb_lib_location_var)
if(NOT TBB_FOUND)
return()
@@ -63,48 +67,45 @@ macro(ov_find_package_tbb)
unset(TBB_DIR)
# try tbb.pc from system
if(NOT ANDROID AND ENABLE_SYSTEM_TBB)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
macro(_ov_pkg_config_tbb_unset)
# unset since it affects OpenVINOConfig.cmake.in
unset(tbb_FOUND)
unset(tbb_FOUND CACHE)
endmacro()
pkg_search_module(tbb QUIET
IMPORTED_TARGET GLOBAL
tbb)
if(tbb_FOUND)
# parse version
string(REGEX REPLACE "~.*" "" tbb_VERSION_PATCHED "${tbb_VERSION}")
if(tbb_VERSION_PATCHED AND tbb_VERSION_PATCHED VERSION_LESS _ov_minimal_tbb_version)
_ov_pkg_config_tbb_unset()
message(WARNING "Found TBB ${tbb_VERSION} via ${PKG_CONFIG_EXECUTABLE} while OpenVINO requies ${_ov_minimal_tbb_version} at least")
elseif(TARGET PkgConfig::tbb)
add_library(TBB::tbb ALIAS PkgConfig::tbb)
set(TBB_VERSION ${tbb_VERSION})
set(TBB_FOUND ${tbb_FOUND})
if(ENABLE_SYSTEM_TBB AND PkgConfig_FOUND)
macro(_ov_pkg_config_tbb_unset)
# unset since it affects OpenVINOConfig.cmake.in
unset(tbb_FOUND)
unset(tbb_FOUND CACHE)
endmacro()
pkg_search_module(tbb QUIET
IMPORTED_TARGET GLOBAL
tbb)
if(tbb_FOUND)
# parse version
string(REGEX REPLACE "~.*" "" tbb_VERSION_PATCHED "${tbb_VERSION}")
if(tbb_VERSION_PATCHED AND tbb_VERSION_PATCHED VERSION_LESS _ov_minimal_tbb_version)
_ov_pkg_config_tbb_unset()
message(WARNING "Found TBB ${tbb_VERSION} via ${PKG_CONFIG_EXECUTABLE} while OpenVINO requies ${_ov_minimal_tbb_version} at least")
elseif(TARGET PkgConfig::tbb)
add_library(TBB::tbb ALIAS PkgConfig::tbb)
set(TBB_VERSION ${tbb_VERSION})
set(TBB_FOUND ${tbb_FOUND})
# note: for python wheels we need to find and install tbbmalloc as well
_ov_get_tbb_location(PkgConfig::tbb tbb_loc)
string(REPLACE "tbb" "tbbmalloc" tbbmalloc_loc "${tbb_loc}")
if(EXISTS "${tbbmalloc_loc}")
add_library(TBB::tbbmalloc SHARED IMPORTED)
set_target_properties(TBB::tbbmalloc PROPERTIES IMPORTED_LOCATION ${tbbmalloc_loc})
endif()
message(STATUS "${PKG_CONFIG_EXECUTABLE}: tbb (${tbb_VERSION}) is found at ${tbb_PREFIX}")
else()
_ov_pkg_config_tbb_unset()
if(CPACK_GENERATOR STREQUAL "^(DEB|RPM|CONDA-FORGE|BREW)$")
# package managers require system TBB
set(message_type FATAL_ERROR)
else()
set(message_type WARNING)
endif()
message(${message_type} "cmake v${CMAKE_VERSION} contains bug in function 'pkg_search_module', need to update to at least v3.16.0 version")
# note: for python wheels we need to find and install tbbmalloc as well
_ov_get_tbb_location(PkgConfig::tbb tbb_loc)
string(REPLACE "tbb" "tbbmalloc" tbbmalloc_loc "${tbb_loc}")
if(EXISTS "${tbbmalloc_loc}")
add_library(TBB::tbbmalloc SHARED IMPORTED)
set_target_properties(TBB::tbbmalloc PROPERTIES IMPORTED_LOCATION ${tbbmalloc_loc})
endif()
message(STATUS "${PKG_CONFIG_EXECUTABLE}: tbb (${tbb_VERSION}) is found at ${tbb_PREFIX}")
else()
_ov_pkg_config_tbb_unset()
if(CPACK_GENERATOR STREQUAL "^(DEB|RPM|CONDA-FORGE|BREW)$")
# package managers require system TBB
set(message_type FATAL_ERROR)
else()
set(message_type WARNING)
endif()
message(${message_type} "cmake v${CMAKE_VERSION} contains bug in function 'pkg_search_module', need to update to at least v3.16.0 version")
endif()
endif()
endif()
@@ -124,7 +125,7 @@ macro(ov_find_package_tbb)
endif()
# try to find one more time
find_package(TBB QUIET COMPONENTS tbb tbbmalloc
find_package(TBB ${_ov_minimal_tbb_version} QUIET COMPONENTS tbb tbbmalloc
# TBB_DIR can be provided by ov_download_tbb
HINTS ${TBB_DIR}
${_tbb_paths}
@@ -143,20 +144,38 @@ macro(ov_find_package_tbb)
endforeach()
if(WIN32 AND TARGET TBB::tbbbind_2_5)
# Add HWLOC::hwloc_2_5 target to check via Apivalidator
get_target_property(TBB_location TBB::tbb IMPORTED_LOCATION_RELEASE)
get_filename_component(TBB_dir "${TBB_location}" DIRECTORY)
set(hwloc_dll_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwloc${CMAKE_SHARED_LIBRARY_SUFFIX}")
find_file(HWLOC_DLL NAMES ${hwloc_dll_name} PATHS "${TBB_dir}" DOC "Path to hwloc.dll")
if(NOT HWLOC_DLL)
message(FATAL_ERROR "Failed to find ${hwloc_dll_name} in ${TBB_dir}")
# some package managers provide hwloc.pc file within installation package
# let's try it first
if(PkgConfig_FOUND)
pkg_search_module(HWLOC QUIET
IMPORTED_TARGET GLOBAL
hwloc)
endif()
add_library(HWLOC::hwloc_2_5 SHARED IMPORTED)
set_property(TARGET HWLOC::hwloc_2_5 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(HWLOC::hwloc_2_5 PROPERTIES
IMPORTED_LOCATION_RELEASE "${HWLOC_DLL}")
if(TARGET PkgConfig::HWLOC)
# dependency is satisfied
else()
# Add HWLOC::hwloc_2_5 target to check via ApiValidator
get_target_property(imported_configs TBB::tbbbind_2_5 IMPORTED_CONFIGURATIONS)
foreach(imported_config RELEASE RELWITHDEBINFO DEBUG)
if(imported_config IN_LIST imported_configs)
get_target_property(TBBbind_location TBB::tbbbind_2_5 IMPORTED_LOCATION_${imported_config})
get_filename_component(TBB_dir "${TBBbind_location}" DIRECTORY)
break()
endif()
endforeach()
set(hwloc_dll_name "${CMAKE_SHARED_LIBRARY_PREFIX}hwloc${CMAKE_SHARED_LIBRARY_SUFFIX}")
find_file(HWLOC_DLL NAMES ${hwloc_dll_name} PATHS "${TBB_dir}" DOC "Path to hwloc.dll")
if(NOT HWLOC_DLL)
message(FATAL_ERROR "Failed to find ${hwloc_dll_name} in ${TBB_dir}")
endif()
add_library(HWLOC::hwloc_2_5 SHARED IMPORTED)
set_property(TARGET HWLOC::hwloc_2_5 APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
set_target_properties(HWLOC::hwloc_2_5 PROPERTIES IMPORTED_LOCATION_RELEASE "${HWLOC_DLL}")
endif()
endif()
endif()

View File

@@ -199,7 +199,7 @@ TEST(OVClassBasicTest, smoke_createMockEngineConfigThrows) {
CommonTestUtils::removeFile(filename.c_str());
}
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPOR
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
TEST_P(OVClassBasicTestP, smoke_registerPluginsXMLUnicodePath) {
const std::string pluginXML = getPluginFile();