Compare commits

...

3 Commits

Author SHA1 Message Date
ThomasV
bd854e2f3c Merge pull request #2569 from bauerj/pyinstaller3
Fix pyinstaller3 build
2017-08-07 11:09:04 +02:00
Johann Bauer
6ccca2f00c Fix pyinstaller3 build 2017-06-29 16:58:10 +02:00
ThomasV
8f60d5ec90 changes for pyinstaller3 2017-06-22 17:58:15 +02:00
5 changed files with 79 additions and 59 deletions

View File

@ -5,9 +5,13 @@ ELECTRUM_GIT_URL=git://github.com/spesmilo/electrum.git
BRANCH=master
NAME_ROOT=electrum
if [ "$#" -gt 0 ]; then
BRANCH="$1"
fi
# These settings probably don't need any change
export WINEPREFIX=/opt/wine64
export PYTHONHASHSEED=22
PYHOME=c:/python27
PYTHON="wine $PYHOME/python.exe -OO -B"
@ -48,17 +52,22 @@ cp -r ../../../packages $WINEPREFIX/drive_c/electrum/
# add locale dir
cp -r ../../../lib/locale $WINEPREFIX/drive_c/electrum/lib/
# Build Qt resources
wine $WINEPREFIX/drive_c/Python27/Lib/site-packages/PyQt4/pyrcc4.exe C:/electrum/icons.qrc -o C:/electrum/lib/icons_rc.py
wine $WINEPREFIX/drive_c/Python27/Lib/site-packages/PyQt4/pyrcc4.exe C:/electrum/icons.qrc -o C:/electrum/gui/qt/icons_rc.py
pushd $WINEPREFIX/drive_c/electrum
$PYTHON setup.py install
popd
cd ..
rm -rf dist/
# build standalone version
$PYTHON "C:/pyinstaller/pyinstaller.py" --noconfirm --ascii --name $NAME_ROOT-$VERSION.exe -w deterministic.spec
wine "C:/python27/scripts/pyinstaller.exe" --noconfirm --ascii --name $NAME_ROOT-$VERSION.exe -w deterministic.spec
# build NSIS installer
# $VERSION could be passed to the electrum.nsi script, but this would require some rewriting in the script iself.
wine "$WINEPREFIX/drive_c/Program Files (x86)/NSIS/makensis.exe" /DPRODUCT_VERSION=$VERSION electrum.nsi
@ -67,11 +76,13 @@ cd dist
mv electrum-setup.exe $NAME_ROOT-$VERSION-setup.exe
cd ..
rm build/ -r
# build portable version
cp portable.patch $WINEPREFIX/drive_c/electrum
pushd $WINEPREFIX/drive_c/electrum
patch < portable.patch
popd
$PYTHON "C:/pyinstaller/pyinstaller.py" --noconfirm --ascii --name $NAME_ROOT-$VERSION-portable.exe -w deterministic.spec
wine "C:/python27/scripts/pyinstaller.exe" --noconfirm --ascii --name $NAME_ROOT-$VERSION-portable.exe -w deterministic.spec
echo "Done."

View File

