From 42f6facc3006b84fb7d131780f2287aa7ab73193 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sat, 26 Nov 2016 00:45:27 +0200 Subject: [PATCH] Add support for the new LibreOffice presentations on macOS via Pyro4 --- osx/macosx-builder.py | 49 ++++++++++++++++++- ...ugins.presentations.lib.maclocontroller.py | 23 +++++++++ ...lugins.presentations.presentationplugin.py | 1 + pyinstaller-hooks/hook-openlp.py | 20 ++++---- 4 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 pyinstaller-hooks/hook-openlp.plugins.presentations.lib.maclocontroller.py diff --git a/osx/macosx-builder.py b/osx/macosx-builder.py index 57ef00d..c7f5253 100644 --- a/osx/macosx-builder.py +++ b/osx/macosx-builder.py @@ -66,6 +66,10 @@ Mako Alembic Required for upgrading the databases used in OpenLP. +Pyro4 + Required for the macOS LibreOffice integration. Install the version from + MacPorts. + MuPDF Required for PDF support in OpenLP. Install using macports, or use the mudrawbin option in the config file to point to the mudraw binary. @@ -98,6 +102,7 @@ import plistlib import signal import subprocess import sys +from glob import glob from shutil import copy, copytree, rmtree from subprocess import Popen, PIPE from configparser import ConfigParser @@ -214,6 +219,8 @@ class MacosxBuilder(object): parser.add_argument('--transifex-pass', dest='transifex_pass', help='Transifex password.') parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False, help='Print out additional information.') + parser.add_argument('-p', '--with-pyro', action='store_true', default=False, + help='Build OpenLP with Pyro4 (for LibreOffice). Defaults to False') self.args = parser.parse_args() def read_config(self): @@ -223,7 +230,11 @@ class MacosxBuilder(object): self.config = ConfigParser(defaults={ 'here': self.script_path, 'projects': os.path.abspath(os.path.join(self.script_path, '..', '..')), }) - self.config.read(os.path.abspath(self.args.config)) + config_file = os.path.abspath(self.args.config) + if not os.path.exists(config_file): + self._print('Config file does not exist: %s' % config_file) + raise SystemExit() + self.config.read(config_file) def setup_system_paths(self): """ @@ -296,6 +307,13 @@ class MacosxBuilder(object): if code != 0: self._print(output) raise Exception('Error reverting the code') + self._print('Cleaning any extra files...') + bzr = Popen(['bzr', 'clean-tree', '--quiet', '--force', '--ignored', '--unknown'], stdout=PIPE) + output = bzr.communicate()[0] + code = bzr.wait() + if code != 0: + self._print(output) + raise Exception('Error cleaning extra files') self._print('Updating the code...') bzr = Popen(('bzr', 'update'), stdout=PIPE) output = bzr.communicate()[0] @@ -429,6 +447,33 @@ class MacosxBuilder(object): self._print_verbose('... %s', filename) copy(os.path.join(root, filename), os.path.join(dest_path, filename)) + def install_pyro4(self): + """ + Install Pyro4 for the macOS Impress module + """ + self._print('Installing Pyro4 for LibreOffice...') + target = os.path.join(self.dist_path, 'plugins', 'presentations', 'lib', 'vendor') + command = [ + self.python, + '-m', + 'pip', + 'install', + 'Pyro4==4.38', + '-t', + target, + '--disable-pip-version-check', + '--no-compile' + ] + pip = Popen(command) + code = pip.wait() + if code != 0: + raise Exception('Error running pip') + egg_info_glob = glob(target + '/*.egg-info') + egg_info_glob.extend(glob(target + '/*.dist-info')) + self._print_verbose('... glob: %s' % egg_info_glob) + for path in egg_info_glob: + rmtree(path, True) + def copy_mac_bundle_files(self): """ Copy Info.plist and OpenLP.icns to app bundle. @@ -693,6 +738,8 @@ class MacosxBuilder(object): self.copy_default_theme() self.copy_plugins() self.copy_media_player() + if self.args.with_pyro: + self.install_pyro4() # TODO creating help on Mac if os.path.exists(self.manual_path): self.run_sphinx() diff --git a/pyinstaller-hooks/hook-openlp.plugins.presentations.lib.maclocontroller.py b/pyinstaller-hooks/hook-openlp.plugins.presentations.lib.maclocontroller.py new file mode 100644 index 0000000..f8413eb --- /dev/null +++ b/pyinstaller-hooks/hook-openlp.plugins.presentations.lib.maclocontroller.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 + +############################################################################### +# OpenLP - Open Source Lyrics Projection # +# --------------------------------------------------------------------------- # +# Copyright (c) 2008-2015 OpenLP Developers # +# --------------------------------------------------------------------------- # +# This program is free software; you can redistribute it and/or modify it # +# under the terms of the GNU General Public License as published by the Free # +# Software Foundation; version 2 of the License. # +# # +# This program is distributed in the hope that it will be useful, but WITHOUT # +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # +# more details. # +# # +# You should have received a copy of the GNU General Public License along # +# with this program; if not, write to the Free Software Foundation, Inc., 59 # +# Temple Place, Suite 330, Boston, MA 02111-1307 USA # +############################################################################### + +hiddenimports = ['Pyro4'] diff --git a/pyinstaller-hooks/hook-openlp.plugins.presentations.presentationplugin.py b/pyinstaller-hooks/hook-openlp.plugins.presentations.presentationplugin.py index 9fe30ad..77ace43 100644 --- a/pyinstaller-hooks/hook-openlp.plugins.presentations.presentationplugin.py +++ b/pyinstaller-hooks/hook-openlp.plugins.presentations.presentationplugin.py @@ -21,6 +21,7 @@ ############################################################################### hiddenimports = ['openlp.plugins.presentations.lib.impresscontroller', + 'openlp.plugins.presentations.lib.maclocontroller', 'openlp.plugins.presentations.lib.pdfcontroller', 'openlp.plugins.presentations.lib.powerpointcontroller', 'openlp.plugins.presentations.lib.pptviewcontroller'] diff --git a/pyinstaller-hooks/hook-openlp.py b/pyinstaller-hooks/hook-openlp.py index c14ed1b..59f2f06 100644 --- a/pyinstaller-hooks/hook-openlp.py +++ b/pyinstaller-hooks/hook-openlp.py @@ -20,12 +20,14 @@ # Temple Place, Suite 330, Boston, MA 02111-1307 USA # ############################################################################### -hiddenimports = ['openlp.plugins.songs.songsplugin', - 'openlp.plugins.bibles.bibleplugin', - 'openlp.plugins.presentations.presentationplugin', - 'openlp.plugins.media.mediaplugin', - 'openlp.plugins.images.imageplugin', - 'openlp.plugins.custom.customplugin', - 'openlp.plugins.songusage.songusageplugin', - 'openlp.plugins.remotes.remoteplugin', - 'openlp.plugins.alerts.alertsplugin'] +hiddenimports = [ + 'openlp.plugins.songs.songsplugin', + 'openlp.plugins.bibles.bibleplugin', + 'openlp.plugins.presentations.presentationplugin', + 'openlp.plugins.media.mediaplugin', + 'openlp.plugins.images.imageplugin', + 'openlp.plugins.custom.customplugin', + 'openlp.plugins.songusage.songusageplugin', + 'openlp.plugins.remotes.remoteplugin', + 'openlp.plugins.alerts.alertsplugin' +]