build_exe.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from distutils.core import setup
  2. import py2exe
  3. import sys, os
  4. """This will create an exe that needs Microsoft Visual C++ 2008 Redistributable Package"""
  5. # If run without args, build executables
  6. if len(sys.argv) == 1:
  7. sys.argv.append("py2exe")
  8. # os.chdir(os.path.dirname(os.path.abspath(sys.argv[0]))) # conflict with wine-py2exe.sh
  9. sys.path.append('./youtube_dl')
  10. options = {
  11. "bundle_files": 1,
  12. "compressed": 1,
  13. "optimize": 2,
  14. "dist_dir": '.',
  15. "dll_excludes": ['w9xpopen.exe']
  16. }
  17. console = [{
  18. "script":"./youtube_dl/__main__.py",
  19. "dest_base": "youtube-dl",
  20. }]
  21. init_file = open('./youtube_dl/__init__.py')
  22. for line in init_file.readlines():
  23. if line.startswith('__version__'):
  24. version = line[11:].strip(" ='\n")
  25. break
  26. else:
  27. version = ''
  28. setup(name='youtube-dl',
  29. version=version,
  30. description='Small command-line program to download videos from YouTube.com and other video sites',
  31. url='https://github.com/rg3/youtube-dl',
  32. packages=['youtube_dl'],
  33. console = console,
  34. options = {"py2exe": options},
  35. zipfile = None,
  36. )
  37. import shutil
  38. shutil.rmtree("build")