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