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