From af0320681984a07155de114c6fa32e3f347b7a7c Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Thu, 15 May 2014 19:29:04 +0300 Subject: [PATCH] Add py2exe --- setup.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 9 deletions(-) diff --git a/setup.py b/setup.py index 5c3af6f..db0b52e 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,17 @@ #! /usr/bin/env python +import sys +from os import name + +PY2EXE = len(sys.argv) >= 2 and sys.argv[1] == 'py2exe' + +try: + import py2exe +except ImportError as e: + if PY2EXE: + print e + sys.exit(1) + from distutils.core import setup from youtube_dl_gui import ( @@ -13,8 +25,61 @@ from youtube_dl_gui import ( __descriptionfull__ ) -icons_path = '/usr/local/share/icons/hicolor/' -youtube_dl_icons = 'youtube_dl_gui/icons/youtube-dl-gui_' +ICONS_SIZE = ('16x16', '32x32', '64x64', '128x128', '256x256') +ICONS_NAME = 'youtube_dl_gui/icons/youtube-dl-gui_%s.png' + +ICONS_LIST = [ICONS_NAME % size for size in ICONS_SIZE] + +py2exe_includes = [ + 'wx.lib.pubsub.*', + 'wx.lib.pubsub.core.*', + 'wx.lib.pubsub.core.arg1.*' +] + +py2exe_options = { + 'includes': py2exe_includes +} + +py2exe_windows = { + 'script': 'youtube_dl_gui\\__main__.py', + 'icon_resources': [(0, 'youtube_dl_gui\\icons\\youtube-dl-gui.ico')] +} + +py2exe_dependencies = [ + 'C:\\Windows\\System32\\ffmpeg.exe', + 'C:\\Windows\\System32\\ffprobe.exe', + 'C:\\python27\\DLLs\MSVCP90.dll' +] + +# Set icons path +if PY2EXE: + icons_path = 'icons' +else: + # On windows you have to copy the icons manually if you dont use py2exe + icons_path = '/usr/local/share/icons/hicolor/' + +# Set params +if PY2EXE: + data_files = [ + ('', py2exe_dependencies), + (icons_path, ICONS_LIST) + ] + + params = { + 'data_files': data_files, + 'windows': [py2exe_windows], + 'options': {'py2exe': py2exe_options} + } +else: + data_files = [] + if name != 'nt': + for index, size in enumerate(ICONS_SIZE): + data_file = (icons_path + size + '/apps', [ICONS_LIST[index]]) + data_files.append(data_file) + + params = { + 'data_files': data_files + } setup( name=__appname__, @@ -25,12 +90,8 @@ setup( author_email=__contact__, description=__description__, long_description=__descriptionfull__, + packages=['youtube_dl_gui'], - data_files=[ - (icons_path + '16x16/apps', [youtube_dl_icons + '16x16.png']), - (icons_path + '32x32/apps', [youtube_dl_icons + '32x32.png']), - (icons_path + '64x64/apps', [youtube_dl_icons + '64x64.png']), - (icons_path + '128x128/apps', [youtube_dl_icons + '128x128.png']), - (icons_path + '256x256/apps', [youtube_dl_icons + '256x256.png']) - ] + + **params )