PyInstaller spec file updates

- file name based on architecture, version and date
- workaround for __init__ in src
- change to unix line endings
This commit is contained in:
Peter Šurda 2017-02-27 13:02:37 +01:00
parent 484d4abb3c
commit 8579d8b3b5
Signed by untrusted user: PeterSurda
GPG Key ID: 0C5F50C0B5F37D87
1 changed files with 79 additions and 86 deletions

View File

@ -1,86 +1,79 @@
import ctypes import ctypes
import os import os
import time
srcPath = "C:\\src\\PyBitmessage\\src\\"
qtPath = "C:\\Qt-4.8.7\\" srcPath = "C:\\src\\PyBitmessage\\src\\"
openSSLPath = "C:\\OpenSSL-1.0.2j\\" qtPath = "C:\\Qt-4.8.7\\"
outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain" openSSLPath = "C:\\OpenSSL-1.0.2j\\bin\\"
outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain"
hiddenimports= [] today = time.strftime("%Y%m%d")
snapshot = False
# manually add messagetypes directory and its listing
with open(os.path.join(srcPath, 'messagetypes.txt'), 'wt') as f: os.rename(os.path.join(srcPath, '__init__.py'), os.path.join(srcPath, '__init__.py.backup'))
for mt in os.listdir(os.path.join(srcPath, 'messagetypes')):
if mt == "__init__.py": # -*- mode: python -*-
continue a = Analysis([srcPath + 'bitmessagemain.py'],
splitted = os.path.splitext(mt) pathex=[outPath],
if splitted[1] != ".py": hiddenimports=[],
continue hookspath=None,
f.write(mt + "\n") runtime_hooks=None)
hiddenimports.append('messagetypes.' + splitted[0])
os.rename(os.path.join(srcPath, '__init__.py.backup'), os.path.join(srcPath, '__init__.py'))
# -*- mode: python -*-
a = Analysis([srcPath + 'bitmessagemain.py'], def addTranslations():
pathex=[outPath], import os
hiddenimports=hiddenimports, extraDatas = []
hookspath=None, for file in os.listdir(srcPath + 'translations'):
runtime_hooks=None) if file[-3:] != ".qm":
continue
a.datas.append(('messagetypes.txt', os.path.join(srcPath, 'messagetypes.txt'), 'DATA')) extraDatas.append((os.path.join('translations', file), os.path.join(srcPath, 'translations', file), 'DATA'))
for file in os.listdir(qtPath + 'translations'):
# fix duplicates if file[0:3] != "qt_" or file[5:8] != ".qm":
for d in a.datas: continue
if 'pyconfig' in d[0]: extraDatas.append((os.path.join('translations', file), os.path.join(qtPath, 'translations', file), 'DATA'))
a.datas.remove(d) return extraDatas
break
def addUIs():
def addTranslations(): import os
import os extraDatas = []
extraDatas = [] for file in os.listdir(srcPath + 'bitmessageqt'):
for file in os.listdir(srcPath + 'translations'): if file[-3:] != ".ui":
if file[-3:] != ".qm": continue
continue extraDatas.append((os.path.join('ui', file), os.path.join(srcPath, 'bitmessageqt', file), 'DATA'))
extraDatas.append((os.path.join('translations', file), os.path.join(srcPath, 'translations', file), 'DATA')) return extraDatas
for file in os.listdir(qtPath + 'translations'):
if file[0:3] != "qt_" or file[5:8] != ".qm": # append the translations directory
continue a.datas += addTranslations()
extraDatas.append((os.path.join('translations', file), os.path.join(qtPath, 'translations', file), 'DATA')) a.datas += addUIs()
return extraDatas
if ctypes.sizeof(ctypes.c_voidp) == 4:
def addUIs(): arch=32
import os else:
extraDatas = [] arch=64
for file in os.listdir(srcPath + 'bitmessageqt'):
if file[-3:] != ".ui": a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'),
continue (os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'),
extraDatas.append((os.path.join('ui', file), os.path.join(srcPath, 'bitmessageqt', file), 'DATA')) (os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
return extraDatas (os.path.join('sslkeys', 'cert.pem'), os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'),
(os.path.join('sslkeys', 'key.pem'), os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY')
# append the translations directory ]
a.datas += addTranslations()
a.datas += addUIs() with open(os.path.join(srcPath, 'version.py'), 'rt') as f:
softwareVersion = f.readline().split('\'')[1]
if ctypes.sizeof(ctypes.c_voidp) == 4:
arch=32 fname = 'Bitmessage_%s_%s.exe' % ("x86" if arch == 32 else "x64", softwareVersion)
else: if snapshot:
arch=64 fname = 'Bitmessagedev_%s_%s.exe' % ("x86" if arch == 32 else "x64", today)
a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'), pyz = PYZ(a.pure)
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'), exe = EXE(pyz,
(os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'), a.scripts,
(os.path.join('sslkeys', 'cert.pem'), os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'), a.binaries,
(os.path.join('sslkeys', 'key.pem'), os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY') a.zipfiles,
] a.datas,
a.binaries,
pyz = PYZ(a.pure) name=fname,
exe = EXE(pyz, debug=False,
a.scripts, strip=None,
a.binaries, upx=False,
a.zipfiles, console=False, icon= os.path.join(srcPath, 'images', 'can-icon.ico'))
a.datas,
a.binaries,
name='Bitmessage.exe',
debug=False,
strip=None,
upx=False,
console=False, icon= os.path.join(srcPath, 'images', 'can-icon.ico'))