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