You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.1 KiB

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. #!/usr/bin/env python2
  2. import os
  3. import sys
  4. import shutil
  5. PY2EXE = len(sys.argv) >= 2 and sys.argv[1] == 'py2exe'
  6. if PY2EXE:
  7. try:
  8. import py2exe
  9. except ImportError as error:
  10. print error
  11. sys.exit(1)
  12. from distutils.core import setup
  13. from distutils.sysconfig import get_python_lib
  14. from youtube_dl_gui import (
  15. __author__,
  16. __appname__,
  17. __contact__,
  18. __version__,
  19. __license__,
  20. __projecturl__,
  21. __description__,
  22. __descriptionfull__
  23. )
  24. ICONS_SIZES = ('16x16', '32x32', '48x48', '64x64', '128x128', '256x256')
  25. ICONS_TEMPLATE = 'youtube_dl_gui/icons/youtube-dl-gui_{size}.png'
  26. ICONS_LIST = [ICONS_TEMPLATE.format(size=size) for size in ICONS_SIZES]
  27. # Set icons path
  28. PY2EXE_ICONS = 'icons'
  29. WINDOWS_ICONS = os.path.join(get_python_lib(), 'youtube_dl_gui', 'icons')
  30. LINUX_ICONS = '/usr/share/icons/hicolor/'
  31. LINUX_FALLBACK_ICONS = '/usr/share/pixmaps/'
  32. def create_scripts():
  33. if not os.path.exists('build/_scripts/'):
  34. os.makedirs('build/_scripts')
  35. shutil.copyfile('youtube_dl_gui/__main__.py', 'build/_scripts/youtube-dl-gui')
  36. def py2exe_setup():
  37. py2exe_dependencies = [
  38. 'C:\\Windows\\System32\\ffmpeg.exe',
  39. 'C:\\Windows\\System32\\ffprobe.exe',
  40. 'C:\\python27\\DLLs\\MSVCP90.dll'
  41. ]
  42. py2exe_data_files = [
  43. ('', py2exe_dependencies),
  44. (PY2EXE_ICONS, ICONS_LIST)
  45. ]
  46. py2exe_options = {
  47. 'includes': ['wx.lib.pubsub.*',
  48. 'wx.lib.pubsub.core.*',
  49. 'wx.lib.pubsub.core.arg1.*']
  50. }
  51. py2exe_windows = {
  52. 'script': 'youtube_dl_gui\\__main__.py',
  53. 'icon_resources': [(0, 'youtube_dl_gui\\icons\\youtube-dl-gui.ico')]
  54. }
  55. params = {
  56. 'data_files': py2exe_data_files,
  57. 'windows': [py2exe_windows],
  58. 'options': {'py2exe': py2exe_options}
  59. }
  60. return params
  61. def normal_setup():
  62. data_files = list()
  63. if os.name == 'nt':
  64. icons_dir = (WINDOWS_ICONS, ICONS_LIST)
  65. data_files.append(icons_dir)
  66. params = {'data_files': data_files}
  67. else:
  68. # Create all the hicolor icons
  69. for index, size in enumerate(ICONS_SIZES):
  70. icons_dest = os.path.join(LINUX_ICONS, size, 'apps')
  71. icons_dir = (icons_dest, [ICONS_LIST[index]])
  72. data_files.append(icons_dir)
  73. # Add the 48x48 icon as fallback
  74. fallback_icon = (LINUX_FALLBACK_ICONS, [ICONS_LIST[2]])
  75. data_files.append(fallback_icon)
  76. create_scripts()
  77. params = {'data_files': data_files, 'scripts': ['build/_scripts/youtube-dl-gui']}
  78. return params
  79. if PY2EXE:
  80. params = py2exe_setup()
  81. else:
  82. params = normal_setup()
  83. setup(
  84. author = __author__,
  85. name = __appname__,
  86. version = __version__,
  87. license = __license__,
  88. author_email = __contact__,
  89. url = __projecturl__,
  90. description = __description__,
  91. long_description = __descriptionfull__,
  92. packages = ['youtube_dl_gui'],
  93. **params
  94. )