setup.py 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/usr/bin/env python3
  2. # coding: utf-8
  3. import os.path
  4. import warnings
  5. import sys
  6. try:
  7. from setuptools import setup, Command, find_packages
  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. # Get the version from hypervideo_dl/version.py without importing the package
  14. exec(compile(open('hypervideo_dl/version.py').read(), 'hypervideo_dl/version.py', 'exec'))
  15. DESCRIPTION = 'A youtube-dl fork with additional features and patches'
  16. LONG_DESCRIPTION = '\n\n'.join((
  17. 'Official repository: <https://github.com/hypervideo/hypervideo>',
  18. '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
  19. open('README.md', encoding='utf-8').read()))
  20. REQUIREMENTS = ['mutagen', 'pycryptodome', 'websockets']
  21. if sys.argv[1:2] == ['py2exe']:
  22. import py2exe # noqa: F401
  23. warnings.warn(
  24. 'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
  25. 'The recommended way is to use "pyinst.py" to build using pyinstaller')
  26. params = {
  27. 'console': [{
  28. 'script': './hypervideo_dl/__main__.py',
  29. 'dest_base': 'hypervideo',
  30. 'version': __version__,
  31. 'description': DESCRIPTION,
  32. 'comments': LONG_DESCRIPTION.split('\n')[0],
  33. 'product_name': 'hypervideo',
  34. 'product_version': __version__,
  35. }],
  36. 'options': {
  37. 'py2exe': {
  38. 'bundle_files': 0,
  39. 'compressed': 1,
  40. 'optimize': 2,
  41. 'dist_dir': './dist',
  42. 'excludes': ['Crypto', 'Cryptodome'], # py2exe cannot import Crypto
  43. 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
  44. }
  45. },
  46. 'zipfile': None
  47. }
  48. else:
  49. files_spec = [
  50. ('share/bash-completion/completions', ['completions/bash/hypervideo']),
  51. ('share/zsh/site-functions', ['completions/zsh/_hypervideo']),
  52. ('share/fish/vendor_completions.d', ['completions/fish/hypervideo.fish']),
  53. ('share/doc/hypervideo_dl', ['README.txt']),
  54. ('share/man/man1', ['hypervideo.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. Try running `make pypi-files` first' % 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': ['hypervideo = hypervideo_dl:main']}
  71. else:
  72. params['scripts'] = ['hypervideo']
  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([sys.executable, 'devscripts/make_lazy_extractors.py', 'hypervideo_dl/extractor/lazy_extractors.py'],
  82. dry_run=self.dry_run)
  83. if setuptools_available:
  84. packages = find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins'))
  85. else:
  86. packages = ['hypervideo_dl', 'hypervideo_dl.downloader', 'hypervideo_dl.extractor', 'hypervideo_dl.postprocessor']
  87. setup(
  88. name='hypervideo',
  89. version=__version__,
  90. maintainer='Jesús E..',
  91. maintainer_email='heckyel@hyperbola.info',
  92. license='CC0-1.0',
  93. description=DESCRIPTION,
  94. long_description=LONG_DESCRIPTION,
  95. long_description_content_type='text/markdown',
  96. url='https://git.conocimientoslibres.ga/software/hypervideo.git',
  97. packages=packages,
  98. install_requires=REQUIREMENTS,
  99. classifiers=[
  100. 'Topic :: Multimedia :: Video',
  101. 'Development Status :: 5 - Production/Stable',
  102. 'Environment :: Console',
  103. 'Programming Language :: Python',
  104. 'Programming Language :: Python :: 3.6',
  105. 'Programming Language :: Python :: 3.7',
  106. 'Programming Language :: Python :: 3.8',
  107. 'Programming Language :: Python :: 3.9',
  108. 'Programming Language :: Python :: 3.10',
  109. 'Programming Language :: Python :: 3.11',
  110. 'Programming Language :: Python :: Implementation',
  111. 'Programming Language :: Python :: Implementation :: CPython',
  112. 'Programming Language :: Python :: Implementation :: PyPy',
  113. 'License :: Public Domain',
  114. 'Operating System :: OS Independent',
  115. ],
  116. python_requires='>=3.6',
  117. cmdclass={'build_lazy_extractors': build_lazy_extractors},
  118. **params
  119. )