From: John Snow <jsnow@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, Cleber Rosa <crosa@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: [RFC PATCH 6/9] scripts: remove sys.path hacks for qemu/qemu.qmp
Date: Thu, 16 Dec 2021 21:29:36 -0500 [thread overview]
Message-ID: <20211217022939.279559-7-jsnow@redhat.com> (raw)
In-Reply-To: <20211217022939.279559-1-jsnow@redhat.com>
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
next prev parent reply other threads:[~2021-12-17 2:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-17 2:29 [RFC PATCH 0/9] Python: Switch to externally hosted qemu.qmp dependency John Snow
2021-12-17 2:29 ` [RFC PATCH 1/9] Python: Update mypy dependency to >= 0.780 John Snow
2021-12-17 2:29 ` [RFC PATCH 2/9] Python: update isort dependency John Snow
2021-12-17 2:29 ` [RFC PATCH 3/9] scripts/qmp: Update 'qmp-shell' forwarder stub John Snow
2021-12-17 2:29 ` [RFC PATCH 4/9] scripts/qmp: update remaining forwarder stubs John Snow
2021-12-17 2:29 ` [RFC PATCH 5/9] scripts/qmp: delete qmp.py script stub John Snow
2021-12-17 2:29 ` John Snow [this message]
2021-12-17 2:29 ` [RFC PATCH 7/9] iotests/testenv: initialize an iotests venv John Snow
2021-12-17 2:29 ` [RFC PATCH 8/9] Python: delete qemu.qmp John Snow
2021-12-17 2:29 ` [RFC PATCH 9/9] (WIP) Python: update Pipfile John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211217022939.279559-7-jsnow@redhat.com \
--to=jsnow@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=eduardo@habkost.net \
--cc=hreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).