2017-02-19 14:48:53 +01:00
|
|
|
import ctypes
|
|
|
|
import os
|
|
|
|
|
2016-03-24 15:29:21 +01:00
|
|
|
srcPath = "C:\\src\\PyBitmessage\\src\\"
|
2017-02-19 14:48:53 +01:00
|
|
|
qtPath = "C:\\Qt-4.8.7\\"
|
|
|
|
openSSLPath = "C:\\OpenSSL-1.0.2j\\"
|
|
|
|
outPath = "C:\\src\\PyInstaller-3.2.1\\bitmessagemain"
|
2016-03-24 15:29:21 +01:00
|
|
|
|
|
|
|
# -*- mode: python -*-
|
|
|
|
a = Analysis([srcPath + 'bitmessagemain.py'],
|
|
|
|
pathex=[outPath],
|
2017-02-19 14:48:53 +01:00
|
|
|
hiddenimports=['messagetypes'],
|
2016-03-24 15:29:21 +01:00
|
|
|
hookspath=None,
|
|
|
|
runtime_hooks=None)
|
2017-02-19 14:48:53 +01:00
|
|
|
|
|
|
|
# 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")
|
|
|
|
a.scripts.append((os.path.join('messagetypes', mt), os.path.join(srcPath, 'messagetypes', mt), 'PYMODULE'))
|
|
|
|
a.datas.append(('messagetypes.txt', os.path.join(srcPath, 'messagetypes.txt'), 'DATA'))
|
|
|
|
|
2016-03-24 15:29:21 +01:00
|
|
|
# fix duplicates
|
|
|
|
for d in a.datas:
|
|
|
|
if 'pyconfig' in d[0]:
|
|
|
|
a.datas.remove(d)
|
|
|
|
break
|
|
|
|
|
|
|
|
def addTranslations():
|
|
|
|
import os
|
|
|
|
extraDatas = []
|
|
|
|
for file in os.listdir(srcPath + 'translations'):
|
|
|
|
if file[-3:] != ".qm":
|
|
|
|
continue
|
2017-02-19 14:48:53 +01:00
|
|
|
extraDatas.append((os.path.join('translations', file), os.path.join(srcPath, 'translations', file) 'DATA'))
|
2016-03-24 15:29:21 +01:00
|
|
|
for file in os.listdir(qtPath + 'translations'):
|
|
|
|
if file[0:3] != "qt_" or file[5:8] != ".qm":
|
|
|
|
continue
|
2017-02-19 14:48:53 +01:00
|
|
|
extraDatas.append((os.path.join('translations', file), os.path.join(qtPath, 'translations', file), 'DATA'))
|
2016-03-24 15:29:21 +01:00
|
|
|
return extraDatas
|
|
|
|
|
|
|
|
def addUIs():
|
|
|
|
import os
|
|
|
|
extraDatas = []
|
|
|
|
for file in os.listdir(srcPath + 'bitmessageqt'):
|
|
|
|
if file[-3:] != ".ui":
|
|
|
|
continue
|
2017-02-19 14:48:53 +01:00
|
|
|
extraDatas.append((os.path.join('ui', file), os.path.join(srcPath, 'bitmessageqt', file), 'DATA'))
|
2016-03-24 15:29:21 +01:00
|
|
|
return extraDatas
|
|
|
|
|
|
|
|
# append the translations directory
|
|
|
|
a.datas += addTranslations()
|
|
|
|
a.datas += addUIs()
|
|
|
|
|
2017-02-19 14:48:53 +01:00
|
|
|
if ctypes.sizeof(ctypes.c_voidp) == 4:
|
|
|
|
arch=32
|
|
|
|
else:
|
|
|
|
arch=64
|
|
|
|
|
|
|
|
a.binaries += [('libeay32.dll', openSSLPath + 'libeay32.dll', 'BINARY'),
|
|
|
|
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % (arch)), os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % (arch)), 'BINARY'),
|
|
|
|
(os.path.join('bitmsghash', 'bitmsghash.cl'), os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
|
|
|
|
(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')
|
|
|
|
]
|
2016-03-24 15:29:21 +01:00
|
|
|
|
|
|
|
pyz = PYZ(a.pure)
|
|
|
|
exe = EXE(pyz,
|
|
|
|
a.scripts,
|
|
|
|
a.binaries,
|
|
|
|
a.zipfiles,
|
|
|
|
a.datas,
|
2017-02-19 14:48:53 +01:00
|
|
|
a.binaries,
|
2016-03-24 15:29:21 +01:00
|
|
|
name='Bitmessage.exe',
|
|
|
|
debug=False,
|
|
|
|
strip=None,
|
|
|
|
upx=False,
|
2017-02-19 14:48:53 +01:00
|
|
|
console=False, icon= os.path.join(srcPath, 'images', 'can-icon.ico')
|