master
py 78 lines 1.87 KB
Raw
1 #!/usr/bin/env python3
2 """
3 vendor - QEMU python vendoring utility
4
5 usage: vendor [-h]
6
7 QEMU python vendoring utility
8
9 options:
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
21 import argparse
22 import os
23 from pathlib import Path
24 import subprocess
25 import sys
26 import tempfile
27
28
29 def 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 = {
44 "meson==1.12.0":
45 "71f133147fa0fcfe8f4df49fa1045771064947834538409e5d97b3613aac8b4e",
46 "qemu.qmp==0.0.6":
47 "5d7c5af0e9de427696e3bf72e333965c3a697929f77f6b7ddc30c989fc7b539b",
48 "pycotap==1.3.1":
49 "1c3a25b3ff89e48f4e00f1f71dbbc1642b4f65c65d416524d07e73492fff25ea",
50 }
51
52 vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
53
54 with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file:
55 for dep_spec, checksum in packages.items():
56 print(f"{dep_spec} --hash=sha256:{checksum}", file=file)
57 file.flush()
58
59 cli_args = [
60 "pip",
61 "download",
62 "--dest",
63 str(vendor_dir),
64 "--require-hashes",
65 "-r",
66 file.name,
67 ]
68 if loud:
69 cli_args.append("-v")
70
71 print(" ".join(cli_args))
72 subprocess.run(cli_args, check=True)
73
74 return 0
75
76
77 if __name__ == "__main__":
78 sys.exit(main())