]> jfr.im git - yt-dlp.git/blame - setup.py
[extractor/anvato] Fix extractor and refactor (#5074)
[yt-dlp.git] / setup.py
CommitLineData
cc52de43 1#!/usr/bin/env python3
54007a45 2
6c57e8a0 3import os.path
7b84d6f9 4import subprocess
4efe62a0 5import sys
f8271158 6import warnings
a32b573c 7
5d535b4a 8try:
f8271158 9 from setuptools import Command, find_packages, setup
5d535b4a 10 setuptools_available = True
11except ImportError:
f8271158 12 from distutils.core import Command, setup
5d535b4a 13 setuptools_available = False
e38df8f9 14
115add43 15from devscripts.utils import read_file, read_version
c1714454 16
115add43 17VERSION = read_version()
e38df8f9 18
96565c7e 19DESCRIPTION = 'A youtube-dl fork with additional features and patches'
7bc877a2 20
21LONG_DESCRIPTION = '\n\n'.join((
7a5c1cfe 22 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
cc1dfc93 23 '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
115add43 24 read_file('README.md')))
770234af 25
115add43 26REQUIREMENTS = read_file('requirements.txt').splitlines()
e38df8f9 27
5d535b4a 28
7b84d6f9 29def packages():
30 if setuptools_available:
460eb9c5 31 return find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins', 'devscripts'))
7b84d6f9 32
33 return [
34 'yt_dlp', 'yt_dlp.extractor', 'yt_dlp.downloader', 'yt_dlp.postprocessor', 'yt_dlp.compat',
7b84d6f9 35 ]
36
37
38def py2exe_params():
c487cf00 39 import py2exe # noqa: F401
7b84d6f9 40
5d535b4a 41 warnings.warn(
386cdfdb 42 'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
5d535b4a 43 'The recommended way is to use "pyinst.py" to build using pyinstaller')
7b84d6f9 44
45 return {
5d535b4a 46 'console': [{
47 'script': './yt_dlp/__main__.py',
48 'dest_base': 'yt-dlp',
c1714454 49 'version': VERSION,
5d535b4a 50 'description': DESCRIPTION,
51 'comments': LONG_DESCRIPTION.split('\n')[0],
52 'product_name': 'yt-dlp',
c1714454 53 'product_version': VERSION,
7b84d6f9 54 'icon_resources': [(1, 'devscripts/logo.ico')],
5d535b4a 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'],
7ab56be2 64 # Modules that are only imported dynamically must be added here
65 'includes': ['yt_dlp.compat._legacy'],
5d535b4a 66 }
67 },
68 'zipfile': None
69 }
70
7b84d6f9 71
72def build_params():
5d535b4a 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 ]
5d535b4a 80 data_files = []
81 for dirname, files in files_spec:
82 resfiles = []
83 for fn in files:
84 if not os.path.exists(fn):
7b84d6f9 85 warnings.warn(f'Skipping file {fn} since it is not present. Try running " make pypi-files " first')
5d535b4a 86 else:
87 resfiles.append(fn)
88 data_files.append((dirname, resfiles))
89
7b84d6f9 90 params = {'data_files': data_files}
5d535b4a 91
92 if setuptools_available:
93 params['entry_points'] = {'console_scripts': ['yt-dlp = yt_dlp:main']}
94 else:
95 params['scripts'] = ['yt-dlp']
7b84d6f9 96 return params
66c935fb 97
a5741a3f 98
5a9858bf 99class build_lazy_extractors(Command):
3d4b08df 100 description = 'Build the extractor lazy loading module'
5a9858bf
JMF
101 user_options = []
102
103 def initialize_options(self):
104 pass
105
106 def finalize_options(self):
107 pass
108
109 def run(self):
7b84d6f9 110 if self.dry_run:
111 print('Skipping build of lazy extractors in dry run mode')
112 return
115add43 113 subprocess.run([sys.executable, 'devscripts/make_lazy_extractors.py'])
5d535b4a 114
66c935fb 115
7b84d6f9 116params = py2exe_params() if sys.argv[1:2] == ['py2exe'] else build_params()
cc51a7d4 117setup(
e28f1c0a 118 name='yt-dlp',
c1714454 119 version=VERSION,
e28f1c0a 120 maintainer='pukkandan',
121 maintainer_email='pukkandan.ytdlp@gmail.com',
3d4b08df
S
122 description=DESCRIPTION,
123 long_description=LONG_DESCRIPTION,
e28f1c0a 124 long_description_content_type='text/markdown',
125 url='https://github.com/yt-dlp/yt-dlp',
7b84d6f9 126 packages=packages(),
e38df8f9 127 install_requires=REQUIREMENTS,
6929b41a 128 python_requires='>=3.7',
7bc877a2 129 project_urls={
0a41f331 130 'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme',
7a5c1cfe
P
131 'Source': 'https://github.com/yt-dlp/yt-dlp',
132 'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues',
b5ae35ee 133 'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators',
7bc877a2 134 },
652e7768 135 classifiers=[
e28f1c0a 136 'Topic :: Multimedia :: Video',
137 'Development Status :: 5 - Production/Stable',
138 'Environment :: Console',
139 'Programming Language :: Python',
e28f1c0a 140 'Programming Language :: Python :: 3.7',
141 'Programming Language :: Python :: 3.8',
56ba69e4 142 'Programming Language :: Python :: 3.9',
143 'Programming Language :: Python :: 3.10',
144 'Programming Language :: Python :: 3.11',
e28f1c0a 145 'Programming Language :: Python :: Implementation',
146 'Programming Language :: Python :: Implementation :: CPython',
e28f1c0a 147 'Programming Language :: Python :: Implementation :: PyPy',
148 'License :: Public Domain',
149 'Operating System :: OS Independent',
a5741a3f 150 ],
359d6d86 151 cmdclass={'build_lazy_extractors': build_lazy_extractors},
fec89790 152 **params
6515018d 153)