From bb1b6b773be54d3457cd809628f5c41fd00a1f90 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Tue, 10 Dec 2019 04:07:44 +0000 Subject: [PATCH] Fix various parts of the build script for the macOS build --- .flake8 | 2 ++ .gitignore | 3 +++ builders/macosx-builder.py | 25 ++++++++++++++++--------- osx/settings.py | 2 +- 4 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 .flake8 create mode 100644 .gitignore diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..aa079ec --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +max-line-length=120 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8319c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +__pycache__ +*.pyc +config.ini diff --git a/builders/macosx-builder.py b/builders/macosx-builder.py index e48ef69..77a7c0f 100644 --- a/builders/macosx-builder.py +++ b/builders/macosx-builder.py @@ -135,7 +135,7 @@ class MacOSXBuilder(Builder): folder.symlink_to(good_path) - def _fix_qt_dll(self, dll): + def _fix_qt_dll(self, dll_file): """ Fix the DLL lookup paths to use relative ones for Qt dependencies. Inspiration: PyInstaller/depend/dylib.py:mac_set_relative_dylib_deps() @@ -158,15 +158,19 @@ class MacOSXBuilder(Builder): return None return f'@loader_path{good_path}/{basename}' + # Skip it if it's not a dylib file + if dll_file.suffix != '.dylib': + return + # Resources/PyQt5/Qt/qml/QtQuick/Controls.2/Fusion - root = str(dll.parent).partition('Contents')[2][1:] + root = str(dll_file.parent).partition('Contents')[2][1:] # /../../../../../../.. backward = '/..' * len(root.split('/')) # /../../../../../../../MacOS good_path = f'{backward}/MacOS' # Rewrite Mach headers with corrected @loader_path - dll = MachO(dll) + dll = MachO(dll_file) dll.rewriteLoadCommands(match_func) with open(dll.filename, 'rb+') as f: for header in dll.headers: @@ -183,7 +187,7 @@ class MacOSXBuilder(Builder): if not path.is_dir() or path.is_symlink(): # Skip simlinks as they are allowed (even with a dot) continue - if '.' in path.name: + if path.name == 'qml': yield path else: yield from self._find_problematic_qt_folders(path) @@ -199,6 +203,7 @@ class MacOSXBuilder(Builder): yield from self._move_contents_to_resources(path) else: sibling = Path(str(path).replace('MacOS', 'Resources')) + sibling.parent.mkdir(parents=True, exist_ok=True) move(path, sibling) yield sibling @@ -213,9 +218,9 @@ class MacOSXBuilder(Builder): rmtree(folder) self._create_symlink(folder) - def _relink_mupdf(self, bin_name): + def _relink_binary(self, bin_name): """ - Relink mupdf to bundled libraries + Relink bundled libraries """ self._print('Linking {bin_name} with bundled libraries...'.format(bin_name=bin_name)) libname = os.path.join(self.dist_path, bin_name) @@ -263,13 +268,13 @@ class MacOSXBuilder(Builder): """ Relink mudraw to bundled libraries """ - self._relink_mupdf('mudraw') + self._relink_binary('mudraw') def _relink_mutool(self): """ Relink mudraw to bundled libraries """ - self._relink_mupdf('mutool') + self._relink_binary('mutool') def _install_pyro4(self): """ @@ -296,6 +301,7 @@ class MacOSXBuilder(Builder): for fname in ['libvlc.dylib', 'libvlccore.dylib']: self._print_verbose('... {}'.format(fname)) copy(os.path.join(vlc_path, 'lib', fname), os.path.join(vlc_dest, fname)) + self._relink_binary(os.path.join('vlc', fname)) if os.path.exists(os.path.join(vlc_dest, 'plugins')): rmtree(os.path.join(vlc_dest, 'plugins')) self._print_verbose('... copying VLC plugins') @@ -404,7 +410,8 @@ class MacOSXBuilder(Builder): Copy any extra files which are particular to a platform """ self._print('Copying extra files for macOS...') - self._copy_vlc_files() + # Exclude VLC for now, at least + # self._copy_vlc_files() self._copy_bundle_files() self._copy_macosx_files() diff --git a/osx/settings.py b/osx/settings.py index f584922..379e84e 100644 --- a/osx/settings.py +++ b/osx/settings.py @@ -29,7 +29,7 @@ import os HERE = os.getcwd() format = 'UDBZ' -size = '600M' +size = '850M' files = [defines.get('app', '/Applications/OpenLP.app')] symlinks = { 'Applications': '/Applications' } badge_icon = os.path.join(HERE, 'OpenLP.icns')