From 28b7f87ccf80883967b0774c64597d5f70bcc328 Mon Sep 17 00:00:00 2001 From: typhoonzero Date: Fri, 6 Jul 2018 19:07:45 +0800 Subject: [PATCH] fix mac build and whl pkg --- python/setup.py.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/python/setup.py.in b/python/setup.py.in index 55064437336..8f80502412f 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -126,10 +126,11 @@ if '${WITH_MKL}' == 'ON': shutil.copy('${MKLML_IOMP_LIB}', libs_path) package_data['paddle.libs']+=['libmklml_intel.so','libiomp5.so'] if '${WITH_MKLDNN}' == 'ON': - # change rpath of libmkldnn.so.0, add $ORIGIN/ to it. - # The reason is that all thirdparty libraries in the same directory, - # thus, libmkldnn.so.0 will find libmklml_intel.so and libiomp5.so. - command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}" + if "@APPLE@" != "1": + # change rpath of libmkldnn.so.0, add $ORIGIN/ to it. + # The reason is that all thirdparty libraries in the same directory, + # thus, libmkldnn.so.0 will find libmklml_intel.so and libiomp5.so. + command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}" if os.system(command) != 0: raise Exception("patchelf --set-rpath for libmkldnn.so.0 fails") package_data['paddle.libs']+=['libmkldnn.so.0'] @@ -142,7 +143,10 @@ package_dir['paddle.libs']=libs_path # The reason is that libwarpctc.so, libiomp5.so etc are in paddle.libs, and # core.so is in paddle.fluid, thus paddle/fluid/../libs will pointer to above libraries. # This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213 -command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so" +if "@APPLE@" == "1": + command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so" +else: + command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so" if os.system(command) != 0: raise Exception("patchelf --set-rpath for core.so fails") -- GitLab