From eef1ff3dabda3cc9e6f2ae66788e70c3e171dfc3 Mon Sep 17 00:00:00 2001 From: Dominik Holland Date: Thu, 24 Feb 2022 11:02:37 +0100 Subject: Fix virtualenv deployment on macos Also copy the Python.framework into the virtualenv to make it fully self-contained. Fixes: QTBUG-98814 Change-Id: I28c65ba944bd787cf645246e5638a56fa9dd3f29 Reviewed-by: Robert Griebl --- src/tools/ivigenerator/deploy-virtualenv.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/tools/ivigenerator/deploy-virtualenv.sh b/src/tools/ivigenerator/deploy-virtualenv.sh index 45217e8..72357be 100755 --- a/src/tools/ivigenerator/deploy-virtualenv.sh +++ b/src/tools/ivigenerator/deploy-virtualenv.sh @@ -117,6 +117,21 @@ if [ "$PLATFORM" == "linux" ]; then echo "copying $LIBSSL" cp -Lf "$LIBSSL" "$VIRTUALENV/bin" fi +else + # Find the linked Python lib and its framework + VERSION_STR=`$VIRTUALENV/bin/python -c "import sys; print(\"{0}.{1}\".format(sys.version_info.major, sys.version_info.minor))"` + PYTHON_LIB_PATH=`otool -L $VIRTUALENV/bin/python | awk '{print $1}' | grep Python` + PYTHON_FRAMEWORK_PATH=`otool -L $VIRTUALENV/bin/python | egrep -o '^.*Python.framework'` + # Copy the framework into our virtualenv + cp -a $PYTHON_FRAMEWORK_PATH $VIRTUALENV/bin + # Delete the python folder from the framework as we already have that in our virtualenv + rm -rf $VIRTUALENV/bin/Python.framework/Versions/$VERSION_STR/lib/$PYTHON_VERSION + rm -rf $VIRTUALENV/bin/Python.framework/Versions/2* + ln -sf $VERSION_STR $VIRTUALENV/bin/Python.framework/Versions/Current + # Use the copied framework in the python binary + install_name_tool -change $PYTHON_LIB_PATH @executable_path/Python.framework/Versions/Current/Python $VIRTUALENV/bin/python + # And fix the reference of the Python.app inside the framework + install_name_tool -change $PYTHON_LIB_PATH @loader_path/../../../../Python $VIRTUALENV/bin/Python.framework/Versions/Current/Resources/Python.app/Contents/MacOS/Python fi # some files might have wrong permissions, e.g. readonly -- cgit v1.2.1