diff --git a/scripts/release/homebrew/docker/formula_generate.py b/scripts/release/homebrew/docker/formula_generate.py index d44094ad052..ad26b932754 100644 --- a/scripts/release/homebrew/docker/formula_generate.py +++ b/scripts/release/homebrew/docker/formula_generate.py @@ -15,10 +15,10 @@ import bisect import argparse -TEMPLATE_FILE_NAME='formula_template.txt' -CLI_VERSION=os.environ['CLI_VERSION'] -HOMEBREW_UPSTREAM_URL=os.environ['HOMEBREW_UPSTREAM_URL'] -HOMEBREW_FORMULAR_LATEST="https://raw.githubusercontent.com/Homebrew/homebrew-core/c882489d4cb39ca004387f0c5ef1a767046c68d6/Formula/azure-cli.rb" +TEMPLATE_FILE_NAME = 'formula_template.txt' +CLI_VERSION = os.environ['CLI_VERSION'] +HOMEBREW_UPSTREAM_URL = os.environ['HOMEBREW_UPSTREAM_URL'] +HOMEBREW_FORMULAR_LATEST = "https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/a/azure-cli.rb" def main(): @@ -26,10 +26,12 @@ def main(): parser = argparse.ArgumentParser(prog='formula_generator.py') parser.set_defaults(func=generate_formula) - parser.add_argument('-b', dest='build_method', choices=['update_existing', 'use_template'], help='The build method, default is update_existing, the other option is use_template.') + parser.add_argument('-b', dest='build_method', choices=['update_existing', 'use_template'], + help='The build method, default is update_existing, the other option is use_template.') args = parser.parse_args() args.func(**vars(args)) + def generate_formula(build_method: str, **_): content = '' if build_method is None or build_method == 'update_existing': @@ -82,7 +84,8 @@ def collect_resources() -> str: def collect_resources_dict() -> dict: nodes = make_graph('azure-cli') - filtered_nodes = {nodes[node_name]['name']: nodes[node_name] for node_name in sorted(nodes) if resource_filter(node_name)} + filtered_nodes = {nodes[node_name]['name']: nodes[node_name] for node_name in sorted(nodes) if + resource_filter(node_name)} return filtered_nodes @@ -126,11 +129,6 @@ def update_formula() -> str: upstream_sha = compute_sha256(HOMEBREW_UPSTREAM_URL) text = re.sub('sha256 ".*"', 'sha256 "{}"'.format(upstream_sha), text, 1) text = re.sub('.*revision.*\n', '', text, 1) # remove revision for previous version if exists - - # include pip when creating venv, see https://github.com/Homebrew/brew/pull/15792 - # this can be removed after Homebrew merges our PR - text = re.sub('system_site_packages: false', 'system_site_packages: false, without_pip: false', text, 1) - pack = None packs_to_remove = set() lines = text.split('\n') @@ -153,7 +151,7 @@ def update_formula() -> str: node_index_dict[pack] = idx elif pack is not None: if line.startswith(" url"): - #update the url of package + # update the url of package if pack in nodes.keys(): url_match = re.search(r'url "(.*)"', line) if url_match is not None and nodes[pack]['url'] != url_match.group(1): @@ -162,7 +160,7 @@ def update_formula() -> str: else: packs_to_remove.add(pack) elif line.startswith(" sha256"): - #update the sha256 of package + # update the sha256 of package if pack in nodes.keys(): lines[idx] = re.sub('sha256 ".*"', 'sha256 "{}"'.format(nodes[pack]['checksum']), line, 1) del nodes[pack]