3 # Allow direct execution
7 sys
.path
.insert(0, os
.path
.dirname(os
.path
.dirname(os
.path
.abspath(__file__
))))
14 from devscripts
.utils
import compose_functions
, read_file
, write_file
16 VERSION_FILE
= 'yt_dlp/version.py'
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
)))