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