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