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