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