[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp
From: |
John Snow |
Subject: |
[RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp |
Date: |
Thu, 16 Dec 2021 21:29:36 -0500 |
qemu.qmp can be found via the package index now. Direct the user to just
install the package. When utilities from 'qemu' are needed, direct the
user to install the package from that directory instead, which will pull
in the 'qemu.qmp' package as a dependency.
Signed-off-by: John Snow <jsnow@redhat.com>
---
scripts/device-crash-test | 11 ++++++++---
scripts/render_block_graph.py | 13 ++++++++++---
scripts/simplebench/bench_block_job.py | 11 ++++++++---
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/scripts/device-crash-test b/scripts/device-crash-test
index 4bfc68c008..5d21b6dfb1 100755
--- a/scripts/device-crash-test
+++ b/scripts/device-crash-test
@@ -34,9 +34,14 @@ import random
import argparse
from itertools import chain
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
-from qemu.machine import QEMUMachine
-from qemu.qmp import ConnectError
+try:
+ from qemu.machine import QEMUMachine
+ from qemu.qmp import ConnectError
+except ModuleNotFoundError:
+ target = os.path.realpath(__file__ + '/../../python')
+ print("script dependencies not found.")
+ print(f'try: pushd "{target}" && pip3 install [--user] . && popd')
+ sys.exit(1)
logger = logging.getLogger('device-crash-test')
dbg = logger.debug
diff --git a/scripts/render_block_graph.py b/scripts/render_block_graph.py
index 26f43fef27..e7b89314ff 100755
--- a/scripts/render_block_graph.py
+++ b/scripts/render_block_graph.py
@@ -24,9 +24,16 @@
import json
from graphviz import Digraph
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python'))
-from qemu.qmp import QMPError
-from qemu.qmp.legacy import QEMUMonitorProtocol
+try:
+ from qemu.qmp import QMPError
+ from qemu.qmp.legacy import QEMUMonitorProtocol
+except ModuleNotFoundError:
+ print(
+ "qemu.qmp python package not found.",
+ "try: pip3 install [--user] qemu.qmp",
+ sep='\n', file=sys.stderr
+ )
+ sys.exit(1)
def perm(arr):
diff --git a/scripts/simplebench/bench_block_job.py
b/scripts/simplebench/bench_block_job.py
index 56191db44b..ccb2f9ded1 100755
--- a/scripts/simplebench/bench_block_job.py
+++ b/scripts/simplebench/bench_block_job.py
@@ -25,9 +25,14 @@
import socket
import json
-sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python'))
-from qemu.machine import QEMUMachine
-from qemu.qmp import ConnectError
+try:
+ from qemu.machine import QEMUMachine
+ from qemu.qmp import ConnectError
+except ModuleNotFoundError:
+ target = os.path.realpath(__file__ + '/../../../python')
+ print("script dependencies not found.")
+ print(f'try: pushd "{target}" && pip3 install [--user] . && popd')
+ sys.exit(1)
def bench_block_job(cmd, cmd_args, qemu_args):
--
2.31.1
- [RFC PATCH 0/9] Python: Switch to externally hosted qemu.qmp dependency, John Snow, 2021/12/16
- [RFC PATCH 1/9] Python: Update mypy dependency to >= 0.780, John Snow, 2021/12/16
- [RFC PATCH 5/9] scripts/qmp: delete qmp.py script stub, John Snow, 2021/12/16
- [RFC PATCH 2/9] Python: update isort dependency, John Snow, 2021/12/16
- [RFC PATCH 4/9] scripts/qmp: update remaining forwarder stubs, John Snow, 2021/12/16
- [RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub, John Snow, 2021/12/16
- [RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp,
John Snow <=
- [RFC PATCH 7/9] iotests/testenv: initialize an iotests venv, John Snow, 2021/12/16
- [RFC PATCH 9/9] (WIP) Python: update Pipfile, John Snow, 2021/12/16
- [RFC PATCH 8/9] Python: delete qemu.qmp, John Snow, 2021/12/16