import argparse
import contextlib
import sys
-from datetime import datetime
+from datetime import datetime, timezone
from devscripts.utils import read_version, run_process, write_file
def get_new_version(version, revision):
if not version:
- version = datetime.utcnow().strftime('%Y.%m.%d')
+ version = datetime.now(timezone.utc).strftime('%Y.%m.%d')
if revision:
- assert revision.isdigit(), 'Revision must be a number'
+ assert revision.isdecimal(), 'Revision must be a number'
else:
old_version = read_version().split('.')
if version.split('.') == old_version[:3]:
UPDATE_HINT = None
CHANNEL = {channel!r}
+
+ORIGIN = {origin!r}
+
+_pkg_version = {package_version!r}
'''
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Update the version.py file')
parser.add_argument(
- '-c', '--channel', choices=['stable', 'nightly'], default='stable',
+ '-c', '--channel', default='stable',
help='Select update channel (default: %(default)s)')
+ parser.add_argument(
+ '-r', '--origin', default='local',
+ help='Select origin/repository (default: %(default)s)')
+ parser.add_argument(
+ '-s', '--suffix', default='',
+ help='Add an alphanumeric suffix to the package version, e.g. "dev"')
parser.add_argument(
'-o', '--output', default='yt_dlp/version.py',
help='The output file to write to (default: %(default)s)')
args.version if args.version and '.' in args.version
else get_new_version(None, args.version))
write_file(args.output, VERSION_TEMPLATE.format(
- version=version, git_head=git_head, channel=args.channel))
+ version=version, git_head=git_head, channel=args.channel, origin=args.origin,
+ package_version=f'{version}{args.suffix}'))
print(f'version={version} ({args.channel}), head={git_head}')