Skip to content

Commit d06c698

Browse files
BUILD: set rpath for GenAI to OpenVINO C when building wheel (openvinotoolkit#1869)
CVS-163867
1 parent 3c2f4a9 commit d06c698

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ find_python3 = true
4949
build_args = ["--parallel", "--target", "py_openvino_genai_stub"]
5050
install_args = ["--strip"]
5151
install_components = ["wheel_genai"]
52-
options = {"BUILD_TOKENIZERS" = "OFF", "ENABLE_SAMPLES" = "OFF"}
52+
options = {"BUILD_TOKENIZERS" = "OFF", "ENABLE_SAMPLES" = "OFF", "CMAKE_SKIP_INSTALL_RPATH" = "OFF"}
5353

5454
[build-system]
5555
requires = [

src/python/CMakeLists.txt

+13-12
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,29 @@ if(OpenVINODeveloperPackage_FOUND)
3939
# ov_add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
4040
endif()
4141

42-
if(DEFINED PY_BUILD_CMAKE_PACKAGE_NAME)
43-
# RPATH for wheel is mandatory to find openvino_genai library. It
44-
# must be forced because GenAI may be built with OpenVINO targeting
45-
# archive. Such OpenVINO configurations sets
46-
# CMAKE_SKIP_INSTALL_RPATH to ON because it relies on setupvars.sh.
47-
set(CMAKE_SKIP_INSTALL_RPATH OFF)
48-
endif()
4942
# setting RPATH / LC_RPATH depending on platform
5043
if(LINUX)
5144
# to find libopenvino_genai.so in the same folder
52-
set(rpaths "$ORIGIN")
45+
set(py_rpaths "$ORIGIN")
46+
# to find libopenvino_c.so for libopenvino_genai.so
47+
set(cpp_rpaths "$ORIGIN/../openvino/libs")
5348
elseif(APPLE)
5449
# to find libopenvino_genai.dylib in the same folder
55-
set(rpaths "@loader_path")
50+
set(py_rpaths "@loader_path")
5651
if(DEFINED PY_BUILD_CMAKE_PACKAGE_NAME)
5752
# in case we build pip package, we need to refer to libopenvino.dylib from 'openvino' package
58-
list(APPEND rpaths "@loader_path/../openvino/libs")
53+
list(APPEND py_rpaths "@loader_path/../openvino/libs")
5954
endif()
55+
# to find libopenvino_c.dylib for libopenvino_genai.dylib
56+
set(cpp_rpaths "$loader_path/../openvino/libs")
57+
endif()
58+
59+
if(py_rpaths)
60+
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "${py_rpaths}")
6061
endif()
6162

62-
if(rpaths)
63-
set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "${rpaths}")
63+
if(cpp_rpaths)
64+
set_target_properties(openvino_genai PROPERTIES INSTALL_RPATH "${cpp_rpaths}")
6465
endif()
6566

6667
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/openvino_genai/__init__.py"

0 commit comments

Comments
 (0)