Skip to content
Snippets Groups Projects
Commit a1332fdb authored by Matt Harbison's avatar Matt Harbison
Browse files

packaging: conditionalize the macOS build script to support both Qt5 and Qt6

The version can be overridden by setting `QT_MAJOR` to 5 or 6 in the environment,
but it tries to do the right thing by default.  I didn't check that all of the
same libraries are in the app bundle and need to be removed that are in the Qt5
app, but when skipping that section of post-build customizing, `codesign`
reported that it wasn't signed properly.  It's just easier to run through it for
now and re-sign at the end.

Qt5 doesn't support arm64, and requires Rosetta to be installed to run it.
Unfortunately, while python, py2app, and PyQt6 are all universal2 binaries, the
libraries installed for Qt6 are thin binaries.  Maybe there's a way to download
the wheels for both architectures and smash them together.  Perhaps with
something like this:

  https://github.com/ronaldoussoren/py2app/issues/399#issuecomment-1709305758

For now, we'll just have to build 2 things on two different machines.

We might also have the opposite problem we had before with py2app being a
universal binary, and defaulting to running the arm64 image on Apple Silicon- it
will want to run the amd64 image on an Intel mac, and crash on startup if it was
built for AS because the Qt6 libraries are the wrong architecture again.  But
since I expect the Qt6 stuff to be less stable, let's not worry about removing
the amd64 image when building on AS like we do the arm64 image with Qt5 builds.
parent 8c082e3c
No related branches found
No related tags found
No related merge requests found
Pipeline #97335 canceled
......@@ -2,4 +2,24 @@
set -euo pipefail
DEFAULT_QT_MAJOR="5"
# Default to Qt6 on arm64 because Qt5 isn't supported there and it's unclear
# if/how to support cross compiling without Rosetta.
if [[ `arch` == arm64 ]]; then
DEFAULT_QT_MAJOR="6"
fi
QT_MAJOR="${QT_MAJOR:-${DEFAULT_QT_MAJOR}}"
case ${QT_MAJOR} in
"5"|"6")
;;
*)
echo "Only '5' or '6' is supported for QT_MAJOR: ${QT_MAJOR}"
exit 1
;;
esac
export APP_NAME="TortoiseHg"
......@@ -5,5 +25,5 @@
export APP_NAME="TortoiseHg"
export QT_VERSION="qt5"
export QT_VERSION="qt${QT_MAJOR}"
PYTHON=${PYTHON:-python3}
HERE="$(hg root)/contrib/packaging/macos"
......@@ -14,7 +34,7 @@
echo "Creating venv $VENV"
${PYTHON} -m venv --copies "${VENV}"
${VENV}/bin/pip --disable-pip-version-check install -U wheel==0.37.0
${VENV}/bin/pip --disable-pip-version-check install -r "${HERE}/requirements-pyqt5.txt"
${VENV}/bin/pip --disable-pip-version-check install -r "${HERE}/requirements-pyqt${QT_MAJOR}.txt"
else
echo "Reusing venv $VENV"
fi
......@@ -43,7 +63,7 @@
APP="dist/${APP_NAME}.app"
rm "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/"*.pyi
rm -r "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/Qt5/qml"
rm "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/"*.pyi
rm -r "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/Qt${QT_MAJOR}/qml"
# Trim down to plugins bundled with the py2 app
......@@ -48,6 +68,6 @@
# Trim down to plugins bundled with the py2 app
for f in "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/Qt5/plugins/"*; do
for f in "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/Qt${QT_MAJOR}/plugins/"*; do
case "${f##*/}" in
iconengines | imageformats | platforms | printsupport)
continue
......@@ -63,7 +83,7 @@
# the app on launch if not present. QtMacExtras.framework is needed to load some
# icons on launch.
for f in "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/Qt5/lib/"*.framework; do
for f in "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/Qt${QT_MAJOR}/lib/"*.framework; do
framework="${f##*/}"
base="${framework%.*}"
......@@ -75,8 +95,8 @@
echo "Deleting ${base} components"
rm -f "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/${base}.abi3.so"
rm -rf "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt5/bindings/${base}"
rm -f "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/${base}.abi3.so"
rm -rf "${APP}/Contents/Resources/lib/python${PYVERSION}/PyQt${QT_MAJOR}/bindings/${base}"
rm -r "${f}"
done
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment