1
0
mirror of https://gitlab.com/openlp/packaging.git synced 2024-12-22 21:12:50 +00:00

Show PyInstaller DEBUG output when run with verbose option.

Use debug bootloader when building devel version.
Add ssl hook and runtime hook to include certificates for Mac OS X(OS X).
Fix release app version(OS X).
Fix converting bytes to megabytes(OS X).
Fix argument to cp command(OS X).
This commit is contained in:
Jonathan Springer 2015-08-23 20:53:43 -04:00
parent 38550840d8
commit 3bd987ffcf
4 changed files with 60 additions and 30 deletions

View File

@ -322,20 +322,25 @@ class MacosxBuilder(object):
""" """
self._print('Running PyInstaller...') self._print('Running PyInstaller...')
os.chdir(self.work_path) os.chdir(self.work_path)
pyinstaller = Popen((self.python, cmd = [self.python,
self.pyinstaller, self.pyinstaller,
'--noconfirm', '--clean',
'--windowed', '--noconfirm',
'--noupx', '--windowed',
'--additional-hooks-dir', self.hooks_path, '--noupx',
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'), '--additional-hooks-dir', self.hooks_path,
'--log-level=ERROR', '--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
# '--distpath', self.branch_path, '-i', self.mac_icon,
# '-i', self.mac_icon, '-p', self.work_path,
'-p', self.work_path, '-n', 'OpenLP',
'-n', 'OpenLP', self.openlp_script]
self.openlp_script), if not self.args.verbose:
stdout=PIPE) cmd.append('--log-level=ERROR')
else:
cmd.append('--log-level=DEBUG')
if self.args.devel:
cmd.append('-d')
pyinstaller = Popen(cmd, stdout=PIPE)
output = pyinstaller.communicate()[0] output = pyinstaller.communicate()[0]
code = pyinstaller.wait() code = pyinstaller.wait()
if code != 0: if code != 0:
@ -433,7 +438,10 @@ class MacosxBuilder(object):
fr = open(self.bundle_info, 'r') fr = open(self.bundle_info, 'r')
fw = open(os.path.join(self.dist_app_path, 'Contents', os.path.basename(self.bundle_info)), 'w') fw = open(os.path.join(self.dist_app_path, 'Contents', os.path.basename(self.bundle_info)), 'w')
text = fr.read() text = fr.read()
text = text % {'openlp_version': self.version_string} if self.args.devel:
text = text % {'openlp_version': self.version_string}
else:
text = text % {'openlp_version': self.version_tag}
fw.write(text) fw.write(text)
fr.close() fr.close()
fw.close() fw.close()
@ -584,7 +592,7 @@ class MacosxBuilder(object):
os.remove(dmg_file) os.remove(dmg_file)
# Create empty dmg file. # Create empty dmg file.
size = self._get_directory_size(self.dist_app_path) # in bytes. size = self._get_directory_size(self.dist_app_path) # in bytes.
size = size / (1024 * 1024) # Convert to megabytes. size = size / (1000 * 1000) # Convert to megabytes.
size += 10 # Additional space in .dmg for other files. size += 10 # Additional space in .dmg for other files.
self._print('... dmg disk size: %s' % size) self._print('... dmg disk size: %s' % size)
self._run_command([self.hdiutil, 'create', dmg_file, '-ov', '-megabytes', str(size), '-fs', 'HFS+', '-volname', self._run_command([self.hdiutil, 'create', dmg_file, '-ov', '-megabytes', str(size), '-fs', 'HFS+', '-volname',
@ -602,7 +610,7 @@ class MacosxBuilder(object):
# Copy OpenLP.app and other files to .dmg # Copy OpenLP.app and other files to .dmg
# TODO more reliable way to determine dmg_volume_path # TODO more reliable way to determine dmg_volume_path
self._print('... Copying the app to the dmg: ' + dmg_volume_path) self._print('... Copying the app to the dmg: ' + dmg_volume_path)
self._run_command(['cp', '-r', self.dist_app_path, dmg_volume_path], self._run_command(['cp', '-R', self.dist_app_path, dmg_volume_path],
'Could not copy app bundle, dmg creation failed.') 'Could not copy app bundle, dmg creation failed.')
# Set icon for dmg file. # Set icon for dmg file.

View File

@ -0,0 +1,10 @@
from PyInstaller.compat import is_darwin
from PyInstaller.utils.hooks.hookutils import exec_statement
if is_darwin: # TODO check if this is needed on linux
datas = []
files = exec_statement("""
import ssl
print(ssl.get_default_verify_paths().cafile)""").strip().split()
for file in files:
datas.append((file, 'lib')) # TODO find a way to make sure the bundled cafile is always named 'cert.pem'

View File

@ -0,0 +1,5 @@
import os
import sys
if sys.platform == 'darwin': # TODO check if this is needed on linux
os.environ['SSL_CERT_FILE'] = os.path.join(sys._MEIPASS, 'lib', 'cert.pem')

View File

@ -289,19 +289,26 @@ class WindowsBuilder(object):
""" """
self._print('Running PyInstaller...') self._print('Running PyInstaller...')
os.chdir(self.branch_path) os.chdir(self.branch_path)
pyinstaller = Popen((self.python, self.pyinstaller, cmd = [self.python,
'--noconfirm', self.pyinstaller,
'--windowed', '--clean',
'--noupx', '--noconfirm',
'--additional-hooks-dir', self.hooks_path, '--windowed',
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'), '--noupx',
'--log-level=DEBUG', '--additional-hooks-dir', self.hooks_path,
'--distpath', self.dist_path_pyinst_arg, '--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'-i', self.win32_icon, '--distpath', self.dist_path_pyinst_arg,
'-p', self.branch_path, '-i', self.win32_icon,
'-n', 'OpenLP', '-p', self.branch_path,
self.openlp_script), '-n', 'OpenLP',
stdout=PIPE) self.openlp_script]
if not self.args.verbose:
cmd.append('--log-level=ERROR')
else:
cmd.append('--log-level=DEBUG')
if self.args.devel:
cmd.append('-d')
pyinstaller = Popen(cmd, stdout=PIPE)
output = pyinstaller.communicate()[0] output = pyinstaller.communicate()[0]
code = pyinstaller.wait() code = pyinstaller.wait()
if code != 0: if code != 0: