setup.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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/ytdl-org/youtube-dl',
  92. author='Ricardo Garcia',
  93. author_email='ytdl@yt-dl.org',
  94. maintainer='Sergey M.',
  95. maintainer_email='dstftw@gmail.com',
  96. license='Unlicense',
  97. packages=[
  98. 'youtube_dl',
  99. 'youtube_dl.extractor', 'youtube_dl.downloader',
  100. 'youtube_dl.postprocessor'],
  101. # Provokes warning on most systems (why?!)
  102. # test_suite = 'nose.collector',
  103. # test_requires = ['nosetest'],
  104. classifiers=[
  105. 'Topic :: Multimedia :: Video',
  106. 'Development Status :: 5 - Production/Stable',
  107. 'Environment :: Console',
  108. 'License :: Public Domain',
  109. 'Programming Language :: Python',
  110. 'Programming Language :: Python :: 2',
  111. 'Programming Language :: Python :: 2.6',
  112. 'Programming Language :: Python :: 2.7',
  113. 'Programming Language :: Python :: 3',
  114. 'Programming Language :: Python :: 3.2',
  115. 'Programming Language :: Python :: 3.3',
  116. 'Programming Language :: Python :: 3.4',
  117. 'Programming Language :: Python :: 3.5',
  118. 'Programming Language :: Python :: 3.6',
  119. 'Programming Language :: Python :: 3.7',
  120. 'Programming Language :: Python :: 3.8',
  121. 'Programming Language :: Python :: Implementation',
  122. 'Programming Language :: Python :: Implementation :: CPython',
  123. 'Programming Language :: Python :: Implementation :: IronPython',
  124. 'Programming Language :: Python :: Implementation :: Jython',
  125. 'Programming Language :: Python :: Implementation :: PyPy',
  126. ],
  127. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  128. **params
  129. )