]> jfr.im git - yt-dlp.git/blob - setup.py
[build] Move bundle scripts into `bundle` submodule
[yt-dlp.git] / setup.py
1 #!/usr/bin/env python3
2
3 # Allow execution from anywhere
4 import os
5 import sys
6
7 sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
8
9 import subprocess
10
11 try:
12 from setuptools import Command, find_packages, setup
13 setuptools_available = True
14 except ImportError:
15 from distutils.core import Command, setup
16 setuptools_available = False
17
18 from devscripts.utils import read_file, read_version
19
20 VERSION = read_version(varname='_pkg_version')
21
22 DESCRIPTION = 'A youtube-dl fork with additional features and patches'
23
24 LONG_DESCRIPTION = '\n\n'.join((
25 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
26 '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
27 read_file('README.md')))
28
29 REQUIREMENTS = read_file('requirements.txt').splitlines()
30
31
32 def packages():
33 if setuptools_available:
34 return find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins', 'devscripts'))
35
36 return [
37 'yt_dlp', 'yt_dlp.extractor', 'yt_dlp.downloader', 'yt_dlp.postprocessor', 'yt_dlp.compat',
38 ]
39
40
41 def build_params():
42 files_spec = [
43 ('share/bash-completion/completions', ['completions/bash/yt-dlp']),
44 ('share/zsh/site-functions', ['completions/zsh/_yt-dlp']),
45 ('share/fish/vendor_completions.d', ['completions/fish/yt-dlp.fish']),
46 ('share/doc/yt_dlp', ['README.txt']),
47 ('share/man/man1', ['yt-dlp.1'])
48 ]
49 data_files = []
50 for dirname, files in files_spec:
51 resfiles = []
52 for fn in files:
53 if not os.path.exists(fn):
54 warnings.warn(f'Skipping file {fn} since it is not present. Try running " make pypi-files " first')
55 else:
56 resfiles.append(fn)
57 data_files.append((dirname, resfiles))
58
59 params = {'data_files': data_files}
60
61 if setuptools_available:
62 params['entry_points'] = {
63 'console_scripts': ['yt-dlp = yt_dlp:main'],
64 'pyinstaller40': ['hook-dirs = yt_dlp.__pyinstaller:get_hook_dirs'],
65 }
66 else:
67 params['scripts'] = ['yt-dlp']
68 return params
69
70
71 class build_lazy_extractors(Command):
72 description = 'Build the extractor lazy loading module'
73 user_options = []
74
75 def initialize_options(self):
76 pass
77
78 def finalize_options(self):
79 pass
80
81 def run(self):
82 if self.dry_run:
83 print('Skipping build of lazy extractors in dry run mode')
84 return
85 subprocess.run([sys.executable, 'devscripts/make_lazy_extractors.py'])
86
87
88 def main():
89 params = build_params()
90 setup(
91 name='yt-dlp', # package name (do not change/remove comment)
92 version=VERSION,
93 maintainer='pukkandan',
94 maintainer_email='pukkandan.ytdlp@gmail.com',
95 description=DESCRIPTION,
96 long_description=LONG_DESCRIPTION,
97 long_description_content_type='text/markdown',
98 url='https://github.com/yt-dlp/yt-dlp',
99 packages=packages(),
100 install_requires=REQUIREMENTS,
101 python_requires='>=3.8',
102 project_urls={
103 'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',
104 'Source': 'https://github.com/yt-dlp/yt-dlp',
105 'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues',
106 'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators',
107 },
108 classifiers=[
109 'Topic :: Multimedia :: Video',
110 'Development Status :: 5 - Production/Stable',
111 'Environment :: Console',
112 'Programming Language :: Python',
113 'Programming Language :: Python :: 3.8',
114 'Programming Language :: Python :: 3.9',
115 'Programming Language :: Python :: 3.10',
116 'Programming Language :: Python :: 3.11',
117 'Programming Language :: Python :: 3.12',
118 'Programming Language :: Python :: Implementation',
119 'Programming Language :: Python :: Implementation :: CPython',
120 'Programming Language :: Python :: Implementation :: PyPy',
121 'License :: Public Domain',
122 'Operating System :: OS Independent',
123 ],
124 cmdclass={'build_lazy_extractors': build_lazy_extractors},
125 **params
126 )
127
128
129 main()