Skip to content

Commit 2d15752

Browse files
committed
Populate python with the libraries to allow skipping wheel installation
1 parent 9b83a7e commit 2d15752

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

.github/workflows/genai_lib.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ jobs:
1313
- run: mkdir ./ov/
1414
- run: curl https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.1.0-14758-22bd6ff0494/l_openvino_toolkit_centos7_2024.1.0.dev20240315_x86_64.tgz | tar --directory ./ov/ --strip-components 1 -xz # Install CentOS7 instead of Ubuntu to match PyPI distribution ABI
1515
- run: sudo ./ov/install_dependencies/install_openvino_dependencies.sh
16+
- run: source ./ov/setupvars.sh && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
17+
- run: cmake --build ./build/ -j
18+
- run: source ./ov/setupvars.sh && PYTHONPATH=./src/python:$PYTHONPATH python -c "from openvino.genai.py_generate_pipeline import LLMPipeline"
1619
- run: source ./ov/setupvars.sh && python -m pip install --pre . --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly
1720
- run: python -c "from openvino.genai.py_generate_pipeline import LLMPipeline"
1821

1922
genai_lib_windows:
2023
runs-on: windows-latest
24+
defaults:
25+
run:
26+
shell: cmd
2127
steps:
2228
- uses: actions/checkout@v4
2329
with:
@@ -27,6 +33,8 @@ jobs:
2733
python-version: 3.8
2834
- run: curl --output ov.zip https://storage.openvinotoolkit.org/repositories/openvino/packages/nightly/2024.1.0-14645-e6dc0865128/w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64.zip
2935
- run: unzip ov.zip
36+
- run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && cmake -DCMAKE_BUILD_TYPE=Release -S ./ -B ./build/
37+
- run: cmake --build ./build/ -j
38+
- run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && set PYTHONPATH=./src/python:$PYTHONPATH && python -c "from openvino.genai.py_generate_pipeline import LLMPipeline"
3039
- run: call w_openvino_toolkit_windows_2024.1.0.dev20240304_x86_64\setupvars.bat && python -m pip install .
31-
shell: cmd
3240
- run: python -c "from openvino.genai.py_generate_pipeline import LLMPipeline"

src/cpp/CMakeLists.txt

+11-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ function(ov_genai_build_jinja2cpp)
3131

3232
add_subdirectory("${jinja2cpp_SOURCE_DIR}" "${jinja2cpp_BINARY_DIR}" EXCLUDE_FROM_ALL)
3333
# openvino::runtime exports _GLIBCXX_USE_CXX11_ABI=0 on CenOS7.
34-
# It needs to be propagated to every lib GenAI links with. It's
35-
# enough to propagate it to fmt, because fmt propagates to
34+
# It needs to be propagated to every library GenAI links with.
35+
# It's enough to propagate to fmt, because fmt propagates to
3636
# jinja2cpp.
37-
target_link_libraries(fmt PUBLIC openvino::runtime)
37+
target_compile_definitions(fmt PUBLIC $<TARGET_PROPERTY:openvino::runtime,INTERFACE_COMPILE_DEFINITIONS>)
3838
endif()
3939
endfunction()
4040

@@ -57,4 +57,12 @@ target_link_libraries(${TARGET_NAME} PUBLIC openvino::runtime PRIVATE nlohmann_j
5757
target_compile_definitions(${TARGET_NAME} PRIVATE OPENVINO_TOKENIZERS_PATH=\"$<TARGET_FILE:openvino_tokenizers>\")
5858

5959
target_compile_features(${TARGET_NAME} PUBLIC cxx_std_17)
60+
6061
install(TARGETS ${TARGET_NAME} LIBRARY DESTINATION . COMPONENT genai RUNTIME DESTINATION . COMPONENT genai)
62+
63+
# Populate python with the libraries to allow skipping wheel installation
64+
add_custom_command(TARGET generate_pipeline_lib POST_BUILD
65+
COMMAND "${CMAKE_COMMAND}" -E copy
66+
"$<TARGET_FILE:generate_pipeline_lib>"
67+
"${CMAKE_CURRENT_SOURCE_DIR}/../python/openvino/genai/$<TARGET_FILE_NAME:generate_pipeline_lib>"
68+
COMMENT "Copy generate_pipeline_lib to src/python/openvino/genai")

src/python/CMakeLists.txt

+8-4
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ endif()
1717

1818
pybind11_add_module(py_generate_pipeline py_generate_pipeline.cpp)
1919
target_link_libraries(py_generate_pipeline PRIVATE generate_pipeline_lib)
20+
2021
install(TARGETS py_generate_pipeline LIBRARY DESTINATION . COMPONENT genai_python)
2122

2223
# setting RPATH / LC_RPATH depending on platform
2324
if(LINUX)
2425
# to find libgenerate_pipeline_lib.so in the same folder
2526
set(rpaths "$ORIGIN")
26-
if(DEFINED SKBUILD)
27-
# in case we build pip package, we need to refer to libopenvino.so from 'openvino' package
28-
list(APPEND rpaths "@ORIGIN/../../openvino/libs")
29-
endif()
3027
elseif(APPLE)
3128
# to find libgenerate_pipeline_lib.dylib in the same folder
3229
set(rpaths "@loader_path")
@@ -39,3 +36,10 @@ endif()
3936
if(rpaths)
4037
set_target_properties(py_generate_pipeline PROPERTIES INSTALL_RPATH "${rpaths}")
4138
endif()
39+
40+
# Populate python with the libraries to allow skipping wheel installation
41+
add_custom_command(TARGET py_generate_pipeline POST_BUILD
42+
COMMAND "${CMAKE_COMMAND}" -E copy
43+
"$<TARGET_FILE:py_generate_pipeline>"
44+
"${CMAKE_CURRENT_SOURCE_DIR}/openvino/genai/$<TARGET_FILE_NAME:py_generate_pipeline>"
45+
COMMENT "Copy py_generate_pipeline to src/python/openvino/genai")

0 commit comments

Comments
 (0)