[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/27] python: add vendor.py utility
From: |
Paolo Bonzini |
Subject: |
[PATCH v2 15/27] python: add vendor.py utility |
Date: |
Tue, 16 May 2023 12:58:56 +0200 |
From: John Snow <jsnow@redhat.com>
This is a teeny-tiny script that just downloads any packages we want to
vendor from PyPI and stores them in qemu.git/python/wheels/. If I'm hit
by a meteor, it'll be easy to replicate what I have done in order to
udpate the vendored source.
We don't really care which python runs it; it exists as a meta-utility
with no external dependencies and we won't package or install it. It
will be monitored by the linters/type checkers, though; so it's
guaranteed safe on python 3.6+.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-Id: <20230511035435.734312-15-jsnow@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
python/scripts/vendor.py | 74 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100755 python/scripts/vendor.py
diff --git a/python/scripts/vendor.py b/python/scripts/vendor.py
new file mode 100755
index 000000000000..23708430ea68
--- /dev/null
+++ b/python/scripts/vendor.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python3
+"""
+vendor - QEMU python vendoring utility
+
+usage: vendor [-h]
+
+QEMU python vendoring utility
+
+options:
+ -h, --help show this help message and exit
+"""
+
+# Copyright (C) 2023 Red Hat, Inc.
+#
+# Authors:
+# John Snow <jsnow@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import argparse
+import os
+from pathlib import Path
+import subprocess
+import sys
+import tempfile
+
+
+def main() -> int:
+ """Run the vendoring utility. See module-level docstring."""
+ loud = False
+ if os.environ.get("DEBUG") or os.environ.get("V"):
+ loud = True
+
+ # No options or anything for now, but I guess
+ # you'll figure that out when you run --help.
+ parser = argparse.ArgumentParser(
+ prog="vendor",
+ description="QEMU python vendoring utility",
+ )
+ parser.parse_args()
+
+ packages = {
+ "meson==0.61.5":
+ "58c2ddb5f885da0e929f15d89f38d8a7d97f981f56815bcba008414f8511f59a",
+ }
+
+ vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
+
+ with tempfile.NamedTemporaryFile(mode="w", encoding="utf-8") as file:
+ for dep_spec, checksum in packages.items():
+ file.write(f"{dep_spec} --hash=sha256:{checksum}")
+ file.flush()
+
+ cli_args = [
+ "pip",
+ "download",
+ "--dest",
+ str(vendor_dir),
+ "--require-hashes",
+ "-r",
+ file.name,
+ ]
+ if loud:
+ cli_args.append("-v")
+
+ print(" ".join(cli_args))
+ subprocess.run(cli_args, check=True)
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
--
2.40.1
- [PATCH v2 06/27] mkvenv: add ensure subcommand, (continued)
- [PATCH v2 06/27] mkvenv: add ensure subcommand, Paolo Bonzini, 2023/05/16
- [PATCH v2 05/27] mkvenv: add nested venv workaround, Paolo Bonzini, 2023/05/16
- [PATCH v2 04/27] mkvenv: add better error message for broken or missing ensurepip, Paolo Bonzini, 2023/05/16
- [PATCH v2 02/27] python: update pylint configuration, Paolo Bonzini, 2023/05/16
- [PATCH v2 07/27] mkvenv: add --diagnose option to explain "ensure" failures, Paolo Bonzini, 2023/05/16
- [PATCH v2 13/27] tests/vm: Configure netbsd to use Python 3.10, Paolo Bonzini, 2023/05/16
- [PATCH v2 08/27] mkvenv: add console script entry point generation, Paolo Bonzini, 2023/05/16
- [PATCH v2 15/27] python: add vendor.py utility,
Paolo Bonzini <=
- [PATCH v2 20/27] tests: Use configure-provided pyvenv for tests, Paolo Bonzini, 2023/05/16
- [PATCH v2 11/27] mkvenv: work around broken pip installations on Debian 10, Paolo Bonzini, 2023/05/16
- [PATCH v2 19/27] qemu.git: drop meson git submodule, Paolo Bonzini, 2023/05/16
- [PATCH v2 23/27] configure: add --enable-pypi and --disable-pypi, Paolo Bonzini, 2023/05/16
- [PATCH v2 16/27] configure: create a python venv unconditionally, Paolo Bonzini, 2023/05/16
- [PATCH v2 12/27] tests/docker: add python3-venv dependency, Paolo Bonzini, 2023/05/16
- [PATCH v2 14/27] tests/vm: add py310-expat to NetBSD, Paolo Bonzini, 2023/05/16
- [PATCH v2 18/27] configure: use 'mkvenv ensure meson' to bootstrap meson, Paolo Bonzini, 2023/05/16