setup.py 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. #!/usr/bin/env python3
  2. import os.path
  3. import sys
  4. import warnings
  5. try:
  6. from setuptools import Command, find_packages, setup
  7. setuptools_available = True
  8. except ImportError:
  9. from distutils.core import Command, setup
  10. setuptools_available = False
  11. from distutils.spawn import spawn
  12. def read(fname):
  13. with open(fname, encoding='utf-8') as f:
  14. return f.read()
  15. # Get the version from yt_dlp/version.py without importing the package
  16. def read_version(fname):
  17. exec(compile(read(fname), fname, 'exec'))
  18. return locals()['__version__']
  19. VERSION = read_version('yt_dlp/version.py')
  20. DESCRIPTION = 'A youtube-dl fork with additional features and patches'
  21. LONG_DESCRIPTION = '\n\n'.join((
  22. 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
  23. '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
  24. read('README.md')))
  25. REQUIREMENTS = read('requirements.txt').splitlines()
  26. if sys.argv[1:2] == ['py2exe']:
  27. import py2exe # noqa: F401
  28. warnings.warn(
  29. 'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
  30. 'The recommended way is to use "pyinst.py" to build using pyinstaller')
  31. params = {
  32. 'console': [{
  33. 'script': './yt_dlp/__main__.py',
  34. 'dest_base': 'yt-dlp',
  35. 'version': VERSION,
  36. 'description': DESCRIPTION,
  37. 'comments': LONG_DESCRIPTION.split('\n')[0],
  38. 'product_name': 'yt-dlp',
  39. 'product_version': VERSION,
  40. }],
  41. 'options': {
  42. 'py2exe': {
  43. 'bundle_files': 0,
  44. 'compressed': 1,
  45. 'optimize': 2,
  46. 'dist_dir': './dist',
  47. 'excludes': ['Crypto', 'Cryptodome'], # py2exe cannot import Crypto
  48. 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
  49. # Modules that are only imported dynamically must be added here
  50. 'includes': ['yt_dlp.compat._legacy'],
  51. }
  52. },
  53. 'zipfile': None
  54. }
  55. else:
  56. files_spec = [
  57. ('share/bash-completion/completions', ['completions/bash/yt-dlp']),
  58. ('share/zsh/site-functions', ['completions/zsh/_yt-dlp']),
  59. ('share/fish/vendor_completions.d', ['completions/fish/yt-dlp.fish']),
  60. ('share/doc/yt_dlp', ['README.txt']),
  61. ('share/man/man1', ['yt-dlp.1'])
  62. ]
  63. root = os.path.dirname(os.path.abspath(__file__))
  64. data_files = []
  65. for dirname, files in files_spec:
  66. resfiles = []
  67. for fn in files:
  68. if not os.path.exists(fn):
  69. warnings.warn('Skipping file %s since it is not present. Try running `make pypi-files` first' % fn)
  70. else:
  71. resfiles.append(fn)
  72. data_files.append((dirname, resfiles))
  73. params = {
  74. 'data_files': data_files,
  75. }
  76. if setuptools_available:
  77. params['entry_points'] = {'console_scripts': ['yt-dlp = yt_dlp:main']}
  78. else:
  79. params['scripts'] = ['yt-dlp']
  80. class build_lazy_extractors(Command):
  81. description = 'Build the extractor lazy loading module'
  82. user_options = []
  83. def initialize_options(self):
  84. pass
  85. def finalize_options(self):
  86. pass
  87. def run(self):
  88. spawn([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'],
  89. dry_run=self.dry_run)
  90. if setuptools_available:
  91. packages = find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins'))
  92. else:
  93. packages = ['yt_dlp', 'yt_dlp.downloader', 'yt_dlp.extractor', 'yt_dlp.postprocessor']
  94. setup(
  95. name='yt-dlp',
  96. version=VERSION,
  97. maintainer='pukkandan',
  98. maintainer_email='pukkandan.ytdlp@gmail.com',
  99. description=DESCRIPTION,
  100. long_description=LONG_DESCRIPTION,
  101. long_description_content_type='text/markdown',
  102. url='https://github.com/yt-dlp/yt-dlp',
  103. packages=packages,
  104. install_requires=REQUIREMENTS,
  105. project_urls={
  106. 'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',
  107. 'Source': 'https://github.com/yt-dlp/yt-dlp',
  108. 'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues',
  109. 'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators',
  110. },
  111. classifiers=[
  112. 'Topic :: Multimedia :: Video',
  113. 'Development Status :: 5 - Production/Stable',
  114. 'Environment :: Console',
  115. 'Programming Language :: Python',
  116. 'Programming Language :: Python :: 3.6',
  117. 'Programming Language :: Python :: 3.7',
  118. 'Programming Language :: Python :: 3.8',
  119. 'Programming Language :: Python :: 3.9',
  120. 'Programming Language :: Python :: 3.10',
  121. 'Programming Language :: Python :: 3.11',
  122. 'Programming Language :: Python :: Implementation',
  123. 'Programming Language :: Python :: Implementation :: CPython',
  124. 'Programming Language :: Python :: Implementation :: PyPy',
  125. 'License :: Public Domain',
  126. 'Operating System :: OS Independent',
  127. ],
  128. python_requires='>=3.6',
  129. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  130. **params
  131. )