Release 2023.12.30
[yt-dlp.git] / devscripts / set-variant.py
blob10341e7444effbdd5fa2baa7cbf5dec3903e9df7
1 #!/usr/bin/env python3
3 # Allow direct execution
4 import os
5 import sys
7 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10 import argparse
11 import functools
12 import re
14 from devscripts.utils import compose_functions, read_file, write_file
16 VERSION_FILE = 'yt_dlp/version.py'
19 def parse_options():
20 parser = argparse.ArgumentParser(description='Set the build variant of the package')
21 parser.add_argument('variant', help='Name of the variant')
22 parser.add_argument('-M', '--update-message', default=None, help='Message to show in -U')
23 return parser.parse_args()
26 def property_setter(name, value):
27 return functools.partial(re.sub, rf'(?m)^{name}\s*=\s*.+$', f'{name} = {value!r}')
30 opts = parse_options()
31 transform = compose_functions(
32 property_setter('VARIANT', opts.variant),
33 property_setter('UPDATE_HINT', opts.update_message)
36 write_file(VERSION_FILE, transform(read_file(VERSION_FILE)))