blob: 762748711702f486dfdbbd35e160c8358eac33c3 [file] [log] [blame]
John Snow22748172023-05-10 23:54:22 -04001#!/usr/bin/env python3
2"""
3vendor - QEMU python vendoring utility
4
5usage: vendor [-h]
6
7QEMU python vendoring utility
8
9options:
10 -h, --help show this help message and exit
11"""
12
13# Copyright (C) 2023 Red Hat, Inc.
14#
15# Authors:
16# John Snow <jsnow@redhat.com>
17#
18# This work is licensed under the terms of the GNU GPL, version 2 or
19# later. See the COPYING file in the top-level directory.
20
21import argparse
22import os
23from pathlib import Path
24import subprocess
25import sys
26import tempfile
27
28
29def main() -> int:
30 """Run the vendoring utility. See module-level docstring."""
31 loud = False
32 if os.environ.get("DEBUG") or os.environ.get("V"):
33 loud = True
34
35 # No options or anything for now, but I guess
36 # you'll figure that out when you run --help.
37 parser = argparse.ArgumentParser(
38 prog="vendor",
39 description="QEMU python vendoring utility",
40 )
41 parser.parse_args()
42
43 packages = {
Paolo Bonzini3b087f72021-12-23 15:29:56 +010044 "meson==0.63.3":
45 "d677b809c4895dcbaac9bf6c43703fcb3609a4b24c6057c78f828590049cf43a",
Paolo Bonziniedc21072023-08-08 20:19:43 +020046
47 "tomli==2.0.1":
48 "939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",
John Snow22748172023-05-10 23:54:22 -040049 }
50
51 vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
52
53 with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file:
54 for dep_spec, checksum in packages.items():
Paolo Bonziniedc21072023-08-08 20:19:43 +020055 print(f"{dep_spec} --hash=sha256:{checksum}", file=file)
John Snow22748172023-05-10 23:54:22 -040056 file.flush()
57
58 cli_args = [
59 "pip",
60 "download",
61 "--dest",
62 str(vendor_dir),
63 "--require-hashes",
64 "-r",
65 file.name,
66 ]
67 if loud:
68 cli_args.append("-v")
69
70 print(" ".join(cli_args))
71 subprocess.run(cli_args, check=True)
72
73 return 0
74
75
76if __name__ == "__main__":
77 sys.exit(main())