Add some lib directories compiler option (#255)

* Add OPENCV_DIRECTORY option to provide the ability to specify the installed opecv lib pat

* Use find_package for opencv in windows, mac and linux

* Fix opencv cmake

* Fix python lib rpath setting

* fix mac python package

* Add some promt when use different opencv lib

* add status message

* Fix the backslash

* Fix python package user defined libs

* Fix windows python process libs

* Add windows lib set path
This commit is contained in:
Jack Zhou
2022-09-21 13:25:56 +08:00
committed by GitHub
parent addce837bc
commit e7f741292e
6 changed files with 83 additions and 155 deletions

View File

@@ -18,6 +18,7 @@ import shutil
import subprocess
import platform
user_specified_dirs = ['@OPENCV_DIRECTORY@', ]
def process_on_linux(current_dir):
rpaths = ["$ORIGIN:$ORIGIN/libs"]
@@ -31,13 +32,15 @@ def process_on_linux(current_dir):
fd_libs.append(filename)
third_libs_path = os.path.join(libs_path, "third_libs")
for root, dirs, files in os.walk(third_libs_path):
for d in dirs:
if d != "lib":
continue
rel_path = os.path.relpath(os.path.join(root, d), libs_path)
rpath = "$ORIGIN/" + rel_path
rpaths.append(rpath)
all_libs_paths = [third_libs_path] + user_specified_dirs
for path in all_libs_paths:
for root, dirs, files in os.walk(path):
for d in dirs:
if d not in ["lib", "lib64"]:
continue
rel_path = os.path.relpath(os.path.join(root, d), libs_path)
rpath = "$ORIGIN/" + rel_path
rpaths.append(rpath)
for lib in fd_libs:
command = "patchelf --set-rpath '{}' {}".format(":".join(rpaths), lib)
@@ -66,18 +69,20 @@ def process_on_mac(current_dir):
commands = list()
third_libs_path = os.path.join(libs_path, "third_libs")
for root, dirs, files in os.walk(third_libs_path):
for d in dirs:
if d != "lib":
continue
rel_path = rel_path = os.path.relpath(os.path.join(root, d), libs_path)
rpath = "$loader_path/" + rel_path
for lib in fd_libs:
pre_commands.append(
"install_name_tool -delete_rpath '@loader_path/{}' {}".format(
rpath, lib))
commands.append("install_name_tool -add_rpath 'loader_path/{}' {}".
format(rpath, lib))
all_libs_paths = [third_libs_path] + user_specified_dirs
for path in all_libs_paths:
for root, dirs, files in os.walk(path):
for d in dirs:
if d not in ["lib", "lib64"]:
continue
rel_path = rel_path = os.path.relpath(os.path.join(root, d), libs_path)
rpath = "$loader_path/" + rel_path
for lib in fd_libs:
pre_commands.append(
"install_name_tool -delete_rpath '@loader_path/{}' {}".format(
rpath, lib))
commands.append("install_name_tool -add_rpath 'loader_path/{}' {}".
format(rpath, lib))
for cmd in pre_commands:
try:
@@ -136,6 +141,7 @@ def process_libraries(current_dir):
package_data.append(
os.path.relpath(f, os.path.join(current_dir,
"fastdeploy")))
return package_data
filters = [".vcxproj", ".png", ".java", ".h", ".cc", ".cpp", ".hpp"]
@@ -145,7 +151,12 @@ def process_libraries(current_dir):
if f.count(flt) > 0:
remain = False
filename = os.path.split(f)[-1]
if filename in ["libnvinfer_plugin.so", "libnvinfer_plugin.so.8.4.1", "libnvinfer.so", "libnvinfer.so.8.4.1", "libnvonnxparser.so", "libnvonnxparser.so.8.4.1", "libnvparsers.so", "libnvparsers.so.8.4.1"]:
if filename in [
"libnvinfer_plugin.so", "libnvinfer_plugin.so.8.4.1",
"libnvinfer.so", "libnvinfer.so.8.4.1", "libnvonnxparser.so",
"libnvonnxparser.so.8.4.1", "libnvparsers.so",
"libnvparsers.so.8.4.1"
]:
continue
if remain:
package_data.append(