2020-05-02 14:02:27 +02:00
|
|
|
# -*- mode: python -*-
|
2017-02-27 13:02:37 +01:00
|
|
|
import ctypes
|
|
|
|
import os
|
2019-09-16 12:50:40 +02:00
|
|
|
import sys
|
2020-05-02 14:02:27 +02:00
|
|
|
import time
|
|
|
|
|
2021-06-10 15:41:44 +02:00
|
|
|
from PyInstaller.utils.hooks import copy_metadata
|
2019-09-16 12:50:40 +02:00
|
|
|
|
2022-01-18 15:29:17 +01:00
|
|
|
|
2019-09-16 12:50:40 +02:00
|
|
|
site_root = os.path.abspath(HOMEPATH)
|
|
|
|
spec_root = os.path.abspath(SPECPATH)
|
2020-05-02 14:02:27 +02:00
|
|
|
arch = 32 if ctypes.sizeof(ctypes.c_voidp) == 4 else 64
|
2020-02-15 17:20:40 +01:00
|
|
|
cdrivePath = site_root[0:3]
|
2021-06-11 20:52:42 +02:00
|
|
|
srcPath = os.path.join(spec_root[:-20], "pybitmessage")
|
2020-05-02 14:02:27 +02:00
|
|
|
sslName = 'OpenSSL-Win%i' % arch
|
2020-02-15 17:20:40 +01:00
|
|
|
openSSLPath = os.path.join(cdrivePath, sslName)
|
|
|
|
msvcrDllPath = os.path.join(cdrivePath, "windows", "system32")
|
|
|
|
outPath = os.path.join(spec_root, "bitmessagemain")
|
2020-05-02 14:02:27 +02:00
|
|
|
qtBase = "PyQt4"
|
2019-09-16 12:50:40 +02:00
|
|
|
|
2020-05-02 14:02:27 +02:00
|
|
|
sys.path.insert(0, srcPath)
|
|
|
|
os.chdir(srcPath)
|
2017-02-27 13:02:37 +01:00
|
|
|
|
|
|
|
snapshot = False
|
|
|
|
|
2022-01-18 15:29:17 +01:00
|
|
|
hookspath = os.path.join(spec_root, 'hooks')
|
2017-02-27 13:02:37 +01:00
|
|
|
|
2019-09-16 12:50:40 +02:00
|
|
|
a = Analysis(
|
2020-05-02 14:02:27 +02:00
|
|
|
[os.path.join(srcPath, 'bitmessagemain.py')],
|
2022-01-18 15:29:17 +01:00
|
|
|
datas=[
|
2021-06-10 15:41:44 +02:00
|
|
|
(os.path.join(spec_root[:-20], 'pybitmessage.egg-info') + '/*',
|
2022-01-18 15:29:17 +01:00
|
|
|
'pybitmessage.egg-info')
|
2021-06-10 15:41:44 +02:00
|
|
|
] + copy_metadata('msgpack-python') + copy_metadata('qrcode')
|
|
|
|
+ copy_metadata('six') + copy_metadata('stem'),
|
2020-05-02 14:02:27 +02:00
|
|
|
pathex=[outPath],
|
|
|
|
hiddenimports=[
|
|
|
|
'bitmessageqt.languagebox', 'pyopencl', 'numpy', 'win32com',
|
2021-06-10 15:41:44 +02:00
|
|
|
'setuptools.msvc', '_cffi_backend',
|
|
|
|
'plugins.menu_qrcode', 'plugins.proxyconfig_stem'
|
2020-05-02 14:02:27 +02:00
|
|
|
],
|
2021-06-11 20:52:42 +02:00
|
|
|
runtime_hooks=[os.path.join(hookspath, 'pyinstaller_rthook_plugins.py')],
|
2021-05-05 17:56:36 +02:00
|
|
|
excludes=['bsddb', 'bz2', 'tcl', 'tk', 'Tkinter', 'tests']
|
2020-05-02 14:02:27 +02:00
|
|
|
)
|
|
|
|
|
2017-02-27 13:02:37 +01:00
|
|
|
|
|
|
|
def addTranslations():
|
|
|
|
extraDatas = []
|
2020-02-15 17:20:40 +01:00
|
|
|
for file_ in os.listdir(os.path.join(srcPath, 'translations')):
|
|
|
|
if file_[-3:] != ".qm":
|
2017-02-27 13:02:37 +01:00
|
|
|
continue
|
2020-05-02 14:02:27 +02:00
|
|
|
extraDatas.append((
|
|
|
|
os.path.join('translations', file_),
|
2020-02-15 17:20:40 +01:00
|
|
|
os.path.join(srcPath, 'translations', file_), 'DATA'))
|
|
|
|
for libdir in sys.path:
|
|
|
|
qtdir = os.path.join(libdir, qtBase, 'translations')
|
|
|
|
if os.path.isdir(qtdir):
|
|
|
|
break
|
|
|
|
if not os.path.isdir(qtdir):
|
|
|
|
return extraDatas
|
|
|
|
for file_ in os.listdir(qtdir):
|
|
|
|
if file_[0:3] != "qt_" or file_[5:8] != ".qm":
|
2017-02-27 13:02:37 +01:00
|
|
|
continue
|
2020-05-02 14:02:27 +02:00
|
|
|
extraDatas.append((
|
|
|
|
os.path.join('translations', file_),
|
2020-02-15 17:20:40 +01:00
|
|
|
os.path.join(qtdir, file_), 'DATA'))
|
2017-02-27 13:02:37 +01:00
|
|
|
return extraDatas
|
|
|
|
|
2020-05-02 14:02:27 +02:00
|
|
|
|
|
|
|
dir_append = os.path.join(srcPath, 'bitmessageqt')
|
|
|
|
|
|
|
|
a.datas += [
|
|
|
|
(os.path.join('ui', file_), os.path.join(dir_append, file_), 'DATA')
|
|
|
|
for file_ in os.listdir(dir_append) if file_.endswith('.ui')
|
|
|
|
]
|
2017-02-27 13:02:37 +01:00
|
|
|
|
2022-01-18 15:29:17 +01:00
|
|
|
sql_dir = os.path.join(srcPath, 'sql')
|
|
|
|
|
|
|
|
a.datas += [
|
|
|
|
('sql', os.path.join(sql_dir, file_), 'DATA')
|
|
|
|
for file_ in os.listdir(sql_dir) if file_.endswith('.sql')
|
|
|
|
]
|
|
|
|
|
2017-02-27 13:02:37 +01:00
|
|
|
# append the translations directory
|
|
|
|
a.datas += addTranslations()
|
2022-01-28 13:55:23 +01:00
|
|
|
a.datas += [('default.ini', os.path.join(srcPath, 'default.ini'), 'DATA')]
|
2020-05-02 14:02:27 +02:00
|
|
|
|
|
|
|
excluded_binaries = [
|
|
|
|
'QtOpenGL4.dll',
|
|
|
|
'QtSvg4.dll',
|
|
|
|
'QtXml4.dll',
|
|
|
|
]
|
|
|
|
a.binaries = TOC([x for x in a.binaries if x[0] not in excluded_binaries])
|
|
|
|
|
|
|
|
a.binaries += [
|
|
|
|
# No effect: libeay32.dll will be taken from PyQt if installed
|
|
|
|
('libeay32.dll', os.path.join(openSSLPath, 'libeay32.dll'), 'BINARY'),
|
|
|
|
(os.path.join('bitmsghash', 'bitmsghash%i.dll' % arch),
|
|
|
|
os.path.join(srcPath, 'bitmsghash', 'bitmsghash%i.dll' % arch),
|
2022-01-18 15:29:17 +01:00
|
|
|
'BINARY'),
|
2020-05-02 14:02:27 +02:00
|
|
|
(os.path.join('bitmsghash', 'bitmsghash.cl'),
|
2022-01-18 15:29:17 +01:00
|
|
|
os.path.join(srcPath, 'bitmsghash', 'bitmsghash.cl'), 'BINARY'),
|
2020-05-02 14:02:27 +02:00
|
|
|
(os.path.join('sslkeys', 'cert.pem'),
|
2022-01-18 15:29:17 +01:00
|
|
|
os.path.join(srcPath, 'sslkeys', 'cert.pem'), 'BINARY'),
|
2020-05-02 14:02:27 +02:00
|
|
|
(os.path.join('sslkeys', 'key.pem'),
|
2022-01-18 15:29:17 +01:00
|
|
|
os.path.join(srcPath, 'sslkeys', 'key.pem'), 'BINARY')
|
2020-05-02 14:02:27 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
from version import softwareVersion
|
|
|
|
|
|
|
|
today = time.strftime("%Y%m%d")
|
|
|
|
|
|
|
|
fname = '%s_%%s_%s.exe' % (
|
|
|
|
('Bitmessagedev', today) if snapshot else ('Bitmessage', softwareVersion)
|
|
|
|
) % ("x86" if arch == 32 else "x64")
|
|
|
|
|
|
|
|
|
2017-02-27 13:02:37 +01:00
|
|
|
pyz = PYZ(a.pure)
|
2020-05-02 14:02:27 +02:00
|
|
|
exe = EXE(
|
|
|
|
pyz,
|
|
|
|
a.scripts,
|
|
|
|
a.binaries,
|
|
|
|
a.zipfiles,
|
|
|
|
a.datas,
|
|
|
|
name=fname,
|
|
|
|
debug=False,
|
|
|
|
strip=None,
|
|
|
|
upx=False,
|
|
|
|
console=False, icon=os.path.join(srcPath, 'images', 'can-icon.ico')
|
|
|
|
)
|
2019-09-16 12:50:40 +02:00
|
|
|
|
2020-05-02 14:02:27 +02:00
|
|
|
coll = COLLECT(
|
|
|
|
exe,
|
|
|
|
a.binaries,
|
|
|
|
a.zipfiles,
|
|
|
|
a.datas,
|
|
|
|
strip=False,
|
|
|
|
upx=False,
|
|
|
|
name='main'
|
|
|
|
)
|