From 10e43203ed62b7ee741056ee6bf3f4ceb58cac3e Mon Sep 17 00:00:00 2001 From: David Amrhein Date: Tue, 26 Jan 2016 11:56:28 -0500 Subject: [PATCH] Enable building and installing of GUI for windows --- .gitignore | 4 ++ lbrynet/lbrynet_gui/GuiApp.py | 9 ++-- setup_win32.py | 90 +++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 5 deletions(-) create mode 100644 setup_win32.py diff --git a/.gitignore b/.gitignore index 63cca906f..23ba8568c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ lbrynet.egg-info/PKG-INFO *.egg + +/build + +/dist diff --git a/lbrynet/lbrynet_gui/GuiApp.py b/lbrynet/lbrynet_gui/GuiApp.py index 573ac1df6..94c977759 100644 --- a/lbrynet/lbrynet_gui/GuiApp.py +++ b/lbrynet/lbrynet_gui/GuiApp.py @@ -69,7 +69,7 @@ class DownloaderApp(object): if os.name == "nt": root.iconbitmap(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), - "lbrynet", "lbrynet_downloader_gui", "lbry-dark-icon.ico")) + "lbry-dark-icon.ico")) else: root.wm_iconbitmap("@" + os.path.join(os.path.dirname(__file__), "lbry-dark-icon.xbm")) @@ -111,8 +111,7 @@ class DownloaderApp(object): logo_file_name = "lbry-dark-242x80.gif" if os.name == "nt": - logo_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "lbrynet", - "lbrynet_downloader_gui", logo_file_name) + logo_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), logo_file_name) else: logo_file = os.path.join(os.path.dirname(__file__), logo_file_name) @@ -142,8 +141,8 @@ class DownloaderApp(object): dropdown_file_name = "drop_down.gif" if os.name == "nt": - dropdown_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), "lbrynet", - "lbrynet_downloader_gui", dropdown_file_name) + dropdown_file = os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])), + dropdown_file_name) else: dropdown_file = os.path.join(os.path.dirname(__file__), dropdown_file_name) diff --git a/setup_win32.py b/setup_win32.py new file mode 100644 index 000000000..b414606a7 --- /dev/null +++ b/setup_win32.py @@ -0,0 +1,90 @@ +# -*- coding: utf-8 -*- +""" +To create local builds and distributable .msi, run the following command: +python setup_win32.py build bdist_msi +""" +import os +import sys + +from cx_Freeze import setup, Executable + + +def find_data_file(filename): + if getattr(sys, 'frozen', False): + # The application is frozen + data_dir = os.path.dirname(sys.executable) + else: + # The application is not frozen + # Change this bit to match where you store your data files: + data_dir = os.path.dirname(__file__) + return os.path.join(data_dir, filename) + +shortcut_table = [ + ('DesktopShortcut', # Shortcut + 'DesktopFolder', # Directory + 'LBRY', # Name + 'TARGETDIR', # Component + '[TARGETDIR]\LBRY.exe', # Target + None, # Arguments + None, # Description + None, # Hotkey + os.path.join('lbrynet', 'lbrynet_gui', 'lbry-dark-icon.ico'), # Icon + None, # IconIndex + None, # ShowCmd + 'TARGETDIR', # WkDir + ), + ] + +# Now create the table dictionary +msi_data = {'Shortcut': shortcut_table} + +bdist_msi_options = { + 'upgrade_code': '{66620F3A-DC3A-11E2-B341-002219E9B01F}', + 'add_to_path': False, + 'initial_target_dir': r'[LocalAppDataFolder]\LBRY', + 'data': msi_data, + } + +build_exe_options = { + 'include_msvcr': True, + 'includes': [], + 'packages': ['os', 'twisted', 'miniupnpc', 'unqlite', 'seccure', + 'requests', 'bitcoinrpc', 'txjsonrpc', 'win32api', 'Crypto', + 'gmpy', 'yapsy'], + 'excludes': ['zope.interface._zope_interface_coptimizations'], + 'include_files': [os.path.join('lbrynet', 'lbrynet_gui', 'close.gif'), + os.path.join('lbrynet', 'lbrynet_gui', 'close1.png'), + os.path.join('lbrynet', 'lbrynet_gui', 'close2.gif'), + os.path.join('lbrynet', 'lbrynet_gui', 'drop_down.gif'), + os.path.join('lbrynet', 'lbrynet_gui', 'hide_options.gif'), + os.path.join('lbrynet', 'lbrynet_gui', 'lbry-dark-242x80.gif'), + os.path.join('lbrynet', 'lbrynet_gui', 'lbry-dark-icon.ico'), + os.path.join('lbrynet', 'lbrynet_gui', 'lbry-dark-icon.xbm'), + os.path.join('lbrynet', 'lbrynet_gui', 'show_options.gif'), + os.path.join('lbrycrdd.exe'), # Not included in repo + os.path.join('lbrycrd-cli.exe'), # Not included in repo + ], + 'namespace_packages': ['zope']} + +exe = Executable( + script=os.path.join('lbrynet', 'lbrynet_gui', 'gui.py'), + base='Win32GUI', + icon=os.path.join('lbrynet', 'lbrynet_gui', 'lbry-dark-icon.ico'), + compress=True, + shortcutName='LBRY', + shortcutDir='DesktopFolder', + targetName='LBRY.exe' + # targetDir="LocalAppDataFolder" + ) + +setup( + name='LBRY', + version='0.0.4', + description='A fully decentralized network for distributing data', + url='lbry.io', + author='', + keywords='LBRY', + options={'build_exe': build_exe_options, + 'bdist_msi': bdist_msi_options}, + executables=[exe], + )