Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[DOCX] Using OpenVINO from wheel (#26695)

Mikhail Ryzhovc95776dc4e2a
diff --git a/docs/articles_en/documentation/openvino-extensibility.rst b/docs/articles_en/documentation/openvino-extensibility.rst
index 40dac8bccbc..216135009b1 100644
--- a/docs/articles_en/documentation/openvino-extensibility.rst
+++ b/docs/articles_en/documentation/openvino-extensibility.rst
@@ -166,6 +166,15 @@ This CMake script finds OpenVINO, using the ``find_package`` CMake command.
$ cmake -DOpenVINO_DIR=<OpenVINO_DIR> ../
$ cmake --build .
+The OpenVINO python distribution could be also used. The following code snippet demonstrates how to get the OpenVINO_DIR:
+
+.. code-block:: sh
+
+ $ cd src/core/template_extension/new
+ $ mkdir build
+ $ cd build
+ $ cmake -DOpenVINO_DIR=$(python3 -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')") ../
+ $ cmake --build .
4. After the build, you may use the path to your extension library to load your extensions to OpenVINO Runtime:
diff --git a/docs/articles_en/get-started/install-openvino/install-openvino-pip.rst b/docs/articles_en/get-started/install-openvino/install-openvino-pip.rst
index be94336cb11..b9f2664b050 100644
--- a/docs/articles_en/get-started/install-openvino/install-openvino-pip.rst
+++ b/docs/articles_en/get-started/install-openvino/install-openvino-pip.rst
@@ -15,6 +15,19 @@ Install Intel® Distribution of OpenVINO™ Toolkit from PyPI Repository
* is dedicated to users of all major OSes: Windows, Linux, and macOS
(all x86_64 / arm64 architectures)
* macOS offers support only for CPU inference
+
+| **Simplified Build and Integration**
+| The package includes CMake configurations, precompiled static libraries, and headers, which
+ can be easily accessed through the Python API. You can use the `get_cmake_path()` method to
+ retrieve the paths to the CMake configurations and libraries:
+
+.. code-block:: python
+
+ from openvino import get_cmake_path
+ cmake_path = get_cmake_path()
+
+For detailed instructions on how to use these configurations in your build setup, check out the
+:ref:`Create a library with extensions <create_a_library_with_extensions>` section.
.. tab-set::
diff --git a/docs/articles_en/openvino-workflow/running-inference/integrate-openvino-with-your-application.rst b/docs/articles_en/openvino-workflow/running-inference/integrate-openvino-with-your-application.rst
index 152d8bd8f48..d3d5b0cce92 100644
--- a/docs/articles_en/openvino-workflow/running-inference/integrate-openvino-with-your-application.rst
+++ b/docs/articles_en/openvino-workflow/running-inference/integrate-openvino-with-your-application.rst
@@ -415,7 +415,13 @@ For details on additional CMake build options, refer to the `CMake page <https:/
.. doxygensnippet:: docs/snippets/CMakeLists.txt
:language: cpp
:fragment: [cmake:integration_example_c]
-
+
+ .. tab-item:: C++ (PyPI)
+ :sync: cpp
+
+ .. doxygensnippet:: docs/snippets/CMakeLists.txt
+ :language: cpp
+ :fragment: [cmake:integration_example_cpp_py]
Build Project
++++++++++++++++++++
diff --git a/docs/snippets/CMakeLists.txt b/docs/snippets/CMakeLists.txt
index f853d073283..ec1cf14bd0e 100644
--- a/docs/snippets/CMakeLists.txt
+++ b/docs/snippets/CMakeLists.txt
@@ -117,6 +117,26 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino::runtime)
# [cmake:integration_example_cpp]
+set(TARGET_NAME_PY "ov_integration_snippet_py")
+# [cmake:integration_example_cpp_py]
+cmake_minimum_required(VERSION 3.10)
+set(CMAKE_CXX_STANDARD 11)
+
+find_package(Python3 REQUIRED)
+ execute_process(
+ COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
+ OUTPUT_VARIABLE OpenVINO_DIR_PY
+ ERROR_QUIET
+ )
+
+find_package(OpenVINO REQUIRED PATHS "${OpenVINO_DIR_PY}")
+
+add_executable(${TARGET_NAME_PY} src/main.cpp)
+
+target_link_libraries(${TARGET_NAME_PY} PRIVATE openvino::runtime)
+
+# [cmake:integration_example_cpp_py]
+
set(TARGET_NAME_C "ov_integration_snippet_c")
# [cmake:integration_example_c]
cmake_minimum_required(VERSION 3.10)
diff --git a/src/core/template_extension/CMakeLists.txt b/src/core/template_extension/CMakeLists.txt
index a7c9d42e7b8..aa8030e78d7 100644
--- a/src/core/template_extension/CMakeLists.txt
+++ b/src/core/template_extension/CMakeLists.txt
@@ -7,7 +7,15 @@ set(CMAKE_CXX_STANDARD 11)
set(TARGET_NAME "openvino_template_extension")
-find_package(OpenVINO REQUIRED)
+# The OpenVINO installed from PyPI can be used to find OpenVINO_DIR
+find_package(Python3 REQUIRED)
+execute_process(
+ COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
+ OUTPUT_VARIABLE OpenVINO_DIR_PY
+ ERROR_QUIET
+)
+
+find_package(OpenVINO REQUIRED PATHS "${OpenVINO_DIR_PY}")
set(SRC identity.cpp ov_extension.cpp)