Skip to content

Commit ad192ab

Browse files
committed
Use python from venv only
1 parent ae532aa commit ad192ab

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

.github/workflows/test_accuracy.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
sudo bash src/cpp/install_dependencies.sh
4141
- name: Build CPP Test
4242
run: |
43+
source venv/bin/activate
4344
pip install nanobind==2.4.0
4445
pip install typing_extensions==4.12.2
4546
mkdir build && cd build

src/cpp/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ find_package(OpenCV REQUIRED COMPONENTS core imgproc)
3535

3636
# Looking for OpenVINO in the python distribution. It doesn't work for cross-compiling build
3737
if(NOT CMAKE_CROSSCOMPILING)
38-
find_package(Python3 REQUIRED)
38+
set(Python_FIND_VIRTUALENV ONLY)
39+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
3940
execute_process(
40-
COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
41+
COMMAND ${Python_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
4142
OUTPUT_VARIABLE OpenVINO_DIR_PY
4243
ERROR_QUIET
4344
)

src/cpp/py_bindings/CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# SPDX-License-Identifier: Apache-2.0
33
#
44

5-
set(DEV_MODULE Development.Module)
6-
7-
find_package(Python COMPONENTS Interpreter ${DEV_MODULE} REQUIRED)
5+
set(Python_FIND_VIRTUALENV ONLY)
6+
find_package(Python COMPONENTS Interpreter Development REQUIRED)
87

98
execute_process(
109
COMMAND "${Python_EXECUTABLE}" -m nanobind --cmake_dir

tests/cpp/accuracy/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,17 @@ FetchContent_MakeAvailable(json googletest)
6464
include(../cmake/common.cmake)
6565

6666
find_package(OpenCV REQUIRED COMPONENTS core highgui videoio imgproc imgcodecs)
67-
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
67+
68+
set(Python_FIND_VIRTUALENV ONLY)
69+
find_package(Python REQUIRED)
70+
execute_process(
71+
COMMAND ${Python_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
72+
OUTPUT_VARIABLE OpenVINO_DIR_PY
73+
ERROR_QUIET
74+
)
75+
find_package(OpenVINO REQUIRED
76+
COMPONENTS Runtime Threading
77+
HINTS "${OpenVINO_DIR_PY}")
6878

6979
add_subdirectory(../../../src/cpp ${tests_BINARY_DIR}/model_api/cpp)
7080

tests/cpp/cmake/common.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,12 @@ macro(add_test)
3535
target_include_directories(${TEST_NAME} PRIVATE ${TEST_INCLUDE_DIRECTORIES})
3636
endif()
3737

38-
target_link_libraries(${TEST_NAME} PRIVATE ${OpenCV_LIBRARIES} openvino::runtime ${TEST_DEPENDENCIES})
38+
target_link_libraries(${TEST_NAME} PRIVATE ${OpenCV_LIBRARIES} ${TEST_DEPENDENCIES})
3939

4040
if(UNIX)
4141
target_link_libraries(${TEST_NAME} PRIVATE pthread)
4242
endif()
4343

44-
target_link_libraries(${TEST_NAME} PRIVATE gtest gtest_main)
45-
target_link_libraries(${TEST_NAME} PRIVATE nlohmann_json::nlohmann_json)
44+
target_link_libraries(${TEST_NAME} PRIVATE gtest_main gmock_main nlohmann_json::nlohmann_json)
4645

4746
endmacro()

0 commit comments

Comments
 (0)