]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/env python3 | |
2 | ||
3 | # Allow direct execution | |
4 | import os | |
5 | import sys | |
6 | ||
7 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
8 | ||
9 | ||
10 | import argparse | |
11 | import functools | |
12 | import re | |
13 | ||
14 | from devscripts.utils import compose_functions, read_file, write_file | |
15 | ||
16 | VERSION_FILE = 'yt_dlp/version.py' | |
17 | ||
18 | ||
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() | |
24 | ||
25 | ||
26 | def property_setter(name, value): | |
27 | return functools.partial(re.sub, rf'(?m)^{name}\s*=\s*.+$', f'{name} = {value!r}') | |
28 | ||
29 | ||
30 | opts = parse_options() | |
31 | transform = compose_functions( | |
32 | property_setter('VARIANT', opts.variant), | |
33 | property_setter('UPDATE_HINT', opts.update_message) | |
34 | ) | |
35 | ||
36 | write_file(VERSION_FILE, transform(read_file(VERSION_FILE))) |