2012-06-09 19:02:47 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2011 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2011 Tim Bentley, Jonathan Corwin, Michael #
|
|
|
|
# Gorven, Scott Guerrieri, Matthias Hub, Meinert Jordan, Armin Köhler, #
|
|
|
|
# Andreas Preikschat, Mattias Põldaru, Christian Richter, Philip Ridout, #
|
|
|
|
# Jeffrey Smith, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Frode #
|
|
|
|
# Woldsund #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# 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 #
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
"""
|
|
|
|
Windows Build Script
|
|
|
|
--------------------
|
|
|
|
|
|
|
|
This script is used to build the Windows binary and the accompanying installer.
|
|
|
|
For this script to work out of the box, it depends on a number of things:
|
|
|
|
|
|
|
|
Python 2.6/2.7
|
|
|
|
|
|
|
|
PyQt4
|
|
|
|
You should already have this installed, OpenLP doesn't work without it. The
|
|
|
|
version the script expects is the packaged one available from River Bank
|
|
|
|
Computing.
|
|
|
|
|
|
|
|
PyEnchant
|
|
|
|
This script expects the precompiled, installable version of PyEnchant to be
|
|
|
|
installed. You can find this on the PyEnchant site.
|
|
|
|
|
|
|
|
Inno Setup 5
|
|
|
|
Inno Setup should be installed into "C:\%PROGRAMFILES%\Inno Setup 5"
|
|
|
|
|
|
|
|
Sphinx
|
|
|
|
This is used to build the documentation. The documentation trunk must be at
|
|
|
|
the same directory level as OpenLP trunk and named "documentation".
|
|
|
|
|
|
|
|
HTML Help Workshop
|
|
|
|
This is used to create the help file.
|
|
|
|
|
|
|
|
PyInstaller
|
|
|
|
PyInstaller should be a checkout of revision 1470 of trunk, and in a
|
|
|
|
directory called, "pyinstaller" on the same level as OpenLP's Bazaar shared
|
|
|
|
repository directory. The revision is very important as there is currently
|
|
|
|
a major regression in HEAD.
|
|
|
|
|
|
|
|
To install PyInstaller, first checkout trunk from Subversion. The easiest
|
|
|
|
way is to install TortoiseSVN and then checkout the following URL to a
|
|
|
|
directory called "pyinstaller"::
|
|
|
|
|
|
|
|
http://svn.pyinstaller.org/trunk
|
|
|
|
|
|
|
|
Bazaar
|
|
|
|
You need the command line "bzr" client installed.
|
|
|
|
|
|
|
|
OpenLP
|
|
|
|
A checkout of the latest code, in a branch directory, which is in a Bazaar
|
|
|
|
shared repository directory. This means your code should be in a directory
|
|
|
|
structure like this: "openlp\branch-name".
|
|
|
|
|
|
|
|
Visual C++ 2008 Express Edition
|
|
|
|
This is to build pptviewlib.dll, the library for controlling the
|
|
|
|
PowerPointViewer.
|
|
|
|
|
|
|
|
windows-builder.py
|
|
|
|
This script, of course. It should be in the "windows-installer" directory
|
|
|
|
at the same level as OpenLP trunk.
|
|
|
|
|
|
|
|
psvince.dll
|
|
|
|
This dll is used during the actual install of OpenLP to check if OpenLP is
|
|
|
|
running on the users machine prior to the setup. If OpenLP is running,
|
|
|
|
the install will fail. The dll can be obtained from here:
|
|
|
|
|
|
|
|
http://www.vincenzo.net/isxkb/index.php?title=PSVince)
|
|
|
|
|
|
|
|
The dll is presently included with this script.
|
|
|
|
|
|
|
|
Mako
|
|
|
|
Mako Templates for Python. This package is required for building the
|
|
|
|
remote plugin. It can be installed by going to your
|
|
|
|
python_directory\scripts\.. and running "easy_install Mako". If you do not
|
|
|
|
have easy_install, the Mako package can be obtained here:
|
|
|
|
|
|
|
|
http://www.makotemplates.org/download.html
|
|
|
|
|
|
|
|
SQLAlchemy Migrate
|
|
|
|
Required for the databases used in OpenLP. The package can be
|
|
|
|
obtained here:
|
|
|
|
|
|
|
|
http://code.google.com/p/sqlalchemy-migrate/
|
|
|
|
|
|
|
|
Portable App Builds
|
|
|
|
The following are required if you are planning to make a portable build of
|
|
|
|
OpenLP. The portable build conforms to the standards published by
|
|
|
|
PortableApps.com:
|
|
|
|
|
|
|
|
http://portableapps.com/development/portableapps.com_format
|
|
|
|
|
|
|
|
PortableApps.com Installer:
|
|
|
|
|
|
|
|
http://portableapps.com/apps/development/portableapps.com_installer
|
|
|
|
|
|
|
|
PortableApps.com Launcher:
|
|
|
|
|
|
|
|
http://portableapps.com/apps/development/portableapps.com_launcher
|
|
|
|
|
|
|
|
NSIS Portable (Unicode version):
|
|
|
|
|
|
|
|
http://portableapps.com/apps/development/nsis_portable
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
2012-06-25 14:10:22 +00:00
|
|
|
from shutil import copy, rmtree, move
|
|
|
|
from distutils import dir_util
|
2012-06-09 19:02:47 +00:00
|
|
|
from subprocess import Popen, PIPE
|
|
|
|
from ConfigParser import SafeConfigParser as ConfigParser
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
|
|
|
|
|
|
|
|
class WindowsBuilder(object):
|
|
|
|
"""
|
|
|
|
The :class:`WindowsBuilder` class encapsulates everything that is needed
|
|
|
|
to build a Windows installer.
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
|
|
self.setup_args()
|
|
|
|
self.setup_system_paths()
|
|
|
|
self.read_config()
|
|
|
|
self.setup_executables()
|
|
|
|
self.setup_paths()
|
|
|
|
self.version = u''
|
|
|
|
|
|
|
|
def _print(self, text, *args):
|
|
|
|
"""
|
|
|
|
Print stuff out. Later we might want to use a log file.
|
|
|
|
"""
|
|
|
|
if len(args) > 0:
|
|
|
|
text = text % tuple(args)
|
|
|
|
print text
|
|
|
|
|
|
|
|
def _print_verbose(self, text, *args):
|
|
|
|
"""
|
|
|
|
Print output, obeying "verbose" mode.
|
|
|
|
"""
|
|
|
|
if self.args.verbose:
|
|
|
|
self._print(text, *args)
|
|
|
|
|
|
|
|
def setup_args(self):
|
|
|
|
"""
|
|
|
|
Set up an argument parser and parse the command line arguments.
|
|
|
|
"""
|
|
|
|
parser = ArgumentParser()
|
|
|
|
parser.add_argument('-b', '--branch', metavar='BRANCH', dest='branch',
|
|
|
|
help='Specify the path to the branch you wish to build.',
|
2012-06-25 14:10:22 +00:00
|
|
|
default=None)
|
2012-06-09 19:02:47 +00:00
|
|
|
parser.add_argument('-d', '--documentation', metavar='DOCS',
|
2012-06-25 14:10:22 +00:00
|
|
|
dest='docs', default=None,
|
2012-06-09 19:02:47 +00:00
|
|
|
help='Specify the path to the documentation branch.')
|
|
|
|
parser.add_argument('-c', '--config', metavar='CONFIG', dest='config',
|
|
|
|
help='Specify the path to the configuration file.',
|
|
|
|
default=os.path.abspath(os.path.join('.', 'config.ini')))
|
|
|
|
parser.add_argument('-u', '--skip-update', dest='skip_update',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='Do NOT update the branch before building.')
|
|
|
|
parser.add_argument('-p', '--portable', metavar='PORTABLE',
|
|
|
|
dest='portable', default=None,
|
|
|
|
help='Specify the path to build the portable installation.')
|
|
|
|
parser.add_argument('-t', '--skip-translations',
|
|
|
|
dest='skip_translations', action='store_true', default=False,
|
|
|
|
help='Do NOT update the language translation files.')
|
|
|
|
parser.add_argument('-v', '--verbose', dest='verbose',
|
|
|
|
action='store_true', default=False,
|
|
|
|
help='Print out additional information.')
|
|
|
|
self.args = parser.parse_args()
|
|
|
|
|
|
|
|
def read_config(self):
|
|
|
|
"""
|
|
|
|
Read the configuration from the configuration file.
|
|
|
|
"""
|
|
|
|
self.config = ConfigParser(defaults={
|
|
|
|
u'pyroot': self.python_root,
|
|
|
|
u'progfiles': self.program_files,
|
|
|
|
u'sitepackages': self.site_packages,
|
|
|
|
u'here': self.script_path
|
|
|
|
})
|
|
|
|
self.config.read(os.path.abspath(self.args.config))
|
|
|
|
|
|
|
|
def setup_system_paths(self):
|
|
|
|
"""
|
|
|
|
Set up some system paths.
|
|
|
|
"""
|
|
|
|
self.script_path = os.path.split(os.path.abspath(__file__))[0]
|
|
|
|
self.python = sys.executable
|
|
|
|
self.python_root = os.path.split(self.python)[0]
|
|
|
|
self.site_packages = os.path.join(self.python_root,
|
|
|
|
u'Lib', u'site-packages')
|
|
|
|
self.program_files = os.getenv(u'PROGRAMFILES')
|
|
|
|
|
|
|
|
def setup_executables(self):
|
|
|
|
"""
|
|
|
|
Set up the paths to the executables we use.
|
|
|
|
"""
|
|
|
|
self.innosetup = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'innosetup'))
|
|
|
|
self.sphinx = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'sphinx'))
|
|
|
|
self.pyinstaller = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'pyinstaller'))
|
|
|
|
self.vcbuild = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'vcbuild'))
|
|
|
|
self.hhc = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'htmlhelp'))
|
|
|
|
self.psvince = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'psvince'))
|
|
|
|
self.portableinstaller = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'portableinstaller'))
|
|
|
|
self.portablelauncher = os.path.abspath(
|
|
|
|
self.config.get(u'executables', u'portablelauncher'))
|
|
|
|
if os.path.exists(os.path.join(self.site_packages, u'PyQt4', u'bin')):
|
|
|
|
# Older versions of the PyQt4 Windows installer put their binaries
|
|
|
|
# in the "bin" directory
|
|
|
|
self.lrelease = os.path.join(self.site_packages, u'PyQt4',
|
|
|
|
u'bin', u'lrelease.exe')
|
|
|
|
else:
|
|
|
|
# Newer versions of the PyQt4 Windows installer put their binaries
|
|
|
|
# in the base directory of the installation
|
|
|
|
self.lrelease = os.path.join(self.site_packages, u'PyQt4',
|
|
|
|
u'lrelease.exe')
|
|
|
|
|
|
|
|
def setup_paths(self):
|
|
|
|
"""
|
|
|
|
Set up a variety of paths that we use throughout the build process.
|
|
|
|
"""
|
|
|
|
if self.args.branch:
|
|
|
|
branch_path = self.args.branch
|
|
|
|
else:
|
|
|
|
branch_path = self.config.get(u'paths', u'branch')
|
|
|
|
self.branch_path = os.path.abspath(branch_path)
|
|
|
|
if self.args.docs:
|
|
|
|
docs_path = self.args.docs
|
|
|
|
else:
|
|
|
|
docs_path = self.config.get(u'paths', u'documentation')
|
|
|
|
self.docs_path = os.path.abspath(docs_path)
|
|
|
|
if self.args.portable:
|
|
|
|
portable_path = self.args.portable
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
portable_path = self.config.get(u'paths', u'portable')
|
|
|
|
except:
|
|
|
|
portable_path = u''
|
|
|
|
if portable_path:
|
|
|
|
self.portable_path = os.path.abspath(portable_path)
|
|
|
|
self.args.portable = self.portable_path
|
|
|
|
else:
|
|
|
|
self.portable_path = u''
|
|
|
|
self.openlp_script = os.path.abspath(
|
|
|
|
os.path.join(branch_path, u'openlp.pyw'))
|
|
|
|
self.hooks_path = os.path.abspath(self.config.get(u'paths', u'hooks'))
|
|
|
|
self.win32_icon = os.path.abspath(
|
|
|
|
self.config.get(u'paths', u'win32icon'))
|
|
|
|
self.i18n_utils = os.path.join(self.branch_path, u'scripts',
|
|
|
|
u'translation_utils.py')
|
|
|
|
self.source_path = os.path.join(self.branch_path, u'openlp')
|
|
|
|
self.manual_path = os.path.join(self.docs_path, u'manual')
|
|
|
|
self.manual_build_path = os.path.join(self.manual_path, u'build')
|
|
|
|
self.helpfile_path = os.path.join(self.manual_build_path, u'htmlhelp')
|
|
|
|
self.i18n_path = os.path.join(self.branch_path, u'resources', u'i18n')
|
|
|
|
self.winres_path = os.path.join(self.branch_path, u'resources',
|
|
|
|
u'windows')
|
|
|
|
self.build_path = os.path.join(self.branch_path, u'build')
|
|
|
|
self.dist_path = os.path.join(self.branch_path, u'dist', u'OpenLP')
|
|
|
|
self.pptviewlib_path = os.path.join(self.source_path, u'plugins',
|
|
|
|
u'presentations', u'lib', u'pptviewlib')
|
|
|
|
|
|
|
|
def update_code(self):
|
|
|
|
"""
|
|
|
|
Update the code in the branch.
|
|
|
|
"""
|
|
|
|
os.chdir(self.branch_path)
|
|
|
|
self._print(u'Reverting any changes to the code...')
|
|
|
|
bzr = Popen((u'bzr', u'revert'), stdout=PIPE)
|
|
|
|
output = bzr.communicate()[0]
|
|
|
|
code = bzr.wait()
|
|
|
|
if code != 0:
|
|
|
|
self._print(output)
|
|
|
|
raise Exception(u'Error reverting the code')
|
|
|
|
self._print(u'Updating the code...')
|
|
|
|
bzr = Popen((u'bzr', u'update'), stdout=PIPE)
|
|
|
|
output = bzr.communicate()[0]
|
|
|
|
code = bzr.wait()
|
|
|
|
if code != 0:
|
|
|
|
self._print(output)
|
|
|
|
raise Exception(u'Error updating the code')
|
|
|
|
|
|
|
|
def run_pyinstaller(self):
|
|
|
|
"""
|
|
|
|
Run PyInstaller on the branch to build an executable.
|
|
|
|
"""
|
|
|
|
self._print(u'Running PyInstaller...')
|
|
|
|
os.chdir(self.branch_path)
|
|
|
|
pyinstaller = Popen((self.python, self.pyinstaller,
|
|
|
|
u'--noconfirm',
|
|
|
|
u'--windowed',
|
|
|
|
u'--noupx',
|
|
|
|
u'--additional-hooks-dir', self.hooks_path,
|
2013-01-01 01:04:23 +00:00
|
|
|
u'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
|
2012-06-09 19:02:47 +00:00
|
|
|
u'--log-level=ERROR',
|
|
|
|
u'-o', self.branch_path,
|
|
|
|
u'-i', self.win32_icon,
|
|
|
|
u'-p', self.branch_path,
|
|
|
|
u'-n', u'OpenLP',
|
|
|
|
self.openlp_script),
|
|
|
|
stdout=PIPE)
|
|
|
|
output = pyinstaller.communicate()[0]
|
|
|
|
code = pyinstaller.wait()
|
|
|
|
if code != 0:
|
|
|
|
self._print(output)
|
|
|
|
raise Exception(u'Error running PyInstaller')
|
|
|
|
|
|
|
|
def write_version_file(self):
|
|
|
|
"""
|
|
|
|
Write the version number to a file for reading once installed.
|
|
|
|
"""
|
|
|
|
self._print(u'Writing version file...')
|
|
|
|
os.chdir(self.branch_path)
|
|
|
|
bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
|
|
|
|
output = bzr.communicate()[0]
|
|
|
|
code = bzr.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running bzr tags')
|
|
|
|
lines = output.splitlines()
|
|
|
|
if len(lines) == 0:
|
|
|
|
tag = u'0.0.0'
|
|
|
|
revision = u'0'
|
|
|
|
else:
|
|
|
|
tag, revision = lines[-1].split()
|
|
|
|
bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE)
|
|
|
|
output, error = bzr.communicate()
|
|
|
|
code = bzr.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running bzr log')
|
|
|
|
output_ascii = unicode(output, errors=u'ignore')
|
|
|
|
latest = output_ascii.split(u':')[0]
|
|
|
|
version_string = latest == revision and tag or \
|
|
|
|
u'%s-bzr%s' % (tag, latest)
|
|
|
|
# Save decimal version in case we need to do a portable build.
|
|
|
|
self.version = latest == revision and tag or\
|
|
|
|
u'%s.%s' % (tag, latest)
|
|
|
|
version_file = open(os.path.join(self.dist_path, u'.version'), u'w')
|
|
|
|
version_file.write(version_string)
|
|
|
|
version_file.close()
|
|
|
|
|
|
|
|
def copy_plugins(self):
|
|
|
|
"""
|
|
|
|
Copy all the plugins to the correct directory so that OpenLP sees that
|
|
|
|
it has plugins.
|
|
|
|
"""
|
|
|
|
self._print(u'Copying plugins...')
|
|
|
|
source = os.path.join(self.source_path, u'plugins')
|
|
|
|
dest = os.path.join(self.dist_path, u'plugins')
|
|
|
|
for root, dirs, files in os.walk(source):
|
|
|
|
for filename in files:
|
|
|
|
if not filename.endswith(u'.pyc'):
|
|
|
|
dest_path = os.path.join(dest, root[len(source)+1:])
|
|
|
|
if not os.path.exists(dest_path):
|
|
|
|
os.makedirs(dest_path)
|
|
|
|
self._print_verbose(u'... %s', filename)
|
|
|
|
copy(os.path.join(root, filename),
|
|
|
|
os.path.join(dest_path, filename))
|
|
|
|
|
|
|
|
def copy_media_player(self):
|
|
|
|
"""
|
|
|
|
Copy the media players to the correct directory for OpenLP.
|
|
|
|
"""
|
|
|
|
self._print(u'Copying media player...')
|
|
|
|
source = os.path.join(self.source_path, u'core', u'ui', u'media')
|
|
|
|
dest = os.path.join(self.dist_path, u'core', u'ui', u'media')
|
|
|
|
for root, dirs, files in os.walk(source):
|
|
|
|
for filename in files:
|
|
|
|
if not filename.endswith(u'.pyc'):
|
|
|
|
dest_path = os.path.join(dest, root[len(source)+1:])
|
|
|
|
if not os.path.exists(dest_path):
|
|
|
|
os.makedirs(dest_path)
|
|
|
|
self._print_verbose(u'... %s', filename)
|
|
|
|
copy(os.path.join(root, filename),
|
|
|
|
os.path.join(dest_path, filename))
|
|
|
|
|
|
|
|
def copy_windows_files(self):
|
|
|
|
"""
|
|
|
|
Copy all the Windows-specific files.
|
|
|
|
"""
|
|
|
|
self._print(u'Copying extra files for Windows...')
|
|
|
|
self._print_verbose(u'... OpenLP.ico')
|
|
|
|
copy(os.path.join(self.script_path, u'OpenLP.ico'),
|
|
|
|
os.path.join(self.dist_path, u'OpenLP.ico'))
|
|
|
|
self._print_verbose(u'... LICENSE.txt')
|
|
|
|
copy(os.path.join(self.script_path, u'LICENSE.txt'),
|
|
|
|
os.path.join(self.dist_path, u'LICENSE.txt'))
|
|
|
|
self._print_verbose(u'... psvince.dll')
|
|
|
|
copy(self.psvince, os.path.join(self.dist_path, u'psvince.dll'))
|
|
|
|
if os.path.isfile(os.path.join(self.helpfile_path, u'OpenLP.chm')):
|
|
|
|
self._print_verbose(u'... OpenLP.chm')
|
|
|
|
copy(os.path.join(self.helpfile_path, u'OpenLP.chm'),
|
|
|
|
os.path.join(self.dist_path, u'OpenLP.chm'))
|
|
|
|
else:
|
|
|
|
self._print(u'... WARNING: Windows help file not found')
|
|
|
|
|
|
|
|
def update_translations(self):
|
|
|
|
"""
|
|
|
|
Update the translations.
|
|
|
|
"""
|
|
|
|
self._print(u'Updating translations...')
|
|
|
|
if not self.config.has_section('transifex'):
|
|
|
|
raise Exception(u'No section named "transifex" found.')
|
|
|
|
if not self.config.has_option('transifex', 'username'):
|
|
|
|
raise Exception(u'No option named "username" found.')
|
|
|
|
if not self.config.has_option('transifex', 'password'):
|
|
|
|
raise Exception(u'No option named "password" found.')
|
|
|
|
username = self.config.get(u'transifex', u'username')
|
|
|
|
password = self.config.get(u'transifex', u'password')
|
|
|
|
os.chdir(os.path.split(self.i18n_utils)[0])
|
|
|
|
translation_utils = Popen([self.python, self.i18n_utils, u'-qdpu',
|
|
|
|
u'-U', username, u'-P', password])
|
|
|
|
code = translation_utils.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running translation_utils.py')
|
|
|
|
|
|
|
|
def compile_translations(self):
|
|
|
|
"""
|
|
|
|
Compile the translations for Qt.
|
|
|
|
"""
|
|
|
|
self._print(u'Compiling translations...')
|
|
|
|
files = os.listdir(self.i18n_path)
|
|
|
|
if not os.path.exists(os.path.join(self.dist_path, u'i18n')):
|
|
|
|
os.makedirs(os.path.join(self.dist_path, u'i18n'))
|
|
|
|
for file in files:
|
|
|
|
if file.endswith(u'.ts'):
|
|
|
|
self._print_verbose(u'... %s', file)
|
|
|
|
source_path = os.path.join(self.i18n_path, file)
|
|
|
|
dest_path = os.path.join(self.dist_path, u'i18n',
|
|
|
|
file.replace(u'.ts', u'.qm'))
|
|
|
|
lconvert = Popen((self.lrelease, u'-compress', u'-silent',
|
|
|
|
source_path, u'-qm', dest_path))
|
|
|
|
code = lconvert.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running lconvert on %s' % \
|
|
|
|
source_path)
|
|
|
|
self._print(u'Copying qm files...')
|
|
|
|
source = os.path.join(self.site_packages, u'PyQt4', u'translations')
|
|
|
|
files = os.listdir(source)
|
|
|
|
for filename in files:
|
|
|
|
if filename.startswith(u'qt_') and filename.endswith(u'.qm') and \
|
|
|
|
len(filename) == 8:
|
|
|
|
self._print_verbose(u'... %s', filename)
|
|
|
|
copy(os.path.join(source, filename),
|
|
|
|
os.path.join(self.dist_path, u'i18n', filename))
|
|
|
|
|
|
|
|
def run_sphinx(self):
|
|
|
|
"""
|
|
|
|
Run Sphinx to build an HTML Help project.
|
|
|
|
"""
|
|
|
|
self._print(u'Deleting previous help manual build... %s',
|
|
|
|
self.manual_build_path)
|
|
|
|
if os.path.exists(self.manual_build_path):
|
|
|
|
rmtree(self.manual_build_path)
|
|
|
|
self._print(u'Running Sphinx...')
|
|
|
|
os.chdir(self.manual_path)
|
|
|
|
sphinx = Popen((self.sphinx, u'-b', u'htmlhelp', u'-d',
|
|
|
|
u'build/doctrees', u'source', u'build/htmlhelp'), stdout=PIPE)
|
|
|
|
output, error = sphinx.communicate()
|
|
|
|
code = sphinx.wait()
|
|
|
|
if code != 0:
|
|
|
|
self._print(output)
|
|
|
|
raise Exception(u'Error running Sphinx')
|
|
|
|
|
|
|
|
def run_htmlhelp(self):
|
|
|
|
"""
|
|
|
|
Run HTML Help Workshop to convert the Sphinx output into a manual.
|
|
|
|
"""
|
|
|
|
self._print(u'Running HTML Help Workshop...')
|
|
|
|
os.chdir(os.path.join(self.manual_build_path, u'htmlhelp'))
|
|
|
|
hhc = Popen((self.hhc, u'OpenLP.chm'), stdout=PIPE)
|
|
|
|
output, error = hhc.communicate()
|
|
|
|
code = hhc.wait()
|
|
|
|
if code != 1:
|
|
|
|
self._print(u'Exit code:', code)
|
|
|
|
self._print(output)
|
|
|
|
raise Exception(u'Error running HTML Help Workshop')
|
|
|
|
|
|
|
|
def create_innosetup_file(self):
|
|
|
|
"""
|
|
|
|
Create an InnoSetup file pointing to the branch being built.
|
|
|
|
"""
|
|
|
|
self._print(u'Creating Inno Setup file...')
|
|
|
|
input = open(os.path.join(self.script_path,
|
|
|
|
u'OpenLP-2.0.iss.default'), u'r').read()
|
|
|
|
output = input.replace(u'%(branch)s', self.branch_path)
|
|
|
|
outfile = open(os.path.join(self.script_path,
|
|
|
|
u'OpenLP-2.0.iss'), u'w')
|
|
|
|
outfile.write(output)
|
|
|
|
outfile.close()
|
|
|
|
|
|
|
|
def check_portableapp_directory(self):
|
|
|
|
"""
|
|
|
|
Checks the PortableApp directory structure amd creates
|
|
|
|
missing subdirs
|
|
|
|
"""
|
|
|
|
self._print(u' Checking PortableApps directory structure...')
|
|
|
|
launcher_path = os.path.join(self.portable_path, u'App',
|
|
|
|
u'Appinfo', u'Launcher')
|
|
|
|
if not os.path.exists(launcher_path):
|
|
|
|
os.makedirs(launcher_path)
|
|
|
|
settings_path = os.path.join(self.portable_path, u'Data',
|
|
|
|
u'Settings')
|
|
|
|
if not os.path.exists(settings_path):
|
|
|
|
os.makedirs(settings_path)
|
|
|
|
|
|
|
|
def create_portableapps_appinfo_file(self):
|
|
|
|
"""
|
|
|
|
Create a Portabbleapps appinfo.ini file.
|
|
|
|
"""
|
|
|
|
self._print(u' Creating PortableApps appinfo file ...')
|
2012-06-25 14:10:22 +00:00
|
|
|
portable_version = self.version + '.0' * (3-self.version.count('.'))
|
2012-06-09 19:02:47 +00:00
|
|
|
input = open(os.path.join(self.script_path,
|
|
|
|
u'appinfo.ini.default'), u'r').read()
|
2012-06-25 14:10:22 +00:00
|
|
|
output = input.replace(u'%(display_version)s', self.version)
|
|
|
|
output = output.replace(u'%(package_version)s', portable_version)
|
2012-06-09 19:02:47 +00:00
|
|
|
outfile = open(os.path.join(self.portable_path, u'App',
|
|
|
|
u'Appinfo', u'appinfo.ini'), u'w')
|
|
|
|
outfile.write(output)
|
|
|
|
outfile.close()
|
|
|
|
|
|
|
|
def run_innosetup(self):
|
|
|
|
"""
|
|
|
|
Run InnoSetup to create an installer.
|
|
|
|
"""
|
|
|
|
self._print(u'Running Inno Setup...')
|
|
|
|
os.chdir(self.script_path)
|
|
|
|
innosetup = Popen((self.innosetup,
|
|
|
|
os.path.join(self.script_path, u'OpenLP-2.0.iss'), u'/q'))
|
|
|
|
code = innosetup.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running Inno Setup')
|
|
|
|
|
|
|
|
def run_portableapp_builder(self):
|
|
|
|
"""
|
|
|
|
Creates a portable installer.
|
|
|
|
1 Copies the distribution to the portable apps directory
|
|
|
|
2 Builds the PortableApps Launcher
|
|
|
|
3 Builds the PortableApps Install
|
|
|
|
"""
|
|
|
|
self._print(u'Running PortableApps Builder...')
|
2012-06-25 14:10:22 +00:00
|
|
|
self._print(u' Clearing old files')
|
2012-06-25 16:38:21 +00:00
|
|
|
# Remove previous contents of portableapp build directory.
|
2012-06-25 14:10:22 +00:00
|
|
|
if os.path.exists(self.portable_path):
|
|
|
|
rmtree(self.portable_path)
|
2012-06-25 16:38:21 +00:00
|
|
|
self._print(u' Creating PortableApps build directory')
|
2012-06-25 14:10:22 +00:00
|
|
|
# Copy the contents of the OpenLPPortable directory to the portable
|
|
|
|
# build directory.
|
|
|
|
dir_util.copy_tree(os.path.join(self.script_path, u'OpenLPPortable'),
|
|
|
|
self.portable_path)
|
2012-06-09 19:02:47 +00:00
|
|
|
self.check_portableapp_directory()
|
|
|
|
self.create_portableapps_appinfo_file()
|
|
|
|
# Copy distribution files to portableapp build directory.
|
2012-06-25 16:38:21 +00:00
|
|
|
self._print(u' Copying distribution files')
|
2012-06-25 14:10:22 +00:00
|
|
|
portable_app_path = os.path.join(self.portable_path, u'App', u'OpenLP')
|
|
|
|
dir_util.copy_tree(self.dist_path, portable_app_path)
|
2012-06-09 19:02:47 +00:00
|
|
|
# Copy help files to portableapp build directory.
|
|
|
|
self._print(u' Copying help files')
|
2012-06-25 14:10:22 +00:00
|
|
|
dir_util.copy_tree(self.helpfile_path,
|
2012-06-09 19:02:47 +00:00
|
|
|
os.path.join(portable_app_path, u'help'))
|
|
|
|
# Build the launcher.
|
|
|
|
self._print(u' Building PortableApps Launcher')
|
|
|
|
portableapps = Popen((self.portablelauncher, self.portable_path),
|
|
|
|
stdout=PIPE)
|
|
|
|
code = portableapps.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error creating PortableAppa Launcher')
|
|
|
|
# Build the portable installer.
|
|
|
|
self._print(u' Building PortableApps Installer')
|
|
|
|
portableapps = Popen((self.portableinstaller, self.portable_path),
|
|
|
|
stdout=PIPE)
|
|
|
|
code = portableapps.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error running PortableApps Installer')
|
|
|
|
portable_app = os.path.abspath(os.path.join(self.portable_path, u'..',
|
|
|
|
u'OpenLPPortable_%s.paf.exe' % self.version))
|
|
|
|
if os.path.exists(portable_app):
|
2012-06-25 14:10:22 +00:00
|
|
|
move(portable_app, os.path.abspath(
|
2012-06-09 19:02:47 +00:00
|
|
|
os.path.join(self.dist_path, u'..')))
|
|
|
|
self._print(u' PortableApp build complete')
|
|
|
|
else:
|
|
|
|
raise Exception(u'PortableApp failed to build')
|
|
|
|
|
|
|
|
def build_pptviewlib(self):
|
|
|
|
"""
|
|
|
|
Build the PowerPoint Viewer DLL using Visual Studio.
|
|
|
|
"""
|
|
|
|
self._print(u'Building PPTVIEWLIB.DLL...')
|
|
|
|
vcbuild = Popen((self.vcbuild, u'/rebuild',
|
|
|
|
os.path.join(self.pptviewlib_path, u'pptviewlib.vcproj'),
|
|
|
|
u'Release|Win32'))
|
|
|
|
code = vcbuild.wait()
|
|
|
|
if code != 0:
|
|
|
|
raise Exception(u'Error building pptviewlib.dll')
|
|
|
|
copy(os.path.join(self.pptviewlib_path, u'Release',
|
|
|
|
u'pptviewlib.dll'), self.pptviewlib_path)
|
|
|
|
|
|
|
|
def main(self):
|
|
|
|
"""
|
|
|
|
The main function to run the Windows builder.
|
|
|
|
"""
|
|
|
|
self._print_verbose(u'OpenLP main script: ......%s',
|
|
|
|
self.openlp_script)
|
|
|
|
self._print_verbose(u'Script path: .............%s',
|
|
|
|
os.path.split(os.path.abspath(__file__))[0])
|
|
|
|
self._print_verbose(u'Branch path: .............%s', self.branch_path)
|
|
|
|
self._print_verbose(u'Source path: .............%s', self.source_path)
|
|
|
|
self._print_verbose(u'Dist path: ...............%s', self.dist_path)
|
|
|
|
self._print_verbose(u'Portable path: ...........%s',
|
|
|
|
self.portable_path)
|
|
|
|
self._print_verbose(u'PyInstaller: .............%s', self.pyinstaller)
|
|
|
|
self._print_verbose(u'Documentation branch path:%s', self.docs_path)
|
|
|
|
self._print_verbose(u'Help file build path: ....%s',
|
|
|
|
self.helpfile_path)
|
|
|
|
self._print_verbose(u'Inno Setup path: .........%s', self.innosetup)
|
|
|
|
self._print_verbose(u'PortableApp Launcher......%s',
|
|
|
|
self.portablelauncher)
|
|
|
|
self._print_verbose(u'PortableApp Installer.....%s',
|
|
|
|
self.portableinstaller)
|
|
|
|
self._print_verbose(u'Windows resources: .......%s', self.winres_path)
|
|
|
|
self._print_verbose(u'VCBuild path: ............%s', self.vcbuild)
|
|
|
|
self._print_verbose(u'PPTVIEWLIB path: .........%s',
|
|
|
|
self.pptviewlib_path)
|
|
|
|
self._print_verbose(u'')
|
|
|
|
if not self.args.skip_update:
|
|
|
|
self.update_code()
|
|
|
|
self.build_pptviewlib()
|
|
|
|
self.run_pyinstaller()
|
|
|
|
self.write_version_file()
|
|
|
|
self.copy_plugins()
|
|
|
|
self.copy_media_player()
|
|
|
|
if os.path.exists(self.manual_path):
|
|
|
|
self.run_sphinx()
|
|
|
|
self.run_htmlhelp()
|
|
|
|
else:
|
|
|
|
self._print(u'')
|
|
|
|
self._print(u'WARNING: Documentation trunk not found. Windows')
|
|
|
|
self._print(u' Help file will not be included in build')
|
|
|
|
self._print(u'')
|
|
|
|
self.copy_windows_files()
|
|
|
|
if not self.args.skip_translations:
|
|
|
|
self.update_translations()
|
|
|
|
self.compile_translations()
|
|
|
|
self.create_innosetup_file()
|
|
|
|
self.run_innosetup()
|
|
|
|
if self.args.portable:
|
|
|
|
self.run_portableapp_builder()
|
|
|
|
self._print(u'Done.')
|
|
|
|
|
|
|
|
if __name__ == u'__main__':
|
|
|
|
WindowsBuilder().main()
|