aboutsummaryrefslogtreecommitdiffstats
path: root/devscripts/set-variant.py
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-07-29 20:33:01 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-08-09 01:08:48 +0530
commit70b2340909d8d917f71d20181614fd7392d3f7f0 (patch)
tree9836125a25c94260c99040cb4d73f302257bd924 /devscripts/set-variant.py
parent115add43876964956917bf596c1d0b148c5b3c26 (diff)
downloadhypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.tar.lz
hypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.tar.xz
hypervideo-pre-70b2340909d8d917f71d20181614fd7392d3f7f0.zip
[build, devscripts] Add devscript to set a build variant
Closes #4471
Diffstat (limited to 'devscripts/set-variant.py')
-rw-r--r--devscripts/set-variant.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/devscripts/set-variant.py b/devscripts/set-variant.py
new file mode 100644
index 000000000..10341e744
--- /dev/null
+++ b/devscripts/set-variant.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+# Allow direct execution
+import os
+import sys
+
+sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+
+import argparse
+import functools
+import re
+
+from devscripts.utils import compose_functions, read_file, write_file
+
+VERSION_FILE = 'yt_dlp/version.py'
+
+
+def parse_options():
+ parser = argparse.ArgumentParser(description='Set the build variant of the package')
+ parser.add_argument('variant', help='Name of the variant')
+ parser.add_argument('-M', '--update-message', default=None, help='Message to show in -U')
+ return parser.parse_args()
+
+
+def property_setter(name, value):
+ return functools.partial(re.sub, rf'(?m)^{name}\s*=\s*.+$', f'{name} = {value!r}')
+
+
+opts = parse_options()
+transform = compose_functions(
+ property_setter('VARIANT', opts.variant),
+ property_setter('UPDATE_HINT', opts.update_message)
+)
+
+write_file(VERSION_FILE, transform(read_file(VERSION_FILE)))