From ffe042bfe4120e5a914eb5d5bd02834eb93ebef3 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 28 Nov 2024 16:02:35 +0100 Subject: [PATCH] Fixed pyi file build when OpenVINO_DIR is externally defined --- src/python/CMakeLists.txt | 14 ++++++++++++++ src/python/py_vlm_pipeline.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 25d81277d6..ae76aa2148 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -114,6 +114,20 @@ elseif(DEFINED PY_BUILD_CMAKE_PACKAGE_NAME AND NOT WIN32) # in case of wheel build, pybind11-stubgen is always available via pyproject.toml's build-system # except Win32 where we have issues with pybind11_stubgen executable which cannot import its own module set(pybind11_stubgen_AVAILABLE ON) + + # by default, wheel build is performed with build-isolation, which means that some variables like PYTHONPATH + # are not available. But if user called setupvars.sh, then OpenVINO dir is available, while PYTHONPATH - no. + # In this case, we will have mismatch on Linux when OpenVINO can point on build dir / install dir, while + # PYTHONPATH points out to locally installed tmp OpenVINO wheel (build against wheel). + # Ways to handle it: + # - setting PYTHONPATH to $ENV{INTEL_OPENVINO_DIR}/python if INTEL_OPENVINO_DIR is defined. It means we are building against + # OpenVINO archive or installation tree + # - if it's not defined, we cannot do any guesses and hence, disable pybind11-stubgen usage + if(DEFINED ENV{INTEL_OPENVINO_DIR}) + set(openvino_pythonpath "$ENV{INTEL_OPENVINO_DIR}/python") + elseif(LINUX AND NOT OpenVINO_DIR STREQUAL OpenVINO_DIR_PY) + set(pybind11_stubgen_AVAILABLE OFF) + endif() endif() # but we also need to check whether OpenVINO is installed diff --git a/src/python/py_vlm_pipeline.cpp b/src/python/py_vlm_pipeline.cpp index 9572652204..ccc254a8fe 100644 --- a/src/python/py_vlm_pipeline.cpp +++ b/src/python/py_vlm_pipeline.cpp @@ -28,7 +28,7 @@ auto vlm_generate_docstring = R"( :type images: List[ov.Tensor] or ov.Tensor :param generation_config: generation_config - :type generation_config: GenerationConfig or a Dict + :type generation_config: GenerationConfig or a Dict :param streamer: streamer either as a lambda with a boolean returning flag whether generation should be stopped :type : Callable[[str], bool], ov.genai.StreamerBase