summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2022-02-24 11:02:37 +0100
committerDominik Holland <dominik.holland@qt.io>2022-02-24 19:05:34 +0100
commiteef1ff3dabda3cc9e6f2ae66788e70c3e171dfc3 (patch)
treeb6aafcb1d809c3f97f11a85debcfe5390159132d
parent7104ba31e464fcc5b5c506595035560d0cdd6cb3 (diff)
downloadqtivi-eef1ff3dabda3cc9e6f2ae66788e70c3e171dfc3.tar.gz
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 <robert.griebl@qt.io>
-rwxr-xr-xsrc/tools/ivigenerator/deploy-virtualenv.sh15
1 files changed, 15 insertions, 0 deletions
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