From aed6f713df3cc185173f9070573535737bd9836b Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Tue, 12 Dec 2023 15:26:25 +0400 Subject: [PATCH] Added LC_RPATH to additionally point to openvino's libs --- .ci/azure/linux.yml | 28 +++++++------ .ci/azure/mac.yml | 12 +++--- .ci/azure/windows.yml | 39 +++++++++---------- .../user_ie_extensions/CMakeLists.txt | 13 ++++++- .../python/openvino_tokenizers/__init__.py | 9 +---- 5 files changed, 52 insertions(+), 49 deletions(-) diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index d97b07678..63d354117 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -103,8 +103,7 @@ jobs: unzip gradle-$(GRADLE_VER)-bin.zip # For opencv-python: python3-setuptools and pip upgrade python3 -m pip install --upgrade pip - python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/requirements.txt - python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/requirements_test.txt + python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/wheel/requirements-dev.txt python3 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt # Speed up build wget https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip @@ -171,10 +170,18 @@ jobs: python -m pip install --upgrade pip python -m pip install -r $(REPO_DIR)/modules/custom_operations/tests/requirements.txt python -m pip install $(INSTALL_DIR)/tools/openvino-*.whl - python -m pip install $(OPENVINO_REPO_DIR)/tools/mo/ workingDirectory: $(WORK_DIR) displayName: 'Create virtual env' + - script: | + source $(WORK_DIR)/.env3/bin/activate + # need to enable sparse_conv tests with new Open3D release + python -m pytest -k "not sparse_conv" tests/run_tests.py + env: + CUSTOM_OP_LIB: $(BIN_DIR)/libuser_ov_extensions.so + workingDirectory: $(REPO_DIR)/modules/custom_operations + displayName: 'Custom user operation tests' + - script: | source $(WORK_DIR)/.env3/bin/activate && source $(SETUPVARS) python -m pip install build @@ -182,6 +189,9 @@ jobs: workingDirectory: $(WORK_DIR) displayName: 'Build tokenizers wheel' + - publish: $(BUILD_WHEEL_DIR) + artifact: Wheels + - script: | source $(WORK_DIR)/.env3/bin/activate # Find and install wheel @@ -192,18 +202,6 @@ jobs: workingDirectory: $(WORK_DIR) displayName: 'Install tokenizers wheel' - - publish: $(BUILD_WHEEL_DIR) - artifact: Wheels - - - script: | - source $(WORK_DIR)/.env3/bin/activate - # need to enable sparse_conv tests with new Open3D release - python -m pytest -k "not sparse_conv" tests/run_tests.py - env: - CUSTOM_OP_LIB: $(BIN_DIR)/libuser_ov_extensions.so - workingDirectory: $(REPO_DIR)/modules/custom_operations - displayName: 'Custom user operation tests' - - script: | source $(WORK_DIR)/.env3/bin/activate python -m pytest tokenizers_test.py diff --git a/.ci/azure/mac.yml b/.ci/azure/mac.yml index 7d6f7f26a..e0d15b173 100644 --- a/.ci/azure/mac.yml +++ b/.ci/azure/mac.yml @@ -111,7 +111,10 @@ jobs: brew install scons # Speed up build brew install ninja - + # install python wheel dependencies + python3.10 -m pip install --upgrade pip + python3.10 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/wheel/requirements-dev.txt + python3.10 -m pip install -r $(OPENVINO_REPO_DIR)/src/bindings/python/src/compatibility/openvino/requirements-dev.txt workingDirectory: $(WORK_DIR) displayName: 'Install dependencies' @@ -162,7 +165,6 @@ jobs: source venv/bin/activate && source $(SETUPVARS) python -m pip install --upgrade pip python -m pip install -r $(REPO_DIR)/modules/custom_operations/tests/requirements.txt - python -m pip install $(OPENVINO_REPO_DIR)/tools/mo/ # Find and install wheel pushd $(INSTALL_DIR)/tools wheel_name=$(find . -name 'openvino-*.whl') @@ -178,6 +180,9 @@ jobs: workingDirectory: $(WORK_DIR) displayName: 'Build tokenizers wheel' + - publish: $(BUILD_WHEEL_DIR) + artifact: Wheels + - script: | source $(WORK_DIR)/venv/bin/activate # Find and install wheel @@ -188,9 +193,6 @@ jobs: workingDirectory: $(WORK_DIR) displayName: 'Install tokenizers wheel' - - publish: $(BUILD_WHEEL_DIR) - artifact: Wheels - - script: | source $(WORK_DIR)/venv/bin/activate python -m pytest tokenizers_test.py diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index 6655e125c..134ccf9ef 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -102,9 +102,7 @@ jobs: call $(SETUPVARS) -pyver 3.8 $(PYTHON_EXE) -m pip install --upgrade pip $(PYTHON_EXE) -m pip install -r $(OPENVINO_REPO_DIR)\src\bindings\python\src\compatibility\openvino\requirements-dev.txt - $(PYTHON_EXE) -m pip install -r $(OPENVINO_REPO_DIR)\src\bindings\python\requirements.txt - $(PYTHON_EXE) -m pip install -r $(REPO_DIR)\modules\custom_operations\tests\requirements.txt - $(PYTHON_EXE) -m pip install $(OPENVINO_REPO_DIR)\tools\mo + $(PYTHON_EXE) -m pip install -r $(OPENVINO_REPO_DIR)\src\bindings\python\wheel\requirements-dev.txt powershell -command "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" choco install opencv -y workingDirectory: $(WORK_DIR) @@ -167,23 +165,6 @@ jobs: workingDirectory: $(BUILD_DIR_CONTRIB) displayName: 'Build OpenVINO Contrib' - - script: | - call $(SETUPVARS) - $(PYTHON_EXE) -m pip install build - $(PYTHON_EXE) -m build --wheel --outdir $(BUILD_WHEEL_DIR) $(REPO_DIR)\modules\custom_operations - workingDirectory: $(WORK_DIR) - displayName: 'Build tokenizers wheel' - - - powershell: | - # Find and install the wheel - $wheelPath=Get-ChildItem -Path "$(BUILD_WHEEL_DIR)" -Filter openvino_tokenizers*.whl | % { $_.FullName } - $(PYTHON_EXE) -m pip install "$wheelPath[all]" - workingDirectory: $(WORK_DIR) - displayName: 'Install tokenizers wheel' - - - publish: $(BUILD_WHEEL_DIR) - artifact: Wheels - - script: | call $(SETUPVARS) set PATH=$(WORK_DIR)\gradle-$(GRADLE_VER)-bin\gradle-$(GRADLE_VER)\bin;%PATH% @@ -195,12 +176,30 @@ jobs: - script: | call C:\tools\opencv\build\setup_vars_opencv4.cmd call $(SETUPVARS) -pyver 3.8 && ^ + $(PYTHON_EXE) -m pip install -r $(REPO_DIR)\modules\custom_operations\tests\requirements.txt $(PYTHON_EXE) -m pytest -k "not sparse_conv" tests\run_tests.py env: CUSTOM_OP_LIB: $(BUILD_DIR_CONTRIB)\user_ie_extensions\user_ov_extensions.dll workingDirectory: $(REPO_DIR)\modules\custom_operations displayName: 'Custom user operation tests' + - script: | + call $(SETUPVARS) + $(PYTHON_EXE) -m pip install build + $(PYTHON_EXE) -m build --wheel --outdir $(BUILD_WHEEL_DIR) $(REPO_DIR)\modules\custom_operations + workingDirectory: $(WORK_DIR) + displayName: 'Build tokenizers wheel' + + - publish: $(BUILD_WHEEL_DIR) + artifact: Wheels + + - powershell: | + # Find and install the wheel + $wheelPath=Get-ChildItem -Path "$(BUILD_WHEEL_DIR)" -Filter openvino_tokenizers*.whl | % { $_.FullName } + $(PYTHON_EXE) -m pip install "$wheelPath[all]" + workingDirectory: $(WORK_DIR) + displayName: 'Install tokenizers wheel' + - script: | call $(SETUPVARS) -pyver 3.8 && ^ $(PYTHON_EXE) -m pytest tokenizers_test.py diff --git a/modules/custom_operations/user_ie_extensions/CMakeLists.txt b/modules/custom_operations/user_ie_extensions/CMakeLists.txt index b14006a2b..763ea875f 100644 --- a/modules/custom_operations/user_ie_extensions/CMakeLists.txt +++ b/modules/custom_operations/user_ie_extensions/CMakeLists.txt @@ -117,9 +117,18 @@ include(GNUInstallDirs) # setting RPATH / LC_RPATH depending on platform if(LINUX) - set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN") + # to find libcore_tokenizer.so in the same folder + set(rpaths "$ORIGIN") elseif(APPLE) - set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "@loader_path") + # to find libcore_tokenizer.dylib in the same folder + set(rpaths "@loader_path") + if(DEFINED SKBUILD) + # in case we build pip package, we need to refer to libopenvino.dylib from 'openvino' package + list(APPEND rpaths "@loader_path/../../openvino/libs") + endif() +endif() +if(rpaths) + set_target_properties(${TARGET_NAME} PROPERTIES INSTALL_RPATH "${rpaths}") endif() # Installing the extension module to the root of the package diff --git a/modules/custom_operations/user_ie_extensions/tokenizer/python/openvino_tokenizers/__init__.py b/modules/custom_operations/user_ie_extensions/tokenizer/python/openvino_tokenizers/__init__.py index b6a998eb7..5bfa50c47 100644 --- a/modules/custom_operations/user_ie_extensions/tokenizer/python/openvino_tokenizers/__init__.py +++ b/modules/custom_operations/user_ie_extensions/tokenizer/python/openvino_tokenizers/__init__.py @@ -33,16 +33,11 @@ else: sys.exit(f"Error: extension does not support the platform {sys.platform}") -# conda-forge case -conda_forge_lib_path = Path(os.path.join(os.path.dirname(__file__), "..", "..", "..")) -if os.path.exists(conda_forge_lib_path / _ext_name): - _ext_path = conda_forge_lib_path / _ext_name -else: - _ext_path = _ext_libs_path / _ext_name +_ext_path = _ext_name if os.environ.get("CONDA_PREFIX") else (_ext_libs_path / _ext_name) del _ext_name del _ext_libs_path -del conda_forge_lib_path +del _extension_path # patching openvino old_core_init = openvino.runtime.Core.__init__