Debian Codegraph @

infra/bots/assets/go_win/create.py

raw
1 #!/usr/bin/env python
2 #
3 # Copyright 2019 Google Inc.
4 #
5 # Use of this source code is governed by a BSD-style license that can be
6 # found in the LICENSE file.
7
8
9 """Create the asset."""
10
11
12 import argparse
13 import os
14 import subprocess
15 import sys
16
17 FILE_DIR = os.path.dirname(os.path.abspath(__file__))
18 INFRA_BOTS_DIR = os.path.realpath(os.path.join(FILE_DIR, os.pardir, os.pardir))
19 sys.path.insert(0, INFRA_BOTS_DIR)
20 import utils
21
22
23 # Remember to also update the go asset when this is updated.
24 GO_URL = "https://go.dev/dl/go1.24.0.windows-amd64.zip"
25
26
27 def create_asset(target_dir):
28 """Create the asset."""
29 with utils.tmp_dir():
30 cwd = os.getcwd()
31 zipfile = os.path.join(cwd, 'go.zip')
32 subprocess.check_call(["wget", '-O', zipfile, GO_URL])
33 subprocess.check_call(["unzip", zipfile, "-d", target_dir])
34
35
36 def main():
37 parser = argparse.ArgumentParser()
38 parser.add_argument('--target_dir', '-t', required=True)
39 args = parser.parse_args()
40 create_asset(args.target_dir)
41
42
43 if __name__ == '__main__':
44 main()