mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-12-24 13:28:13 +08:00
Fix python compilation on OSX (#58)
* Fix python compilation on OSX * Fix python compilation on OSX
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "fastdeploy/backends/backend.h"
|
||||
#include "fastdeploy/utils/perf.h"
|
||||
|
||||
@@ -152,7 +153,14 @@ struct FASTDEPLOY_DECL Runtime {
|
||||
|
||||
RuntimeOption option;
|
||||
|
||||
~Runtime() {
|
||||
if (backend_ != nullptr) {
|
||||
delete backend_;
|
||||
backend_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
BaseBackend* backend_;
|
||||
BaseBackend* backend_ = nullptr;
|
||||
};
|
||||
} // namespace fastdeploy
|
||||
|
||||
41
setup.py
41
setup.py
@@ -44,7 +44,8 @@ setup_configs = dict()
|
||||
setup_configs["ENABLE_PADDLE_FRONTEND"] = os.getenv("ENABLE_PADDLE_FRONTEND",
|
||||
"ON")
|
||||
setup_configs["ENABLE_ORT_BACKEND"] = os.getenv("ENABLE_ORT_BACKEND", "ON")
|
||||
setup_configs["ENABLE_PADDLE_BACKEND"] = os.getenv("ENABLE_PADDLE_BACKEND", "OFF")
|
||||
setup_configs["ENABLE_PADDLE_BACKEND"] = os.getenv("ENABLE_PADDLE_BACKEND",
|
||||
"OFF")
|
||||
setup_configs["BUILD_DEMO"] = os.getenv("BUILD_DEMO", "ON")
|
||||
setup_configs["ENABLE_VISION"] = os.getenv("ENABLE_VISION", "ON")
|
||||
setup_configs["ENABLE_TRT_BACKEND"] = os.getenv("ENABLE_TRT_BACKEND", "OFF")
|
||||
@@ -370,8 +371,8 @@ if sys.argv[1] == "install" or sys.argv[1] == "bdist_wheel":
|
||||
path = os.path.relpath(
|
||||
os.path.join(root, d),
|
||||
".setuptools-cmake-build/third_libs/install")
|
||||
rpaths.append("$ORIGIN/" + os.path.join(
|
||||
"libs/third_libs", path))
|
||||
rpaths.append("$ORIGIN/" + os.path.join("libs/third_libs",
|
||||
path))
|
||||
rpaths = ":".join(rpaths)
|
||||
command = "patchelf --set-rpath '{}' ".format(rpaths) + pybind_so_file
|
||||
# The sw_64 not suppot patchelf, so we just disable that.
|
||||
@@ -379,6 +380,40 @@ if sys.argv[1] == "install" or sys.argv[1] == "bdist_wheel":
|
||||
assert os.system(
|
||||
command) == 0, "patchelf {} failed, the command: {}".format(
|
||||
command, pybind_so_file)
|
||||
elif platform.system().lower() == "darwin":
|
||||
pre_commands = [
|
||||
"install_name_tool -delete_rpath '@loader_path/libs' " +
|
||||
pybind_so_file
|
||||
]
|
||||
commands = [
|
||||
"install_name_tool -id '@loader_path/libs' " + pybind_so_file
|
||||
]
|
||||
commands.append("install_name_tool -add_rpath '@loader_path/libs' " +
|
||||
pybind_so_file)
|
||||
for root, dirs, files in os.walk(
|
||||
".setuptools-cmake-build/third_libs/install"):
|
||||
for d in dirs:
|
||||
if d == "lib":
|
||||
path = os.path.relpath(
|
||||
os.path.join(root, d),
|
||||
".setuptools-cmake-build/third_libs/install")
|
||||
pre_commands.append(
|
||||
"install_name_tool -delete_rpath '@loader_path/{}' ".
|
||||
format(os.path.join("libs/third_libs",
|
||||
path)) + pybind_so_file)
|
||||
commands.append(
|
||||
"install_name_tool -add_rpath '@loader_path/{}' ".
|
||||
format(os.path.join("libs/third_libs",
|
||||
path)) + pybind_so_file)
|
||||
for command in pre_commands:
|
||||
try:
|
||||
os.system(command)
|
||||
except:
|
||||
print("Skip execute command: " + command)
|
||||
for command in commands:
|
||||
assert os.system(
|
||||
command) == 0, "command execute failed! command: {}".format(
|
||||
command)
|
||||
|
||||
all_files = get_all_files("fastdeploy/libs")
|
||||
for f in all_files:
|
||||
|
||||
Reference in New Issue
Block a user