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.

130 lines
3.7 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. py2exe_console = [{
  30. "script": "./youtube_dl/__main__.py",
  31. "dest_base": "youtube-dl",
  32. }]
  33. py2exe_params = {
  34. 'console': py2exe_console,
  35. 'options': {"py2exe": py2exe_options},
  36. 'zipfile': None
  37. }
  38. if len(sys.argv) >= 2 and sys.argv[1] == 'py2exe':
  39. params = py2exe_params
  40. else:
  41. files_spec = [
  42. ('etc/bash_completion.d', ['youtube-dl.bash-completion']),
  43. ('etc/fish/completions', ['youtube-dl.fish']),
  44. ('share/doc/youtube_dl', ['README.txt']),
  45. ('share/man/man1', ['youtube-dl.1'])
  46. ]
  47. root = os.path.dirname(os.path.abspath(__file__))
  48. data_files = []
  49. for dirname, files in files_spec:
  50. resfiles = []
  51. for fn in files:
  52. if not os.path.exists(fn):
  53. warnings.warn('Skipping file %s since it is not present. Type make to build all automatically generated files.' % fn)
  54. else:
  55. resfiles.append(fn)
  56. data_files.append((dirname, resfiles))
  57. params = {
  58. 'data_files': data_files,
  59. }
  60. if setuptools_available:
  61. params['entry_points'] = {'console_scripts': ['youtube-dl = youtube_dl:main']}
  62. else:
  63. params['scripts'] = ['bin/youtube-dl']
  64. class build_lazy_extractors(Command):
  65. description = "Build the extractor lazy loading module"
  66. user_options = []
  67. def initialize_options(self):
  68. pass
  69. def finalize_options(self):
  70. pass
  71. def run(self):
  72. spawn(
  73. [sys.executable, 'devscripts/make_lazy_extractors.py', 'youtube_dl/extractor/lazy_extractors.py'],
  74. dry_run=self.dry_run,
  75. )
  76. # Get the version from youtube_dl/version.py without importing the package
  77. exec(compile(open('youtube_dl/version.py').read(),
  78. 'youtube_dl/version.py', 'exec'))
  79. setup(
  80. name='youtube_dl',
  81. version=__version__,
  82. description='YouTube video downloader',
  83. long_description='Small command-line program to download videos from'
  84. ' YouTube.com and other video sites.',
  85. url='https://github.com/rg3/youtube-dl',
  86. author='Ricardo Garcia',
  87. author_email='ytdl@yt-dl.org',
  88. maintainer='Philipp Hagemeister',
  89. maintainer_email='phihag@phihag.de',
  90. packages=[
  91. 'youtube_dl',
  92. 'youtube_dl.extractor', 'youtube_dl.downloader',
  93. 'youtube_dl.postprocessor'],
  94. # Provokes warning on most systems (why?!)
  95. # test_suite = 'nose.collector',
  96. # test_requires = ['nosetest'],
  97. classifiers=[
  98. "Topic :: Multimedia :: Video",
  99. "Development Status :: 5 - Production/Stable",
  100. "Environment :: Console",
  101. "License :: Public Domain",
  102. "Programming Language :: Python :: 2.6",
  103. "Programming Language :: Python :: 2.7",
  104. "Programming Language :: Python :: 3",
  105. "Programming Language :: Python :: 3.2",
  106. "Programming Language :: Python :: 3.3",
  107. "Programming Language :: Python :: 3.4",
  108. "Programming Language :: Python :: 3.5",
  109. ],
  110. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  111. **params
  112. )