]> jfr.im git - yt-dlp.git/blob - setup.py
[cleanup] Consistent style for file heads
[yt-dlp.git] / setup.py
1 #!/usr/bin/env python3
2
3 import os.path
4 import sys
5 import warnings
6
7 try:
8 from setuptools import Command, find_packages, setup
9 setuptools_available = True
10 except ImportError:
11 from distutils.core import Command, setup
12 setuptools_available = False
13 from distutils.spawn import spawn
14
15
16 def read(fname):
17 with open(fname, encoding='utf-8') as f:
18 return f.read()
19
20
21 # Get the version from yt_dlp/version.py without importing the package
22 def read_version(fname):
23 exec(compile(read(fname), fname, 'exec'))
24 return locals()['__version__']
25
26
27 VERSION = read_version('yt_dlp/version.py')
28
29 DESCRIPTION = 'A youtube-dl fork with additional features and patches'
30
31 LONG_DESCRIPTION = '\n\n'.join((
32 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
33 '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
34 read('README.md')))
35
36 REQUIREMENTS = read('requirements.txt').splitlines()
37
38
39 if sys.argv[1:2] == ['py2exe']:
40 import py2exe # noqa: F401
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 params = {
45 'console': [{
46 'script': './yt_dlp/__main__.py',
47 'dest_base': 'yt-dlp',
48 'version': VERSION,
49 'description': DESCRIPTION,
50 'comments': LONG_DESCRIPTION.split('\n')[0],
51 'product_name': 'yt-dlp',
52 'product_version': VERSION,
53 }],
54 'options': {
55 'py2exe': {
56 'bundle_files': 0,
57 'compressed': 1,
58 'optimize': 2,
59 'dist_dir': './dist',
60 'excludes': ['Crypto', 'Cryptodome'], # py2exe cannot import Crypto
61 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'],
62 # Modules that are only imported dynamically must be added here
63 'includes': ['yt_dlp.compat._legacy'],
64 }
65 },
66 'zipfile': None
67 }
68
69 else:
70 files_spec = [
71 ('share/bash-completion/completions', ['completions/bash/yt-dlp']),
72 ('share/zsh/site-functions', ['completions/zsh/_yt-dlp']),
73 ('share/fish/vendor_completions.d', ['completions/fish/yt-dlp.fish']),
74 ('share/doc/yt_dlp', ['README.txt']),
75 ('share/man/man1', ['yt-dlp.1'])
76 ]
77 root = os.path.dirname(os.path.abspath(__file__))
78 data_files = []
79 for dirname, files in files_spec:
80 resfiles = []
81 for fn in files:
82 if not os.path.exists(fn):
83 warnings.warn('Skipping file %s since it is not present. Try running `make pypi-files` first' % fn)
84 else:
85 resfiles.append(fn)
86 data_files.append((dirname, resfiles))
87
88 params = {
89 'data_files': data_files,
90 }
91
92 if setuptools_available:
93 params['entry_points'] = {'console_scripts': ['yt-dlp = yt_dlp:main']}
94 else:
95 params['scripts'] = ['yt-dlp']
96
97
98 class build_lazy_extractors(Command):
99 description = 'Build the extractor lazy loading module'
100 user_options = []
101
102 def initialize_options(self):
103 pass
104
105 def finalize_options(self):
106 pass
107
108 def run(self):
109 spawn([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'],
110 dry_run=self.dry_run)
111
112
113 if setuptools_available:
114 packages = find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins'))
115 else:
116 packages = ['yt_dlp', 'yt_dlp.downloader', 'yt_dlp.extractor', 'yt_dlp.postprocessor']
117
118
119 setup(
120 name='yt-dlp',
121 version=VERSION,
122 maintainer='pukkandan',
123 maintainer_email='pukkandan.ytdlp@gmail.com',
124 description=DESCRIPTION,
125 long_description=LONG_DESCRIPTION,
126 long_description_content_type='text/markdown',
127 url='https://github.com/yt-dlp/yt-dlp',
128 packages=packages,
129 install_requires=REQUIREMENTS,
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.6',
142 'Programming Language :: Python :: 3.7',
143 'Programming Language :: Python :: 3.8',
144 'Programming Language :: Python :: 3.9',
145 'Programming Language :: Python :: 3.10',
146 'Programming Language :: Python :: 3.11',
147 'Programming Language :: Python :: Implementation',
148 'Programming Language :: Python :: Implementation :: CPython',
149 'Programming Language :: Python :: Implementation :: PyPy',
150 'License :: Public Domain',
151 'Operating System :: OS Independent',
152 ],
153 python_requires='>=3.6',
154
155 cmdclass={'build_lazy_extractors': build_lazy_extractors},
156 **params
157 )