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