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

View File

@ -1,38 +1,24 @@
import ctypes import ctypes
import os import os
import time
srcPath = "C:\\src\\PyBitmessage\\src\\" srcPath = "C:\\src\\PyBitmessage\\src\\"
qtPath = "C:\\Qt-4.8.7\\" qtPath = "C:\\Qt-4.8.7\\"
openSSLPath = "C:\\OpenSSL-1.0.2j\\" openSSLPath = "C:\\OpenSSL-1.0.2j\\bin\\"
outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain" outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain"
today = time.strftime("%Y%m%d")
snapshot = False
hiddenimports= [] os.rename(os.path.join(srcPath, '__init__.py'), os.path.join(srcPath, '__init__.py.backup'))
# manually add messagetypes directory and its listing
with open(os.path.join(srcPath, 'messagetypes.txt'), 'wt') as f:
for mt in os.listdir(os.path.join(srcPath, 'messagetypes')):
if mt == "__init__.py":
continue
splitted = os.path.splitext(mt)
if splitted[1] != ".py":
continue
f.write(mt + "\n")
hiddenimports.append('messagetypes.' + splitted[0])
# -*- mode: python -*- # -*- mode: python -*-
a = Analysis([srcPath + 'bitmessagemain.py'], a = Analysis([srcPath + 'bitmessagemain.py'],
pathex=[outPath], pathex=[outPath],
hiddenimports=hiddenimports, hiddenimports=[],
hookspath=None, hookspath=None,
runtime_hooks=None) runtime_hooks=None)
a.datas.append(('messagetypes.txt', os.path.join(srcPath, 'messagetypes.txt'), 'DATA')) os.rename(os.path.join(srcPath, '__init__.py.backup'), os.path.join(srcPath, '__init__.py'))
# fix duplicates
for d in a.datas:
if 'pyconfig' in d[0]:
a.datas.remove(d)
break
def addTranslations(): def addTranslations():
import os import os
@ -72,6 +58,13 @@ a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'),
(os.path.join('sslkeys', 'key.pem'), os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY') (os.path.join('sslkeys', 'key.pem'), os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY')
] ]
with open(os.path.join(srcPath, 'version.py'), 'rt') as f:
softwareVersion = f.readline().split('\'')[1]
fname = 'Bitmessage_%s_%s.exe' % ("x86" if arch == 32 else "x64", softwareVersion)
if snapshot:
fname = 'Bitmessagedev_%s_%s.exe' % ("x86" if arch == 32 else "x64", today)
pyz = PYZ(a.pure) pyz = PYZ(a.pure)
exe = EXE(pyz, exe = EXE(pyz,
a.scripts, a.scripts,
@ -79,7 +72,7 @@ exe = EXE(pyz,
a.zipfiles, a.zipfiles,
a.datas, a.datas,
a.binaries, a.binaries,
name='Bitmessage.exe', name=fname,
debug=False, debug=False,
strip=None, strip=None,
upx=False, upx=False,