@ -11,6 +11,19 @@ else:
home = 'C:\\electrum\\'
dlls = ['libiconv-2.dll',
'libjpeg-7.dll',
'libMagickCore-2.dll',
'libMagickWand-2.dll',
'libpng12-0.dll',
'libtiff-3.dll',
'libxml2-2.dll',
'libzbar-0.dll',
'zlib1.dll']
zbar_dlls = [('C:\\Program Files (x86)\\Zbar\\bin\\'+x, x) for x in dlls]
# We don't put these files in to actually include them in the script but to make the Analysis method scan them for imports
a = Analysis([home+'electrum',
home+'gui/qt/main_window.py',
@ -21,6 +34,9 @@ a = Analysis([home+'electrum',
home+'lib/bitcoin.py',
home+'lib/dnssec.py',
home+'lib/commands.py',
home+'lib/daemon.py',
home+'lib/plugins.py',
home+'lib/qrscanner.py',
home+'plugins/cosigner_pool/qt.py',
home+'plugins/email_requests/qt.py',
home+'plugins/trezor/client.py',
@ -29,45 +45,15 @@ a = Analysis([home+'electrum',
home+'plugins/ledger/qt.py',
home+'packages/requests/utils.py'
],
pathex=[home+'lib', home+'gui', home+'plugins', home+'packages'],
hiddenimports=['lib', 'gui'],
hookspath=[])
##### include folder in distribution #######
def extra_datas(mydir):
def rec_glob(p, files):
import os
import glob
for d in glob.glob(p):
if os.path.isfile(d):
files.append(d)
rec_glob("%s/*" % d, files)
files = []
rec_glob("%s/*" % mydir, files)
extra_datas = []
for f in files:
d = f.split('\\')
t = ''
for a in d[2:]:
if len(t)==0:
t = a
else:
t = t+'\\'+a
extra_datas.append((t, f, 'DATA'))
return extra_datas
###########################################
# append dirs
# cacert.pem
a.datas += [ ('requests/cacert.pem', home+'packages/requests/cacert.pem', 'DATA') ]
# Py folders that are needed because of the magic import finding
a.datas += extra_datas(home+'gui')
a.datas += extra_datas(home+'lib')
a.datas += extra_datas(home+'plugins')
a.datas += extra_datas(home+'packages')
datas = [
(home+'lib/currencies.json', 'electrum'),
(home+'lib/wordlist/english.txt', 'electrum/wordlist'),
(home+'packages/requests/cacert.pem', 'requests/cacert.pem')
],
binaries= zbar_dlls,
hookspath=[],
hiddenimports=["lib", "gui", "plugins", "electrum_gui.qt.icons_rc"]
)
# http://stackoverflow.com/questions/19055089/pyinstaller-onefile-warning-pyconfig-h-when-importing-scipy-or-scipy-signal
for d in a.datas:
@ -76,6 +62,7 @@ for d in a.datas:
break
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.scripts,
a.binaries,
@ -85,7 +72,7 @@ exe = EXE(pyz,
strip=None,
upx=False,
icon=home+'icons/electrum.ico',
console=False)
console=True)
# The console True makes an annoying black box pop up, but it does make Electrum output command line commands, with this turned off no output will be given but commands can still be used
coll = COLLECT(exe,
@ -96,5 +83,6 @@ coll = COLLECT(exe,
upx=True,
debug=False,
icon=home+'icons/electrum.ico',
console=False,
console=True,
name=os.path.join('dist', 'electrum'))

View File

@ -4,7 +4,6 @@
PYTHON_URL=https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi
PYQT4_URL=http://sourceforge.net/projects/pyqt/files/PyQt4/PyQt-4.11.1/PyQt4-4.11.1-gpl-Py2.7-Qt4.8.6-x32.exe
PYWIN32_URL=http://sourceforge.net/projects/pywin32/files/pywin32/Build%20219/pywin32-219.win32-py2.7.exe/download
PYINSTALLER_URL=https://pypi.python.org/packages/source/P/PyInstaller/PyInstaller-2.1.zip
NSIS_URL=http://prdownloads.sourceforge.net/nsis/nsis-2.46-setup.exe?download
SETUPTOOLS_URL=https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11.win32-py2.7.exe
@ -22,7 +21,8 @@ set -e
# Clean up Wine environment
echo "Cleaning $WINEPREFIX"
rm -rf $WINEPREFIX
rm -rf $WINEPREFIX/
mkdir $WINEPREFIX
echo "done"
wine 'wineboot'
@ -46,23 +46,28 @@ wine pywin32.exe
wget -O PyQt.exe "$PYQT4_URL"
wine PyQt.exe
# Install pyinstaller
wget -O pyinstaller.zip "$PYINSTALLER_URL"
unzip pyinstaller.zip
mv PyInstaller-2.1 $WINEPREFIX/drive_c/pyinstaller
# Install ZBar
#wget -q -O zbar.exe "http://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
#wine zbar.exe
# install Cryptodome
$PYTHON -m pip install pycryptodomex
# Install setuptools
wget -O setuptools.exe "$SETUPTOOLS_URL"
wine setuptools.exe
# Install pyinstaller
$PYTHON -m pip install pyinstaller==3.2.1
$PYTHON -m pip install win_inet_pton
# Install ZBar
wget -q -O zbar.exe "http://sourceforge.net/projects/zbar/files/zbar/0.10/zbar-0.10-setup.exe/download"
wine zbar.exe
# install Cryptodome
$PYTHON -m pip install pycryptodomex
# Upgrade setuptools (so Electrum can be installed later)
$PYTHON -m pip install setuptools --upgrade
# Install NSIS installer
echo "Make sure to untick 'Start NSIS' and 'Show release notes'"
wget -q -O nsis.exe "$NSIS_URL"
wine nsis.exe

View File

@ -90,10 +90,11 @@ if not is_android:
check_imports()
# load local module as electrum
if is_bundle or is_local or is_android:
if is_local or is_android:
import imp
imp.load_module('electrum', *imp.find_module('lib'))
imp.load_module('electrum_gui', *imp.find_module('gui'))
imp.load_module('electrum_plugins', *imp.find_module('plugins'))
from electrum import bitcoin, network
from electrum import SimpleConfig, Network

View File

@ -23,4 +23,19 @@
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import audio_modem
names = [
'audio_modem',
'cosigner_pool',
'digitalbitbox',
'email_requests',
'greenaddress_instant',
'hw_wallet',
'keepkey',
'labels',
'ledger',
'trezor',
'trustedcoin',
'virtualkeyboard',
]