@@ -159,18 +159,20 @@ if '${WITH_MKL}' == 'ON':
159
159
shutil.copy('${MKLML_LIB}', libs_path)
160
160
shutil.copy('${MKLML_IOMP_LIB}', libs_path)
161
161
package_data['paddle.libs']+=['libmklml_intel.so','libiomp5.so']
162
- if '${WITH_MKLDNN}' == 'ON':
163
- # TODO(typhoonzero): use install_name_tool to patch mkl libs once
164
- # we can support mkl on mac.
165
- #
166
- # change rpath of libmkldnn.so.0, add $ORIGIN/ to it.
167
- # The reason is that all thirdparty libraries in the same directory,
168
- # thus, libmkldnn.so.0 will find libmklml_intel.so and libiomp5.so.
169
- command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}"
170
- if os.system(command) != 0:
171
- raise Exception("patch libmkldnn.so failed, command: %s" % command)
172
- package_data['paddle.libs']+=['libmkldnn.so.0']
173
- shutil.copy('${MKLDNN_SHARED_LIB}', libs_path)
162
+ if '${CMAKE_BUILD_TYPE}' == 'Release':
163
+ # only change rpath in Release mode.
164
+ if '${WITH_MKLDNN}' == 'ON':
165
+ # TODO(typhoonzero): use install_name_tool to patch mkl libs once
166
+ # we can support mkl on mac.
167
+ #
168
+ # change rpath of libmkldnn.so.0, add $ORIGIN/ to it.
169
+ # The reason is that all thirdparty libraries in the same directory,
170
+ # thus, libmkldnn.so.0 will find libmklml_intel.so and libiomp5.so.
171
+ command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}"
172
+ if os.system(command) != 0:
173
+ raise Exception("patch libmkldnn.so failed, command: %s" % command)
174
+ package_data['paddle.libs']+=['libmkldnn.so.0']
175
+ shutil.copy('${MKLDNN_SHARED_LIB}', libs_path)
174
176
# remove unused paddle/libs/__init__.py
175
177
os.remove(libs_path+'/__init__.py')
176
178
package_dir['paddle.libs']=libs_path
@@ -179,20 +181,22 @@ package_dir['paddle.libs']=libs_path
179
181
# The reason is that libwarpctc.so, libiomp5.so etc are in paddle.libs, and
180
182
# core.so is in paddle.fluid, thus paddle/fluid/../libs will pointer to above libraries.
181
183
# This operation will fix https://github.com/PaddlePaddle/Paddle/issues/3213
182
- if "@APPLE@" == "1":
183
- command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so"
184
- else:
185
- command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/core.so"
186
- if os.system(command) != 0:
187
- raise Exception("patch core.so failed, command: %s" % command)
188
- if '${WITH_FLUID_ONLY}'== 'OFF':
189
- # change rpath of _swig_paddle.so.
184
+ if '${CMAKE_BUILD_TYPE}' == 'Release':
185
+ # only change rpath in Release mode, since in Debug mode, core.so is too large to be changed.
190
186
if "@APPLE@" == "1":
191
- command = "install_name_tool -id \"@loader_path/../paddle/ libs/\" ${PADDLE_BINARY_DIR}/python/py_paddle/_swig_paddle .so"
187
+ command = "install_name_tool -id \"@loader_path/../libs/\" ${PADDLE_BINARY_DIR}/python/paddle/fluid/core .so"
192
188
else:
193
- command = "patchelf --set-rpath '$ORIGIN/../paddle/ libs/' ${PADDLE_BINARY_DIR}/python/py_paddle/_swig_paddle .so"
189
+ command = "patchelf --set-rpath '$ORIGIN/../libs/' ${PADDLE_BINARY_DIR}/python/paddle/fluid/core .so"
194
190
if os.system(command) != 0:
195
- raise Exception("patch _swig_paddle.so failed, command: %s" % command)
191
+ raise Exception("patch core.so failed, command: %s" % command)
192
+ if '${WITH_FLUID_ONLY}'== 'OFF':
193
+ # change rpath of _swig_paddle.so.
194
+ if "@APPLE@" == "1":
195
+ command = "install_name_tool -id \"@loader_path/../paddle/libs/\" ${PADDLE_BINARY_DIR}/python/py_paddle/_swig_paddle.so"
196
+ else:
197
+ command = "patchelf --set-rpath '$ORIGIN/../paddle/libs/' ${PADDLE_BINARY_DIR}/python/py_paddle/_swig_paddle.so"
198
+ if os.system(command) != 0:
199
+ raise Exception("patch _swig_paddle.so failed, command: %s" % command)
196
200
197
201
setup(name='${PACKAGE_NAME}',
198
202
version='${PADDLE_VERSION}',
0 commit comments