]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python3 | |
2 | import os.path | |
3 | import sys | |
4 | import warnings | |
5 | ||
6 | try: | |
7 | from setuptools import Command, find_packages, setup | |
8 | setuptools_available = True | |
9 | except ImportError: | |
10 | from distutils.core import Command, setup | |
11 | setuptools_available = False | |
12 | from distutils.spawn import spawn | |
13 | ||
14 | ||
15 | def read(fname): | |
16 | with open(fname, encoding='utf-8') as f: | |
17 | return f.read() | |
18 | ||
19 | ||
20 | # Get the version from yt_dlp/version.py without importing the package | |
21 | def read_version(fname): | |
22 | exec(compile(read(fname), fname, 'exec')) | |
23 | return locals()['__version__'] | |
24 | ||
25 | ||
26 | VERSION = read_version('yt_dlp/version.py') | |
27 | ||
28 | DESCRIPTION = 'A youtube-dl fork with additional features and patches' | |
29 | ||
30 | LONG_DESCRIPTION = '\n\n'.join(( | |
31 | 'Official repository: <https://github.com/yt-dlp/yt-dlp>', | |
32 | '**PS**: Some links in this document will not work since this is a copy of the README.md from Github', | |
33 | read('README.md'))) | |
34 | ||
35 | REQUIREMENTS = read('requirements.txt').splitlines() | |
36 | ||
37 | ||
38 | if sys.argv[1:2] == ['py2exe']: | |
39 | import py2exe # noqa: F401 | |
40 | warnings.warn( | |
41 | 'py2exe builds do not support pycryptodomex and needs VC++14 to run. ' | |
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', | |
47 | 'version': VERSION, | |
48 | 'description': DESCRIPTION, | |
49 | 'comments': LONG_DESCRIPTION.split('\n')[0], | |
50 | 'product_name': 'yt-dlp', | |
51 | 'product_version': VERSION, | |
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'], | |
61 | # Modules that are only imported dynamically must be added here | |
62 | 'includes': ['yt_dlp.compat._legacy'], | |
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'] | |
95 | ||
96 | ||
97 | class build_lazy_extractors(Command): | |
98 | description = 'Build the extractor lazy loading module' | |
99 | user_options = [] | |
100 | ||
101 | def initialize_options(self): | |
102 | pass | |
103 | ||
104 | def finalize_options(self): | |
105 | pass | |
106 | ||
107 | def run(self): | |
108 | spawn([sys.executable, 'devscripts/make_lazy_extractors.py', 'yt_dlp/extractor/lazy_extractors.py'], | |
109 | dry_run=self.dry_run) | |
110 | ||
111 | ||
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 | ||
117 | ||
118 | setup( | |
119 | name='yt-dlp', | |
120 | version=VERSION, | |
121 | maintainer='pukkandan', | |
122 | maintainer_email='pukkandan.ytdlp@gmail.com', | |
123 | description=DESCRIPTION, | |
124 | long_description=LONG_DESCRIPTION, | |
125 | long_description_content_type='text/markdown', | |
126 | url='https://github.com/yt-dlp/yt-dlp', | |
127 | packages=packages, | |
128 | install_requires=REQUIREMENTS, | |
129 | project_urls={ | |
130 | 'Documentation': 'https://github.com/yt-dlp/yt-dlp#readme', | |
131 | 'Source': 'https://github.com/yt-dlp/yt-dlp', | |
132 | 'Tracker': 'https://github.com/yt-dlp/yt-dlp/issues', | |
133 | 'Funding': 'https://github.com/yt-dlp/yt-dlp/blob/master/Collaborators.md#collaborators', | |
134 | }, | |
135 | classifiers=[ | |
136 | 'Topic :: Multimedia :: Video', | |
137 | 'Development Status :: 5 - Production/Stable', | |
138 | 'Environment :: Console', | |
139 | 'Programming Language :: Python', | |
140 | 'Programming Language :: Python :: 3.6', | |
141 | 'Programming Language :: Python :: 3.7', | |
142 | 'Programming Language :: Python :: 3.8', | |
143 | 'Programming Language :: Python :: 3.9', | |
144 | 'Programming Language :: Python :: 3.10', | |
145 | 'Programming Language :: Python :: 3.11', | |
146 | 'Programming Language :: Python :: Implementation', | |
147 | 'Programming Language :: Python :: Implementation :: CPython', | |
148 | 'Programming Language :: Python :: Implementation :: PyPy', | |
149 | 'License :: Public Domain', | |
150 | 'Operating System :: OS Independent', | |
151 | ], | |
152 | python_requires='>=3.6', | |
153 | ||
154 | cmdclass={'build_lazy_extractors': build_lazy_extractors}, | |
155 | **params | |
156 | ) |