12274817fSJohn Snow#!/usr/bin/env python3 22274817fSJohn Snow""" 32274817fSJohn Snowvendor - QEMU python vendoring utility 42274817fSJohn Snow 52274817fSJohn Snowusage: vendor [-h] 62274817fSJohn Snow 72274817fSJohn SnowQEMU python vendoring utility 82274817fSJohn Snow 92274817fSJohn Snowoptions: 102274817fSJohn Snow -h, --help show this help message and exit 112274817fSJohn Snow""" 122274817fSJohn Snow 132274817fSJohn Snow# Copyright (C) 2023 Red Hat, Inc. 142274817fSJohn Snow# 152274817fSJohn Snow# Authors: 162274817fSJohn Snow# John Snow <jsnow@redhat.com> 172274817fSJohn Snow# 182274817fSJohn Snow# This work is licensed under the terms of the GNU GPL, version 2 or 192274817fSJohn Snow# later. See the COPYING file in the top-level directory. 202274817fSJohn Snow 212274817fSJohn Snowimport argparse 222274817fSJohn Snowimport os 232274817fSJohn Snowfrom pathlib import Path 242274817fSJohn Snowimport subprocess 252274817fSJohn Snowimport sys 262274817fSJohn Snowimport tempfile 272274817fSJohn Snow 282274817fSJohn Snow 292274817fSJohn Snowdef main() -> int: 302274817fSJohn Snow """Run the vendoring utility. See module-level docstring.""" 312274817fSJohn Snow loud = False 322274817fSJohn Snow if os.environ.get("DEBUG") or os.environ.get("V"): 332274817fSJohn Snow loud = True 342274817fSJohn Snow 352274817fSJohn Snow # No options or anything for now, but I guess 362274817fSJohn Snow # you'll figure that out when you run --help. 372274817fSJohn Snow parser = argparse.ArgumentParser( 382274817fSJohn Snow prog="vendor", 392274817fSJohn Snow description="QEMU python vendoring utility", 402274817fSJohn Snow ) 412274817fSJohn Snow parser.parse_args() 422274817fSJohn Snow 432274817fSJohn Snow packages = { 44*07f0d326SPaolo Bonzini "meson==1.5.0": 45*07f0d326SPaolo Bonzini "52b34f4903b882df52ad0d533146d4b992c018ea77399f825579737672ae7b20", 462274817fSJohn Snow } 472274817fSJohn Snow 482274817fSJohn Snow vendor_dir = Path(__file__, "..", "..", "wheels").resolve() 492274817fSJohn Snow 502274817fSJohn Snow with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file: 512274817fSJohn Snow for dep_spec, checksum in packages.items(): 52edc21078SPaolo Bonzini print(f"{dep_spec} --hash=sha256:{checksum}", file=file) 532274817fSJohn Snow file.flush() 542274817fSJohn Snow 552274817fSJohn Snow cli_args = [ 562274817fSJohn Snow "pip", 572274817fSJohn Snow "download", 582274817fSJohn Snow "--dest", 592274817fSJohn Snow str(vendor_dir), 602274817fSJohn Snow "--require-hashes", 612274817fSJohn Snow "-r", 622274817fSJohn Snow file.name, 632274817fSJohn Snow ] 642274817fSJohn Snow if loud: 652274817fSJohn Snow cli_args.append("-v") 662274817fSJohn Snow 672274817fSJohn Snow print(" ".join(cli_args)) 682274817fSJohn Snow subprocess.run(cli_args, check=True) 692274817fSJohn Snow 702274817fSJohn Snow return 0 712274817fSJohn Snow 722274817fSJohn Snow 732274817fSJohn Snowif __name__ == "__main__": 742274817fSJohn Snow sys.exit(main()) 75