From 326e61ec51be3c7d3a0138580ef5ff12fdea36de Mon Sep 17 00:00:00 2001 From: Erik Gomez Date: Mon, 14 Dec 2020 17:17:39 -0600 Subject: [PATCH] confirm universal before going to next step --- build_python_framework_pkgs.zsh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/build_python_framework_pkgs.zsh b/build_python_framework_pkgs.zsh index f4a4c95..9dc6cd9 100755 --- a/build_python_framework_pkgs.zsh +++ b/build_python_framework_pkgs.zsh @@ -151,6 +151,29 @@ echo "Adding ad-hoc code signing so the framework will run on Apple Silicon..." /usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib/" -type f -perm -u=x -exec /usr/bin/codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; /usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib/" -type f -name "*dylib" -exec /usr/bin/codesign -s - --preserve-metadata=identifier,entitlements,flags,runtime -f {} \; +# confirm truly universal +TOTAL_DYLIB=$(/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib" -name "*.dylib" | /usr/bin/wc -l | /usr/bin/xargs) +UNIVERSAL_DYLIB=$(/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib" -name "*.dylib" | /usr/bin/xargs file | /usr/bin/grep "2 architectures" | /usr/bin/wc -l | /usr/bin/xargs) +if [ "${TOTAL_DYLIB}" != "${UNIVERSAL_DYLIB}" ] ; then + echo "Dynamic Libraries do not match, resulting in a non-universal Python framework." + echo "Total Dynamic Libraries found: ${TOTAL_DYLIB}" + echo "Universal Dynamic Libraries found: ${UNIVERSAL_DYLIB}" + exit 1 +fi + +echo "Dynamic Libraries are confirmed as universal" + +TOTAL_SO=$(/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib" -name "*.so" | /usr/bin/wc -l | /usr/bin/xargs) +UNIVERSAL_SO=$(/usr/bin/find "$TOOLSDIR/$TYPE/payload/${FRAMEWORKDIR}/Python3.framework/Versions/Current/lib" -name "*.so" | /usr/bin/xargs file | /usr/bin/grep "2 architectures" | /usr/bin/wc -l | /usr/bin/xargs) +if [ "${TOTAL_SO}" != "${UNIVERSAL_SO}" ] ; then + echo "Shared objects do not match, resulting in a non-universal Python framework." + echo "Total shared objects found: ${TOTAL_SO}" + echo "Universal shared objects found: ${UNIVERSAL_SO}" + exit 1 +fi + +echo "Shared objects are confirmed as universal" + # make a symbolic link to help with interactive use /bin/ln -s "$PYTHON_BIN" "$TOOLSDIR/$TYPE/payload/usr/local/bin/managed_python3"