setup.py 4.4 KB

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