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.

138 lines
4.0 KiB

  1. #!/usr/bin/env python
  2. # coding: utf-8
  3. from __future__ import print_function
  4. import os.path
  5. import warnings
  6. import sys
  7. try:
  8. from setuptools import setup, Command
  9. setuptools_available = True
  10. except ImportError:
  11. from distutils.core import setup, Command
  12. setuptools_available = False
  13. from distutils.spawn import spawn
  14. try:
  15. # This will create an exe that needs Microsoft Visual C++ 2008
  16. # Redistributable Package
  17. import py2exe
  18. except ImportError:
  19. if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
  20. print('Cannot import py2exe', file=sys.stderr)
  21. exit(1)
  22. py2exe_options = {
  23. 'bundle_files': 1,
  24. 'compressed': 1,
  25. 'optimize': 2,
  26. 'dist_dir': '.',
  27. 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
  28. }
  29. # Get the version from youtube_dl/version.py without importing the package
  30. exec(compile(open('youtube_dl/version.py').read(),
  31. 'youtube_dl/version.py', 'exec'))
  32. DESCRIPTION = 'YouTube video downloader'
  33. LONG_DESCRIPTION = 'Command-line program to download videos from YouTube.com and other video sites'
  34. py2exe_console = [{
  35. 'script': './youtube_dl/__main__.py',
  36. 'dest_base': 'youtube-dl',
  37. 'version': __version__,
  38. 'description': DESCRIPTION,
  39. 'comments': LONG_DESCRIPTION,
  40. 'product_name': 'youtube-dl',
  41. 'product_version': __version__,
  42. }]
  43. py2exe_params = {
  44. 'console': py2exe_console,
  45. 'options': {'py2exe': py2exe_options},
  46. 'zipfile': None
  47. }
  48. if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
  49. params = py2exe_params
  50. else:
  51. files_spec = [
  52. ('etc/bash_completion.d', ['youtube-dl.bash-completion']),
  53. ('etc/fish/completions', ['youtube-dl.fish']),
  54. ('share/doc/youtube_dl', ['README.txt']),
  55. ('share/man/man1', ['youtube-dl.1'])
  56. ]
  57. root = os.path.dirname(os.path.abspath(__file__))
  58. data_files = []
  59. for dirname, files in files_spec:
  60. resfiles = []
  61. for fn in files:
  62. if not os.path.exists(fn):
  63. warnings.warn('Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn)
  64. else:
  65. resfiles.append(fn)
  66. data_files.append((dirname, resfiles))
  67. params = {
  68. 'data_files': data_files,
  69. }
  70. if setuptools_available:
  71. params['entry_points'] = {'console_scripts': ['youtube-dl = youtube_dl:main']}
  72. else:
  73. params['scripts'] = ['bin/youtube-dl']
  74. class build_lazy_extractors(Command):
  75. description = 'Build the extractor lazy loading module'
  76. user_options = []
  77. def initialize_options(self):
  78. pass
  79. def finalize_options(self):
  80. pass
  81. def run(self):
  82. spawn(
  83. [sys.executable, 'devscripts/make_lazy_extractors.py', 'youtube_dl/extractor/lazy_extractors.py'],
  84. dry_run=self.dry_run,
  85. )
  86. setup(
  87. name='youtube_dl',
  88. version=__version__,
  89. description=DESCRIPTION,
  90. long_description=LONG_DESCRIPTION,
  91. url='https://github.com/rg3/youtube-dl',
  92. author='Ricardo Garcia',
  93. author_email='ytdl@yt-dl.org',
  94. maintainer='Sergey M.',
  95. maintainer_email='dstftw@gmail.com',
  96. packages=[
  97. 'youtube_dl',
  98. 'youtube_dl.extractor', 'youtube_dl.downloader',
  99. 'youtube_dl.postprocessor'],
  100. # Provokes warning on most systems (why?!)
  101. # test_suite = 'nose.collector',
  102. # test_requires = ['nosetest'],
  103. classifiers=[
  104. 'Topic :: Multimedia :: Video',
  105. 'Development Status :: 5 - Production/Stable',
  106. 'Environment :: Console',
  107. 'License :: Public Domain',
  108. 'Programming Language :: Python :: 2.6',
  109. 'Programming Language :: Python :: 2.7',
  110. 'Programming Language :: Python :: 3',
  111. 'Programming Language :: Python :: 3.2',
  112. 'Programming Language :: Python :: 3.3',
  113. 'Programming Language :: Python :: 3.4',
  114. 'Programming Language :: Python :: 3.5',
  115. 'Programming Language :: Python :: 3.6',
  116. ],
  117. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  118. **params
  119. )