mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[cleanup,build] Cleanup some build-related code
Fixes an issue in 7ab56be2c7
This commit is contained in:
parent
4f80952353
commit
c171445431
5
Makefile
5
Makefile
|
@ -22,7 +22,9 @@ clean-dist:
|
||||||
rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \
|
rm -rf yt-dlp.1.temp.md yt-dlp.1 README.txt MANIFEST build/ dist/ .coverage cover/ yt-dlp.tar.gz completions/ \
|
||||||
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS .mailmap
|
yt_dlp/extractor/lazy_extractors.py *.spec CONTRIBUTING.md.tmp yt-dlp yt-dlp.exe yt_dlp.egg-info/ AUTHORS .mailmap
|
||||||
clean-cache:
|
clean-cache:
|
||||||
find . \( -name "*.pyc" -o -name "*.class" \) -delete
|
find . \( \
|
||||||
|
-type d -name .pytest_cache -o -type d -name __pycache__ -o -name "*.pyc" -o -name "*.class" \
|
||||||
|
\) -prune -exec rm -rf {} \;
|
||||||
|
|
||||||
completion-bash: completions/bash/yt-dlp
|
completion-bash: completions/bash/yt-dlp
|
||||||
completion-fish: completions/fish/yt-dlp.fish
|
completion-fish: completions/fish/yt-dlp.fish
|
||||||
|
@ -131,6 +133,7 @@ yt-dlp.tar.gz: all
|
||||||
--exclude '*.pyo' \
|
--exclude '*.pyo' \
|
||||||
--exclude '*~' \
|
--exclude '*~' \
|
||||||
--exclude '__pycache__' \
|
--exclude '__pycache__' \
|
||||||
|
--exclude '.pytest_cache' \
|
||||||
--exclude '.git' \
|
--exclude '.git' \
|
||||||
-- \
|
-- \
|
||||||
README.md supportedsites.md Changelog.md LICENSE \
|
README.md supportedsites.md Changelog.md LICENSE \
|
||||||
|
|
|
@ -24,5 +24,5 @@ def build_completion(opt_parser):
|
||||||
f.write(filled_template)
|
f.write(filled_template)
|
||||||
|
|
||||||
|
|
||||||
parser = yt_dlp.parseOpts()[0]
|
parser = yt_dlp.parseOpts(ignore_config_files=True)[0]
|
||||||
build_completion(parser)
|
build_completion(parser)
|
||||||
|
|
|
@ -44,5 +44,5 @@ def build_completion(opt_parser):
|
||||||
f.write(filled_template)
|
f.write(filled_template)
|
||||||
|
|
||||||
|
|
||||||
parser = yt_dlp.parseOpts()[0]
|
parser = yt_dlp.parseOpts(ignore_config_files=True)[0]
|
||||||
build_completion(parser)
|
build_completion(parser)
|
||||||
|
|
|
@ -3,6 +3,17 @@
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
|
|
||||||
|
def read(fname):
|
||||||
|
with open(fname, encoding='utf-8') as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
# Get the version from yt_dlp/version.py without importing the package
|
||||||
|
def read_version(fname):
|
||||||
|
exec(compile(read(fname), fname, 'exec'))
|
||||||
|
return locals()['__version__']
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
|
parser = optparse.OptionParser(usage='%prog INFILE OUTFILE')
|
||||||
options, args = parser.parse_args()
|
options, args = parser.parse_args()
|
||||||
|
@ -10,18 +21,9 @@ def main():
|
||||||
parser.error('Expected an input and an output filename')
|
parser.error('Expected an input and an output filename')
|
||||||
|
|
||||||
infile, outfile = args
|
infile, outfile = args
|
||||||
|
|
||||||
with open(infile, encoding='utf-8') as inf:
|
|
||||||
issue_template_tmpl = inf.read()
|
|
||||||
|
|
||||||
# Get the version from yt_dlp/version.py without importing the package
|
|
||||||
exec(compile(open('yt_dlp/version.py').read(),
|
|
||||||
'yt_dlp/version.py', 'exec'))
|
|
||||||
|
|
||||||
out = issue_template_tmpl % {'version': locals()['__version__']}
|
|
||||||
|
|
||||||
with open(outfile, 'w', encoding='utf-8') as outf:
|
with open(outfile, 'w', encoding='utf-8') as outf:
|
||||||
outf.write(out)
|
outf.write(
|
||||||
|
read(infile) % {'version': read_version('yt_dlp/version.py')})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
if os.path.exists(plugins_blocked_dirname):
|
if os.path.exists(plugins_blocked_dirname):
|
||||||
os.rename(plugins_blocked_dirname, plugins_dirname)
|
os.rename(plugins_blocked_dirname, plugins_dirname)
|
||||||
|
|
||||||
with open('devscripts/lazy_load_template.py') as f:
|
with open('devscripts/lazy_load_template.py', encoding='utf-8') as f:
|
||||||
module_template = f.read()
|
module_template = f.read()
|
||||||
|
|
||||||
CLASS_PROPERTIES = ['ie_key', 'working', '_match_valid_url', 'suitable', '_match_id', 'get_temp_id']
|
CLASS_PROPERTIES = ['ie_key', 'working', '_match_valid_url', 'suitable', '_match_id', 'get_temp_id']
|
||||||
|
|
|
@ -43,5 +43,5 @@ def build_completion(opt_parser):
|
||||||
f.write(template)
|
f.write(template)
|
||||||
|
|
||||||
|
|
||||||
parser = yt_dlp.parseOpts()[0]
|
parser = yt_dlp.parseOpts(ignore_config_files=True)[0]
|
||||||
build_completion(parser)
|
build_completion(parser)
|
||||||
|
|
39
pyinst.py
39
pyinst.py
|
@ -3,7 +3,7 @@
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from PyInstaller.utils.hooks import collect_submodules
|
from PyInstaller.__main__ import run as run_pyinstaller
|
||||||
|
|
||||||
OS_NAME = platform.system()
|
OS_NAME = platform.system()
|
||||||
if OS_NAME == 'Windows':
|
if OS_NAME == 'Windows':
|
||||||
|
@ -20,18 +20,22 @@
|
||||||
elif OS_NAME == 'Darwin':
|
elif OS_NAME == 'Darwin':
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise Exception('{OS_NAME} is not supported')
|
raise Exception(f'{OS_NAME} is not supported')
|
||||||
|
|
||||||
ARCH = platform.architecture()[0][:2]
|
ARCH = platform.architecture()[0][:2]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
opts = parse_options()
|
opts = parse_options()
|
||||||
version = read_version()
|
version = read_version('yt_dlp/version.py')
|
||||||
|
|
||||||
|
onedir = '--onedir' in opts or '-D' in opts
|
||||||
|
if not onedir and '-F' not in opts and '--onefile' not in opts:
|
||||||
|
opts.append('--onefile')
|
||||||
|
|
||||||
suffix = '_macos' if OS_NAME == 'Darwin' else '_x86' if ARCH == '32' else ''
|
suffix = '_macos' if OS_NAME == 'Darwin' else '_x86' if ARCH == '32' else ''
|
||||||
final_file = 'dist/%syt-dlp%s%s' % (
|
final_file = 'dist/%syt-dlp%s%s' % (
|
||||||
'yt-dlp/' if '--onedir' in opts else '', suffix, '.exe' if OS_NAME == 'Windows' else '')
|
'yt-dlp/' if onedir else '', suffix, '.exe' if OS_NAME == 'Windows' else '')
|
||||||
|
|
||||||
print(f'Building yt-dlp v{version} {ARCH}bit for {OS_NAME} with options {opts}')
|
print(f'Building yt-dlp v{version} {ARCH}bit for {OS_NAME} with options {opts}')
|
||||||
print('Remember to update the version using "devscripts/update-version.py"')
|
print('Remember to update the version using "devscripts/update-version.py"')
|
||||||
|
@ -45,17 +49,16 @@ def main():
|
||||||
'--icon=devscripts/logo.ico',
|
'--icon=devscripts/logo.ico',
|
||||||
'--upx-exclude=vcruntime140.dll',
|
'--upx-exclude=vcruntime140.dll',
|
||||||
'--noconfirm',
|
'--noconfirm',
|
||||||
|
# NB: Modules that are only imported dynamically must be added here.
|
||||||
|
# --collect-submodules may not work correctly if user has a yt-dlp installed via PIP
|
||||||
|
'--hidden-import=yt_dlp.compat._legacy',
|
||||||
*dependency_options(),
|
*dependency_options(),
|
||||||
*opts,
|
*opts,
|
||||||
'--collect-submodules=yt_dlp',
|
|
||||||
'yt_dlp/__main__.py',
|
'yt_dlp/__main__.py',
|
||||||
]
|
]
|
||||||
|
|
||||||
print(f'Running PyInstaller with {opts}')
|
print(f'Running PyInstaller with {opts}')
|
||||||
|
run_pyinstaller(opts)
|
||||||
import PyInstaller.__main__
|
|
||||||
|
|
||||||
PyInstaller.__main__.run(opts)
|
|
||||||
|
|
||||||
set_version_info(final_file, version)
|
set_version_info(final_file, version)
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,12 +69,14 @@ def parse_options():
|
||||||
if ARCH != opts[0]:
|
if ARCH != opts[0]:
|
||||||
raise Exception(f'{opts[0]}bit executable cannot be built on a {ARCH}bit system')
|
raise Exception(f'{opts[0]}bit executable cannot be built on a {ARCH}bit system')
|
||||||
opts = opts[1:]
|
opts = opts[1:]
|
||||||
return opts or ['--onefile']
|
return opts
|
||||||
|
|
||||||
|
|
||||||
def read_version():
|
# Get the version from yt_dlp/version.py without importing the package
|
||||||
exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
|
def read_version(fname):
|
||||||
return locals()['__version__']
|
with open(fname, encoding='utf-8') as f:
|
||||||
|
exec(compile(f.read(), fname, 'exec'))
|
||||||
|
return locals()['__version__']
|
||||||
|
|
||||||
|
|
||||||
def version_to_list(version):
|
def version_to_list(version):
|
||||||
|
@ -80,10 +85,12 @@ def version_to_list(version):
|
||||||
|
|
||||||
|
|
||||||
def dependency_options():
|
def dependency_options():
|
||||||
dependencies = [pycryptodome_module(), 'mutagen', 'brotli', 'certifi'] + collect_submodules('websockets')
|
# Due to the current implementation, these are auto-detected, but explicitly add them just in case
|
||||||
excluded_modules = ['test', 'ytdlp_plugins', 'youtube-dl', 'youtube-dlc']
|
dependencies = [pycryptodome_module(), 'mutagen', 'brotli', 'certifi', 'websockets']
|
||||||
|
excluded_modules = ['test', 'ytdlp_plugins', 'youtube_dl', 'youtube_dlc']
|
||||||
|
|
||||||
yield from (f'--hidden-import={module}' for module in dependencies)
|
yield from (f'--hidden-import={module}' for module in dependencies)
|
||||||
|
yield '--collect-submodules=websockets'
|
||||||
yield from (f'--exclude-module={module}' for module in excluded_modules)
|
yield from (f'--exclude-module={module}' for module in excluded_modules)
|
||||||
|
|
||||||
|
|
||||||
|
|
24
setup.py
24
setup.py
|
@ -11,18 +11,28 @@
|
||||||
setuptools_available = False
|
setuptools_available = False
|
||||||
from distutils.spawn import spawn
|
from distutils.spawn import spawn
|
||||||
|
|
||||||
# Get the version from yt_dlp/version.py without importing the package
|
|
||||||
exec(compile(open('yt_dlp/version.py').read(), 'yt_dlp/version.py', 'exec'))
|
|
||||||
|
|
||||||
|
def read(fname):
|
||||||
|
with open(fname, encoding='utf-8') as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
|
||||||
|
# Get the version from yt_dlp/version.py without importing the package
|
||||||
|
def read_version(fname):
|
||||||
|
exec(compile(read(fname), fname, 'exec'))
|
||||||
|
return locals()['__version__']
|
||||||
|
|
||||||
|
|
||||||
|
VERSION = read_version('yt_dlp/version.py')
|
||||||
|
|
||||||
DESCRIPTION = 'A youtube-dl fork with additional features and patches'
|
DESCRIPTION = 'A youtube-dl fork with additional features and patches'
|
||||||
|
|
||||||
LONG_DESCRIPTION = '\n\n'.join((
|
LONG_DESCRIPTION = '\n\n'.join((
|
||||||
'Official repository: <https://github.com/yt-dlp/yt-dlp>',
|
'Official repository: <https://github.com/yt-dlp/yt-dlp>',
|
||||||
'**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
|
'**PS**: Some links in this document will not work since this is a copy of the README.md from Github',
|
||||||
open('README.md', encoding='utf-8').read()))
|
read('README.md')))
|
||||||
|
|
||||||
REQUIREMENTS = open('requirements.txt', encoding='utf-8').read().splitlines()
|
REQUIREMENTS = read('requirements.txt').splitlines()
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1:2] == ['py2exe']:
|
if sys.argv[1:2] == ['py2exe']:
|
||||||
|
@ -34,11 +44,11 @@
|
||||||
'console': [{
|
'console': [{
|
||||||
'script': './yt_dlp/__main__.py',
|
'script': './yt_dlp/__main__.py',
|
||||||
'dest_base': 'yt-dlp',
|
'dest_base': 'yt-dlp',
|
||||||
'version': __version__,
|
'version': VERSION,
|
||||||
'description': DESCRIPTION,
|
'description': DESCRIPTION,
|
||||||
'comments': LONG_DESCRIPTION.split('\n')[0],
|
'comments': LONG_DESCRIPTION.split('\n')[0],
|
||||||
'product_name': 'yt-dlp',
|
'product_name': 'yt-dlp',
|
||||||
'product_version': __version__,
|
'product_version': VERSION,
|
||||||
}],
|
}],
|
||||||
'options': {
|
'options': {
|
||||||
'py2exe': {
|
'py2exe': {
|
||||||
|
@ -107,7 +117,7 @@ def run(self):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='yt-dlp',
|
name='yt-dlp',
|
||||||
version=__version__,
|
version=VERSION,
|
||||||
maintainer='pukkandan',
|
maintainer='pukkandan',
|
||||||
maintainer_email='pukkandan.ytdlp@gmail.com',
|
maintainer_email='pukkandan.ytdlp@gmail.com',
|
||||||
description=DESCRIPTION,
|
description=DESCRIPTION,
|
||||||
|
|
Loading…
Reference in a new issue