]>
Commit | Line | Data |
---|---|---|
cc52de43 | 1 | #!/usr/bin/env python3 |
54007a45 | 2 | |
6c57e8a0 | 3 | import os.path |
4efe62a0 | 4 | import sys |
f8271158 | 5 | import warnings |
a32b573c | 6 | |
5d535b4a | 7 | try: |
f8271158 | 8 | from setuptools import Command, find_packages, setup |
5d535b4a | 9 | setuptools_available = True |
10 | except ImportError: | |
f8271158 | 11 | from distutils.core import Command, setup |
5d535b4a | 12 | setuptools_available = False |
13 | from distutils.spawn import spawn | |
e38df8f9 | 14 | |
c1714454 | 15 | |
16 | def read(fname): | |
17 | with open(fname, encoding='utf-8') as f: | |
18 | return f.read() | |
19 | ||
20 | ||
7a5c1cfe | 21 | # Get the version from yt_dlp/version.py without importing the package |
c1714454 | 22 | def read_version(fname): |
23 | exec(compile(read(fname), fname, 'exec')) | |
24 | return locals()['__version__'] | |
25 | ||
3d4b08df | 26 | |
c1714454 | 27 | VERSION = read_version('yt_dlp/version.py') |
e38df8f9 | 28 | |
96565c7e | 29 | DESCRIPTION = 'A youtube-dl fork with additional features and patches' |
7bc877a2 | 30 | |
31 | LONG_DESCRIPTION = '\n\n'.join(( | |
7a5c1cfe | 32 | 'Official repository: <https://github.com/yt-dlp/yt-dlp>', |
cc1dfc93 | 33 | '**PS**: Some links in this document will not work since this is a copy of the README.md from Github', |
c1714454 | 34 | read('README.md'))) |
770234af | 35 | |
c1714454 | 36 | REQUIREMENTS = read('requirements.txt').splitlines() |
e38df8f9 | 37 | |
5d535b4a | 38 | |
cc1dfc93 | 39 | if sys.argv[1:2] == ['py2exe']: |
c487cf00 | 40 | import py2exe # noqa: F401 |
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') |
44 | params = { | |
45 | 'console': [{ | |
46 | 'script': './yt_dlp/__main__.py', | |
47 | 'dest_base': 'yt-dlp', | |
c1714454 | 48 | 'version': VERSION, |
5d535b4a | 49 | 'description': DESCRIPTION, |
50 | 'comments': LONG_DESCRIPTION.split('\n')[0], | |
51 | 'product_name': 'yt-dlp', | |
c1714454 | 52 | 'product_version': VERSION, |
5d535b4a | 53 | }], |
54 | 'options': { | |
55 | 'py2exe': { | |
56 | 'bundle_files': 0, | |
57 | 'compressed': 1, | |
58 | 'optimize': 2, | |
59 | 'dist_dir': './dist', | |
60 | 'excludes': ['Crypto', 'Cryptodome'], # py2exe cannot import Crypto | |
61 | 'dll_excludes': ['w9xpopen.exe', 'crypt32.dll'], | |
7ab56be2 | 62 | # Modules that are only imported dynamically must be added here |
63 | 'includes': ['yt_dlp.compat._legacy'], | |
5d535b4a | 64 | } |
65 | }, | |
66 | 'zipfile': None | |
67 | } | |
68 | ||
69 | else: | |
70 | files_spec = [ | |
71 | ('share/bash-completion/completions', ['completions/bash/yt-dlp']), | |
72 | ('share/zsh/site-functions', ['completions/zsh/_yt-dlp']), | |
73 | ('share/fish/vendor_completions.d', ['completions/fish/yt-dlp.fish']), | |
74 | ('share/doc/yt_dlp', ['README.txt']), | |
75 | ('share/man/man1', ['yt-dlp.1']) | |
76 | ] | |
77 | root = os.path.dirname(os.path.abspath(__file__)) | |
78 | data_files = [] | |
79 | for dirname, files in files_spec: | |
80 | resfiles = [] | |
81 | for fn in files: | |
82 | if not os.path.exists(fn): | |
83 | warnings.warn('Skipping file %s since it is not present. Try running `make pypi-files` first' % fn) | |
84 | else: | |
85 | resfiles.append(fn) | |
86 | data_files.append((dirname, resfiles)) | |
87 | ||
88 | params = { | |
89 | 'data_files': data_files, | |
90 | } | |
91 | ||
92 | if setuptools_available: | |
93 | params['entry_points'] = {'console_scripts': ['yt-dlp = yt_dlp:main']} | |
94 | else: | |
95 | params['scripts'] = ['yt-dlp'] | |
66c935fb | 96 | |
a5741a3f | 97 | |
5a9858bf | 98 | class build_lazy_extractors(Command): |
3d4b08df | 99 | description = 'Build the extractor lazy loading module' |
5a9858bf JMF |
100 | user_options = [] |
101 | ||
102 | def initialize_options(self): | |
103 | pass | |
104 | ||
105 | def finalize_options(self): | |
106 | pass | |
107 | ||
108 | def run(self): | |
cc1dfc93 | 109 | spawn([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'], |
110 | dry_run=self.dry_run) | |
5a9858bf | 111 | |
66c935fb | 112 | |
5d535b4a | 113 | if setuptools_available: |
114 | packages = find_packages(exclude=('youtube_dl', 'youtube_dlc', 'test', 'ytdlp_plugins')) | |
115 | else: | |
116 | packages = ['yt_dlp', 'yt_dlp.downloader', 'yt_dlp.extractor', 'yt_dlp.postprocessor'] | |
117 | ||
66c935fb | 118 | |
cc51a7d4 | 119 | setup( |
e28f1c0a | 120 | name='yt-dlp', |
c1714454 | 121 | version=VERSION, |
e28f1c0a | 122 | maintainer='pukkandan', |
123 | maintainer_email='pukkandan.ytdlp@gmail.com', | |
3d4b08df S |
124 | description=DESCRIPTION, |
125 | long_description=LONG_DESCRIPTION, | |
e28f1c0a | 126 | long_description_content_type='text/markdown', |
127 | url='https://github.com/yt-dlp/yt-dlp', | |
66c935fb | 128 | packages=packages, |
e38df8f9 | 129 | install_requires=REQUIREMENTS, |
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.6', |
142 | 'Programming Language :: Python :: 3.7', | |
143 | 'Programming Language :: Python :: 3.8', | |
56ba69e4 | 144 | 'Programming Language :: Python :: 3.9', |
145 | 'Programming Language :: Python :: 3.10', | |
146 | 'Programming Language :: Python :: 3.11', | |
e28f1c0a | 147 | 'Programming Language :: Python :: Implementation', |
148 | 'Programming Language :: Python :: Implementation :: CPython', | |
e28f1c0a | 149 | 'Programming Language :: Python :: Implementation :: PyPy', |
150 | 'License :: Public Domain', | |
151 | 'Operating System :: OS Independent', | |
a5741a3f | 152 | ], |
14b17a55 | 153 | python_requires='>=3.6', |
359d6d86 | 154 | |
155 | cmdclass={'build_lazy_extractors': build_lazy_extractors}, | |
fec89790 | 156 | **params |
6515018d | 157 | ) |