Skip to content

Commit

Permalink
[DOCS] Using OpenVINO from wheel for 24.4 (#26836)
Browse files Browse the repository at this point in the history
Porting: #26695
  • Loading branch information
sgolebiewski-intel authored Oct 3, 2024
1 parent 8dd187e commit d70e7dc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/articles_en/documentation/openvino-extensibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ Install Intel® Distribution of OpenVINO™ Toolkit from PyPI Repository
(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::

.. tab-item:: System Requirements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ For details on additional CMake build options, refer to the `CMake page <https:/
: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
++++++++++++++++++++
Expand Down
20 changes: 20 additions & 0 deletions docs/snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion src/core/template_extension/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit d70e7dc

Please sign in to comment.