[osx] fixed mac osx arm64 and x86_64 0.3.0 rpath error (#374)

* Update paddle_inference.cmake

* Update process_libraries.py.in

* Update process_libraries.py.in

* Update paddle_inference.cmake

* Update CMakeLists.txt

* Update VERSION_NUMBER

* Update VERSION_NUMBER

* Update download_prebuilt_libraries.md

* Update gpu.md

* Update cpu.md

* Update download_prebuilt_libraries.md

* Update jetson.md

* Update tensorrt_tricks.md

* Update cpp.md

Co-authored-by: Jason <jiangjiajun@baidu.com>
This commit is contained in:
DefTruth
2022-10-16 15:23:35 +08:00
committed by GitHub
parent 24c8fdc27d
commit e24c592f43
9 changed files with 70 additions and 62 deletions

View File

@@ -74,6 +74,7 @@ def process_on_linux(current_dir):
def process_on_mac(current_dir):
fd_libs = list()
libs_path = os.path.join(current_dir, "fastdeploy", "libs")
cmake_build_dir = os.path.join(current_dir, ".setuptools-cmake-build")
for f in os.listdir(libs_path):
filename = os.path.join(libs_path, f)
if not os.path.isfile(filename):
@@ -82,41 +83,48 @@ def process_on_mac(current_dir):
f.count(".so") > 0):
fd_libs.append(filename)
commands = list()
pre_commands = list()
for lib in fd_libs:
pre_commands.append(
"install_name_tool -delete_rpath '@loader_path/libs' " + lib)
if lib.count("fastdeploy_main") > 0:
pre_commands.append(
"install_name_tool -delete_rpath {} ".format(cmake_build_dir) + lib)
commands.append("install_name_tool -id @loader_path " + lib)
commands.append("install_name_tool -add_rpath @loader_path " + lib)
commands = list()
third_libs_path = os.path.join(libs_path, "third_libs")
all_libs_paths = [third_libs_path] + user_specified_dirs
cmake_third_libs_path = os.path.join(cmake_build_dir, "third_libs", "install")
all_libs_paths = [cmake_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)
rel_path = os.path.relpath(os.path.join(root, d), cmake_third_libs_path)
if path in user_specified_dirs:
# Note(zhoushunjie): Use the absolute path for user_specified_dirs
rpath = os.path.join(root, d)
need_delete_rpath = os.path.join(root, d)
need_add_rpath = os.path.join(root, d)
else:
rpath = "$loader_path/" + rel_path
need_delete_rpath = os.path.join(root, d)
need_add_rpath = "@loader_path/third_libs/" + 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))
if lib.count("fastdeploy_main") > 0:
pre_commands.append(
"install_name_tool -delete_rpath {} {}".format(need_delete_rpath, lib))
commands.append(
"install_name_tool -add_rpath {} {}".format(need_add_rpath, lib))
for cmd in pre_commands:
for command in pre_commands:
try:
subprocess.Popen(cmd, shell=True)
os.system(command)
except:
print("Skip execute command:", cmd)
print("Skip execute command: " + command)
for cmd in commands:
assert subprocess.Popen(
cmd, shell=True) != 0, "Execute command failed: {}".format(cmd)
for command in commands:
assert os.system(
command) == 0, "command execute failed! command: {}".format(
command)
def process_on_windows(current_dir):
libs_path = os.path.join(current_dir, "fastdeploy", "libs")