setup.py 5.1 KB

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