@@ -44,7 +44,7 @@ sed "${sed_args[@]}" "s|/tools/host|${TOOLS_PATH}/host|g" ${TOOLS_PATH}/host/sha
4444# We force linking of external static libraries by removing the shared
4545# libraries. This is hacky. But we're building in a temporary container
4646# and it gets the job done.
47- find ${TOOLS_PATH} /deps -name ' *.so*' -exec rm {} \;
47+ find ${TOOLS_PATH} /deps -name ' *.so*' -a \! \( -name ' libtcl*.so* ' -or -name ' libtk*.so* ' \) - exec rm {} \;
4848
4949tar -xf Python-${PYTHON_VERSION} .tar.xz
5050
@@ -705,6 +705,8 @@ if [ "${PYBUILD_SHARED}" = "1" ]; then
705705 ${ROOT} /out/python/install/bin/python${PYTHON_MAJMIN_VERSION}
706706
707707 # Python's build system doesn't make this file writable.
708+ # TODO(geofft): @executable_path/ is a weird choice here, who is
709+ # relying on it? Should probably be @loader_path.
708710 chmod 755 ${ROOT} /out/python/install/lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME}
709711 install_name_tool \
710712 -change /install/lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME} @executable_path/${LIBPYTHON_SHARED_LIBRARY_BASENAME} \
@@ -723,6 +725,13 @@ if [ "${PYBUILD_SHARED}" = "1" ]; then
723725 -change /install/lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME} @executable_path/../lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME} \
724726 ${ROOT} /out/python/install/bin/python${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX}
725727 fi
728+
729+ # At the moment, python3 and libpython don't have shared-library
730+ # dependencies, but at some point we will want to run this for
731+ # them too.
732+ for module in ${ROOT} /out/python/install/lib/python* /lib-dynload/* .so; do
733+ install_name_tool -add_rpath @loader_path/../.. " $module "
734+ done
726735 else # (not macos)
727736 LIBPYTHON_SHARED_LIBRARY_BASENAME=libpython${PYTHON_MAJMIN_VERSION}${PYTHON_BINARY_SUFFIX} .so.1.0
728737 LIBPYTHON_SHARED_LIBRARY=${ROOT} /out/python/install/lib/${LIBPYTHON_SHARED_LIBRARY_BASENAME}
@@ -1250,6 +1259,12 @@ if [ -d "${TOOLS_PATH}/deps/lib/tcl8" ]; then
12501259 for source in ${TOOLS_PATH} /deps/lib/{itcl4.2.4,tcl8,tcl8.6,thread2.8.9,tk8.6}; do
12511260 cp -av $source ${ROOT} /out/python/install/lib/
12521261 done
1262+
1263+ if [[ " ${PYBUILD_PLATFORM} " == macos* ]]; then
1264+ cp -av ${TOOLS_PATH} /deps/lib/lib* .dylib ${ROOT} /out/python/install/lib/
1265+ else
1266+ cp -av ${TOOLS_PATH} /deps/lib/lib* .so ${ROOT} /out/python/install/lib/
1267+ fi
12531268fi
12541269
12551270# Copy the terminfo database if present.
0 commit comments