Skip to content

Commit

Permalink
Added LC_RPATH to additionally point to openvino's libs (#784)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored Dec 13, 2023
1 parent 8d45c4c commit 4c60cb1
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 49 deletions.
28 changes: 13 additions & 15 deletions .ci/azure/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -171,17 +170,28 @@ 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
python -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

- script: |
source $(WORK_DIR)/.env3/bin/activate
# Find and install wheel
Expand All @@ -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
bandit -c pyproject.toml -r user_ie_extensions/tokenizer/python/
Expand Down
12 changes: 7 additions & 5 deletions .ci/azure/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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
Expand Down
39 changes: 19 additions & 20 deletions .ci/azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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%
Expand All @@ -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
Expand Down
13 changes: 11 additions & 2 deletions modules/custom_operations/user_ie_extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down

0 comments on commit 4c60cb1

Please sign in to comment.