Skip to content

Commit

Permalink
Fix Linux distribution by removing unwanted stuff from PyQt5 (#135) +…
Browse files Browse the repository at this point in the history
… fontconfig/freetype

* Deleted other workflows

* Removed unwanted stuff from PyQt5

* Remove libfontconfig and libfreetype also

* Revert "Deleted other workflows"

This reverts commit 3ff9939.
  • Loading branch information
FrodeSolheim authored Nov 29, 2021
1 parent 2f6eebc commit f5214ec
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fsbuild/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ make

BUILDDIR=fsbuild/_build

# Remove files from PyQt5 that we don't want to bundle (before pyinstaller
# pulls in their dependencies).
python3 fsbuild/fix-pyqt5.py

rm -Rf $BUILDDIR/pyinstaller
if [ "$SYSTEM_OS" = "Windows" ]; then
pyinstaller \
Expand All @@ -30,6 +34,13 @@ pyinstaller \
--log-level DEBUG \
$PACKAGE_NAME
BINDIR=fsbuild/_build/pyinstaller/$PACKAGE_NAME
# Fontconfig in particular can crash the application because it conflicts
# with system font cache or config files. For now, assume these library are
# always present and use the system ones.
echo "rm $BINDIR/libfreetype.so.6"
rm $BINDIR/libfreetype.so.6
echo "rm $BINDIR/libfontconfig.so.1"
rm $BINDIR/libfontconfig.so.1
fi

# These do not work with macOS notarization, but might as well remove for all
Expand Down
46 changes: 46 additions & 0 deletions fsbuild/fix-pyqt5.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
import os
import shutil
import sys

from PyQt5.QtCore import QLibraryInfo


def main():
# This is mainly to avoid bundling libraries that can cause issues,
# such as GTK (and dependencies) being included if GTK platform
# integration is included.
print("Fixing PyQt5 installation before running pyinstaller")
print("(Removing unnecessary stuff")

# librariesPath = QLibraryInfo.location(QLibraryInfo.LibrariesPath)
# print(librariesPath)

def removePath(path):
print(path)
if os.path.exists(path):
print("Removing", path)
shutil.rmtree(path)

qmlPath = QLibraryInfo.location(QLibraryInfo.Qml2ImportsPath)
removePath(qmlPath)

translationsPath = QLibraryInfo.location(QLibraryInfo.TranslationsPath)
removePath(translationsPath)

pluginsPath = QLibraryInfo.location(QLibraryInfo.PluginsPath)
print(pluginsPath)

def removePlugins(type):
pluginTypePath = os.path.join(pluginsPath, type)
print(pluginTypePath)
if os.path.exists(pluginTypePath):
print("Removing", pluginTypePath)
shutil.rmtree(pluginTypePath)

if sys.platform == "linux":
removePlugins("platformthemes")


if __name__ == "__main__":
main()

0 comments on commit f5214ec

Please sign in to comment.