mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-11-04 08:35:12 +00:00 
			
		
		
		
	- Use `manylinux-shared` images for Linux builds - Discontinue `yt-dlp_linux_armv7l`/`linux_armv7l_exe` release binary - Add `yt-dlp_linux_armv7l.zip`/`linux_armv7l_dir` release binary - Add `yt-dlp_musllinux` and `yt-dlp_musllinux_aarch64` release binaries - Migrate `linux_exe` build strategy from staticx+musl to manylinux2014/glibc2.17 - Rewrite release.yml's "unholy bash monstrosity" as devscripts/setup_variables.py Closes #10072, Closes #10630, Closes #10578, Closes #13976, Closes #13977, Closes #14106 Authored by: bashonly
		
			
				
	
	
		
			67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			67 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
import argparse
 | 
						|
import datetime as dt
 | 
						|
import functools
 | 
						|
import re
 | 
						|
import subprocess
 | 
						|
 | 
						|
 | 
						|
def read_file(fname):
 | 
						|
    with open(fname, encoding='utf-8') as f:
 | 
						|
        return f.read()
 | 
						|
 | 
						|
 | 
						|
def write_file(fname, content, mode='w'):
 | 
						|
    with open(fname, mode, encoding='utf-8') as f:
 | 
						|
        return f.write(content)
 | 
						|
 | 
						|
 | 
						|
def read_version(fname='yt_dlp/version.py', varname='__version__'):
 | 
						|
    """Get the version without importing the package"""
 | 
						|
    items = {}
 | 
						|
    exec(compile(read_file(fname), fname, 'exec'), items)
 | 
						|
    return items[varname]
 | 
						|
 | 
						|
 | 
						|
def calculate_version(version=None, fname='yt_dlp/version.py'):
 | 
						|
    if version and '.' in version:
 | 
						|
        return version
 | 
						|
 | 
						|
    revision = version
 | 
						|
    version = dt.datetime.now(dt.timezone.utc).strftime('%Y.%m.%d')
 | 
						|
 | 
						|
    if revision:
 | 
						|
        assert re.fullmatch(r'[0-9]+', revision), 'Revision must be numeric'
 | 
						|
    else:
 | 
						|
        old_version = read_version(fname=fname).split('.')
 | 
						|
        if version.split('.') == old_version[:3]:
 | 
						|
            revision = str(int(([*old_version, 0])[3]) + 1)
 | 
						|
 | 
						|
    return f'{version}.{revision}' if revision else version
 | 
						|
 | 
						|
 | 
						|
def get_filename_args(has_infile=False, default_outfile=None):
 | 
						|
    parser = argparse.ArgumentParser()
 | 
						|
    if has_infile:
 | 
						|
        parser.add_argument('infile', help='Input file')
 | 
						|
    kwargs = {'nargs': '?', 'default': default_outfile} if default_outfile else {}
 | 
						|
    parser.add_argument('outfile', **kwargs, help='Output file')
 | 
						|
 | 
						|
    opts = parser.parse_args()
 | 
						|
    if has_infile:
 | 
						|
        return opts.infile, opts.outfile
 | 
						|
    return opts.outfile
 | 
						|
 | 
						|
 | 
						|
def compose_functions(*functions):
 | 
						|
    return lambda x: functools.reduce(lambda y, f: f(y), functions, x)
 | 
						|
 | 
						|
 | 
						|
def run_process(*args, **kwargs):
 | 
						|
    kwargs.setdefault('text', True)
 | 
						|
    kwargs.setdefault('check', True)
 | 
						|
    kwargs.setdefault('capture_output', True)
 | 
						|
    if kwargs['text']:
 | 
						|
        kwargs.setdefault('encoding', 'utf-8')
 | 
						|
        kwargs.setdefault('errors', 'replace')
 | 
						|
    return subprocess.run(args, **kwargs)
 |