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.

110 lines
3.1 KiB

  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import print_function
  4. import os.path
  5. import pkg_resources
  6. import warnings
  7. import sys
  8. try:
  9. from setuptools import setup
  10. setuptools_available = True
  11. except ImportError:
  12. from distutils.core import setup
  13. setuptools_available = False
  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'],
  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. # Get the version from youtube_dl/version.py without importing the package
  65. exec(compile(open('youtube_dl/version.py').read(),
  66. 'youtube_dl/version.py', 'exec'))
  67. setup(
  68. name='youtube_dl',
  69. version=__version__,
  70. description='YouTube video downloader',
  71. long_description='Small command-line program to download videos from'
  72. ' YouTube.com and other video sites.',
  73. url='https://github.com/rg3/youtube-dl',
  74. author='Ricardo Garcia',
  75. author_email='ytdl@yt-dl.org',
  76. maintainer='Philipp Hagemeister',
  77. maintainer_email='phihag@phihag.de',
  78. packages=[
  79. 'youtube_dl',
  80. 'youtube_dl.extractor', 'youtube_dl.downloader',
  81. 'youtube_dl.postprocessor'],
  82. # Provokes warning on most systems (why?!)
  83. # test_suite = 'nose.collector',
  84. # test_requires = ['nosetest'],
  85. classifiers=[
  86. "Topic :: Multimedia :: Video",
  87. "Development Status :: 5 - Production/Stable",
  88. "Environment :: Console",
  89. "License :: Public Domain",
  90. "Programming Language :: Python :: 2.6",
  91. "Programming Language :: Python :: 2.7",
  92. "Programming Language :: Python :: 3",
  93. "Programming Language :: Python :: 3.3"
  94. ],
  95. **params
  96. )