Enhance macOS build lib cleanup
Update the macOS build workflow to robustly locate and clean multiple library directories inside the .app bundle. Instead of a single lib path, the script now finds all 'lib' dirs containing PySide6 or ytsage and iterates over them. Cleanup expanded to handle alternate PySide6 paths (PySide6/Qt/translations, PySide6/Qt/plugins), more plugin/imageformat variants (.dylib/.so), additional Qt library name patterns (Qt6*, framework-style names) and Qt6DBus, and removal of common build tools/modules. Adds logging and a warning when no library dirs are found.
This commit is contained in:
@@ -206,66 +206,73 @@ jobs:
|
|||||||
echo "Processing App Bundle at: $app_path"
|
echo "Processing App Bundle at: $app_path"
|
||||||
|
|
||||||
# Determine Lib directory (standard location vs customized)
|
# Determine Lib directory (standard location vs customized)
|
||||||
# We look for 'os.py' or 'ytsage' folder to be sure
|
# We look for all 'lib' directories that contain 'PySide6' or 'ytsage' to be thorough
|
||||||
lib_dir=$(find "$app_path/Contents" -type d -name "ytsage" | head -n1 | xargs dirname)
|
# resulting in potentially multiple lib dirs to clean (e.g. MacOS/lib and Resources/lib)
|
||||||
|
lib_dirs=$(find "$app_path/Contents" -type d -name "lib" | while read -r d; do if [ -d "$d/ytsage" ] || [ -d "$d/PySide6" ]; then echo "$d"; fi; done)
|
||||||
|
|
||||||
if [ -z "$lib_dir" ]; then
|
if [ -z "$lib_dirs" ]; then
|
||||||
# Fallback standard cx_Freeze locations
|
echo "Warning: No valid Library directory found. Skipping deep trim."
|
||||||
if [ -d "$app_path/Contents/MacOS/lib" ]; then
|
|
||||||
lib_dir="$app_path/Contents/MacOS/lib"
|
|
||||||
elif [ -d "$app_path/Contents/Resources/lib" ]; then
|
|
||||||
lib_dir="$app_path/Contents/Resources/lib"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Detected Lib Directory: $lib_dir"
|
for lib_dir in $lib_dirs; do
|
||||||
|
echo "Processing Lib Directory: $lib_dir"
|
||||||
if [ -d "$lib_dir" ]; then
|
|
||||||
# 1. Remove screenshots
|
|
||||||
rm -rf "$lib_dir/assets/branding/screenshots"
|
|
||||||
echo "Removed screenshots folder"
|
|
||||||
|
|
||||||
# 2. Remove unused Qt translations
|
# 1. Remove screenshots
|
||||||
rm -rf "$lib_dir/PySide6/translations"
|
rm -rf "$lib_dir/assets/branding/screenshots"
|
||||||
echo "Removed Qt translations"
|
echo "Removed screenshots folder"
|
||||||
|
|
||||||
# 3. Remove unused Qt plugins
|
# 2. Remove unused Qt translations (Path varies: PySide6/translations or PySide6/Qt/translations)
|
||||||
plugins_dir="$lib_dir/PySide6/plugins"
|
rm -rf "$lib_dir/PySide6/translations"
|
||||||
for plugin in designer pdf svg sql help qml quick webengine bluetooth opengl printsupport test xml; do
|
rm -rf "$lib_dir/PySide6/Qt/translations"
|
||||||
if [ -d "$plugins_dir/$plugin" ]; then
|
echo "Removed Qt translations"
|
||||||
rm -rf "$plugins_dir/$plugin"
|
|
||||||
echo "Removed plugin folder: $plugin"
|
# 3. Remove unused Qt plugins
|
||||||
fi
|
# Path varies: PySide6/plugins or PySide6/Qt/plugins
|
||||||
done
|
for plugins_base in "$lib_dir/PySide6/plugins" "$lib_dir/PySide6/Qt/plugins"; do
|
||||||
|
if [ -d "$plugins_base" ]; then
|
||||||
# 3.1. Explicitly remove specific input contexts and image formats
|
for plugin in designer pdf svg sql help qml quick webengine bluetooth opengl printsupport test xml; do
|
||||||
rm -rf "$plugins_dir/platforminputcontexts"
|
if [ -d "$plugins_base/$plugin" ]; then
|
||||||
# Note: macOS libs usually have .dylib extension or no extension in bundles, or .so for python modules
|
rm -rf "$plugins_base/$plugin"
|
||||||
# We try removing common variants
|
echo "Removed plugin folder: $plugin from $plugins_base"
|
||||||
rm -f "$plugins_dir/imageformats/libqpdf.dylib" "$plugins_dir/imageformats/libqsvg.dylib"
|
fi
|
||||||
rm -f "$plugins_dir/imageformats/qpdf.dylib" "$plugins_dir/imageformats/qsvg.dylib"
|
done
|
||||||
rm -f "$plugins_dir/iconengines/libqsvgicon.dylib" "$plugins_dir/iconengines/qsvgicon.dylib"
|
|
||||||
|
# 3.1. Explicitly remove specific input contexts and image formats
|
||||||
# 4. Remove any duplicate or unnecessary Qt Libraries (DLLs/dylibs)
|
rm -rf "$plugins_base/platforminputcontexts"
|
||||||
# Targeting root lib and PySide6 internal lib
|
rm -f "$plugins_base/imageformats/libqpdf.dylib" "$plugins_base/imageformats/libqsvg.dylib"
|
||||||
# Patterns match both .so, .dylib, and .framework style naming
|
rm -f "$plugins_base/imageformats/libqpdf.so" "$plugins_base/imageformats/libqsvg.so" # just in case
|
||||||
echo "Removing bloat Qt libraries..."
|
rm -f "$plugins_base/iconengines/libqsvgicon.dylib"
|
||||||
find "$lib_dir" -name "Qt6Web*" -delete
|
fi
|
||||||
find "$lib_dir" -name "Qt6Pdf*" -delete
|
done
|
||||||
find "$lib_dir" -name "Qt6Qml*" -delete
|
|
||||||
find "$lib_dir" -name "Qt6Quick*" -delete
|
# 4. Remove any duplicate or unnecessary Qt Libraries (DLLs/dylibs/frameworks)
|
||||||
find "$lib_dir" -name "Qt6VirtualKeyboard*" -delete
|
# On macOS, these often appear as files with no extension (e.g. 'QtQml') or .dylib
|
||||||
find "$lib_dir" -name "Qt6OpenGL*" -delete
|
# We remove both variants and also the 'Qt6' prefixed ones just in case
|
||||||
|
echo "Removing bloat Qt libraries..."
|
||||||
# 5. Remove build tools and unused python modules
|
|
||||||
for tool in setuptools wheel pkg_resources _distutils_hack curses _pyrepl; do
|
# Standard patterns (Linux/Windows style)
|
||||||
rm -rf "$lib_dir/$tool"
|
find "$lib_dir" -name "*Qt6Web*" -delete
|
||||||
echo "Removed build tool/module: $tool"
|
find "$lib_dir" -name "*Qt6Pdf*" -delete
|
||||||
done
|
find "$lib_dir" -name "*Qt6Qml*" -delete
|
||||||
|
find "$lib_dir" -name "*Qt6Quick*" -delete
|
||||||
else
|
find "$lib_dir" -name "*Qt6VirtualKeyboard*" -delete
|
||||||
echo "Warning: Library directory could not be precisely determined. Skipping deep trim."
|
find "$lib_dir" -name "*Qt6OpenGL*" -delete
|
||||||
fi
|
find "$lib_dir" -name "*Qt6DBus*" -delete
|
||||||
|
|
||||||
|
# macOS Framework style (No '6' in name usually, e.g. QtQml, QtQuick)
|
||||||
|
# Be careful not to delete QtQuickWidgets if used (though usually safe if Quick is gone)
|
||||||
|
# We use known specific lists to avoid over-deleting
|
||||||
|
for bloat in QtQml QtQmlMeta QtQmlModels QtQmlWorkerScript QtQuick QtQuickControls2 QtQuickTemplates2 QtWebEngine QtWebEngineCore QtVirtualKeyboard QtVirtualKeyboardQml QtOpenGL QtOpenGLWidgets QtPdf QtPdfWidgets QtDBus; do
|
||||||
|
find "$lib_dir" -maxdepth 1 -name "$bloat" -delete
|
||||||
|
find "$lib_dir" -maxdepth 1 -name "${bloat}.*" -delete # Matches versions or extensions
|
||||||
|
done
|
||||||
|
|
||||||
|
# 5. Remove build tools and unused python modules
|
||||||
|
for tool in setuptools wheel pkg_resources _distutils_hack curses _pyrepl; do
|
||||||
|
rm -rf "$lib_dir/$tool"
|
||||||
|
echo "Removed build tool/module: $tool"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "Error: Could not find .app bundle to trim!"
|
echo "Error: Could not find .app bundle to trim!"
|
||||||
|
|||||||
Reference in New Issue
Block a user