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...')
os.chdir(self.work_path)
pyinstaller = Popen((self.python,
self.pyinstaller,
'--noconfirm',
'--windowed',
'--noupx',
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'--log-level=ERROR',
# '--distpath', self.branch_path,
# '-i', self.mac_icon,
'-p', self.work_path,
'-n', 'OpenLP',
self.openlp_script),
stdout=PIPE)
cmd = [self.python,
self.pyinstaller,
'--clean',
'--noconfirm',
'--windowed',
'--noupx',
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'-i', self.mac_icon,
'-p', self.work_path,
'-n', 'OpenLP',
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]
code = pyinstaller.wait()
if code != 0:
@ -433,7 +438,10 @@ class MacosxBuilder(object):
fr = open(self.bundle_info, 'r')
fw = open(os.path.join(self.dist_app_path, 'Contents', os.path.basename(self.bundle_info)), 'w')
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)
fr.close()
fw.close()
@ -584,7 +592,7 @@ class MacosxBuilder(object):
os.remove(dmg_file)
# Create empty dmg file.
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.
self._print('... dmg disk size: %s' % size)
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
# TODO more reliable way to determine 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.')
# 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...')
os.chdir(self.branch_path)
pyinstaller = Popen((self.python, self.pyinstaller,
'--noconfirm',
'--windowed',
'--noupx',
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'--log-level=DEBUG',
'--distpath', self.dist_path_pyinst_arg,
'-i', self.win32_icon,
'-p', self.branch_path,
'-n', 'OpenLP',
self.openlp_script),
stdout=PIPE)
cmd = [self.python,
self.pyinstaller,
'--clean',
'--noconfirm',
'--windowed',
'--noupx',
'--additional-hooks-dir', self.hooks_path,
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_openlp_pyqt4.py'),
'--distpath', self.dist_path_pyinst_arg,
'-i', self.win32_icon,
'-p', self.branch_path,
'-n', 'OpenLP',
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]
code = pyinstaller.wait()
if code != 0: