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