]> jfr.im git - yt-dlp.git/blame - setup.py
Fix `Makefile`
[yt-dlp.git] / setup.py
CommitLineData
cc52de43 1#!/usr/bin/env python3
6c57e8a0 2import os.path
4efe62a0 3import sys
f8271158 4import warnings
a32b573c 5
5d535b4a 6try:
f8271158 7 from setuptools import Command, find_packages, setup
5d535b4a 8 setuptools_available = True
9except ImportError:
f8271158 10 from distutils.core import Command, setup
5d535b4a 11 setuptools_available = False
12from distutils.spawn import spawn
e38df8f9 13
7a5c1cfe 14# Get the version from yt_dlp/version.py without importing the package
cc1dfc93 15exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
3d4b08df 16
e38df8f9 17
96565c7e 18DESCRIPTION = 'A youtube-dl fork with additional features and patches'
7bc877a2 19
20LONG_DESCRIPTION = '\n\n'.join((
7a5c1cfe 21 'Official repository: <https://github.com/yt-dlp/yt-dlp>',
cc1dfc93 22 '**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
aee6ce58 23 open('README.md', encoding='utf-8').read()))
770234af 24
aee6ce58 25REQUIREMENTS = open('requirements.txt', encoding='utf-8').read().splitlines()
e38df8f9 26
5d535b4a 27
cc1dfc93 28if sys.argv[1:2] == ['py2exe']:
5d535b4a 29 import py2exe
30 warnings.warn(
386cdfdb 31 'py2exe builds do not support pycryptodomex and needs VC++14 to run. '
5d535b4a 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
56else:
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']
66c935fb 83
a5741a3f 84
5a9858bf 85class build_lazy_extractors(Command):
3d4b08df 86 description = 'Build the extractor lazy loading module'
5a9858bf
JMF
87 user_options = []
88
89 def initialize_options(self):
90 pass
91
92 def finalize_options(self):
93 pass
94
95 def run(self):
cc1dfc93 96 spawn([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'],
97 dry_run=self.dry_run)
5a9858bf 98
66c935fb 99
5d535b4a 100if setuptools_available:
101 packages = find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins'))
102else:
103 packages = ['yt_dlp', 'yt_dlp.downloader', 'yt_dlp.extractor', 'yt_dlp.postprocessor']
104
66c935fb 105
cc51a7d4 106setup(
e28f1c0a 107 name='yt-dlp',
652e7768 108 version=__version__,
e28f1c0a 109 maintainer='pukkandan',
110 maintainer_email='pukkandan.ytdlp@gmail.com',
3d4b08df
S
111 description=DESCRIPTION,
112 long_description=LONG_DESCRIPTION,
e28f1c0a 113 long_description_content_type='text/markdown',
114 url='https://github.com/yt-dlp/yt-dlp',
66c935fb 115 packages=packages,
e38df8f9 116 install_requires=REQUIREMENTS,
7bc877a2 117 project_urls={
0744a815 118 'Documentation': 'https://yt-dlp.readthedocs.io',
7a5c1cfe
P
119 'Source': 'https://github.com/yt-dlp/yt-dlp',
120 'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues',
b5ae35ee 121 'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators',
7bc877a2 122 },
652e7768 123 classifiers=[
e28f1c0a 124 'Topic :: Multimedia :: Video',
125 'Development Status :: 5 - Production/Stable',
126 'Environment :: Console',
127 'Programming Language :: Python',
e28f1c0a 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',
e28f1c0a 133 'Programming Language :: Python :: Implementation :: PyPy',
134 'License :: Public Domain',
135 'Operating System :: OS Independent',
a5741a3f 136 ],
14b17a55 137 python_requires='>=3.6',
359d6d86 138
139 cmdclass={'build_lazy_extractors': build_lazy_extractors},
fec89790 140 **params
6515018d 141)