Python: Enable python3.12 support
cover Python: Enable python3.12 support
A few mostly trivial fixes, one backport from the qemu.qmp repo, and enabling the Python tests to run against Python3.12.
John Snow (4):
Python/iotests: Add type hint for nbd module python/qmp: remove Server.wait_closed() call for Python 3.12
configure: fix error message to say Python 3.8
Python: Enable python3.12 support
configure | 5 +++-- python/qemu/qmp/protocol.py | 1 - python/setup.cfg | 3 ++- tests/docker/dockerfiles/python.docker | 6 +++++- tests/qemu-iotests/tests/nbd-multiconn | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.41.0
PATCH 1/4 Python/iotests: Add type hint for nbd module
The test bails gracefully if this module isn't installed, but linters need a little help understanding that. It's enough to just declare the type in this case.
(Fixes pylint complaining about use of an uninitialized variable because it isn't wise enough to understand the notrun call is noreturn.)
--- tests/qemu-iotests/tests/nbd-multiconn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/qemu-iotests/tests/nbd-multiconn +3 -1
@@ -20,6 +20,8 @@ import os from contextlib import contextmanager +from types import ModuleType + import iotests from iotests import qemu_img_create, qemu_io
@@ -28,7 +30,7 @@ disk = os.path.join(iotests.test_dir, 'disk') size = '4M' nbd_sock = os.path.join(iotests.sock_dir, 'nbd_sock') nbd_uri = 'nbd+unix:///{}?socket=' + nbd_sock - +nbd: ModuleType @contextmanager def open_nbd(export_name):
Signature · 1 line
2.41.0
Re: [PATCH 1/4] Python/iotests: Add type hint for nbd module
Quoted 9 lines · John Snow
The test bails gracefully if this module isn't installed, but linters need a little help understanding that. It's enough to just declare the type in this case.
(Fixes pylint complaining about use of an uninitialized variable because it isn't wise enough to understand the notrun call is noreturn.)
Signed-off-by John Snow <[email protected]>Reviewed-by Eric Blake <[email protected]>
Signature · 2 lines
Best regards, Vladimir
PATCH 2/4 python/qmp: remove Server.wait_closed() call for Python 3.12
In reply to John SnowThis patch is a backport from
https://gitlab.com/qemu-project/python-qemu-qmp/-/commit/e03a3334b6a477beb09b293708632f2c06fe9f61
According to Guido in https://github.com/python/cpython/issues/104344 , this call was never meant to wait for the server to shut down - that is handled synchronously - but instead, this waits for all connections to close. Or, it would have, if it wasn't broken since it was introduced.
3.12 fixes the bug, which now causes a hang in our code. The fix is just to remove the wait.
--- python/qemu/qmp/protocol.py | 1 - 1 file changed, 1 deletion(-)
python/qemu/qmp/protocol.py +0 -1
@@ -495,7 +495,6 @@ async def _stop_server(self) -> None: try: self.logger.debug("Stopping server.") self._server.close() - await self._server.wait_closed() self.logger.debug("Server stopped.") finally: self._server = None
Signature · 1 line
2.41.0
Re: [PATCH 2/4] python/qmp: remove Server.wait_closed() call for Python 3.12
Quoted 8 lines · John Snow
This patch is a backport from
https://gitlab.com/qemu-project/python-qemu-qmp/-/commit/e03a3334b6a477beb09b293708632f2c06fe9f61According to Guido in https://github.com/python/cpython/issues/104344 , this call was never meant to wait for the server to shut down - that is handled synchronously - but instead, this waits for all connections to close. Or, it would have, if it wasn't broken since it was introduced.
Quoted 4 lines
3.12 fixes the bug, which now causes a hang in our code. The fix is just to remove the wait.
Signed-off-by John Snow <[email protected]>
Signature · 2 lines
Best regards, Vladimir
PATCH 3/4 configure: fix error message to say Python 3.8
In reply to John Snow--- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
configure +1 -1
@@ -944,7 +944,7 @@ then # If first_python is set, there was a binary somewhere even though # it was not suitable. Use it for the error message. if test -n "$first_python"; then - error_exit "Cannot use '$first_python', Python >= 3.7 is required." \ + error_exit "Cannot use '$first_python', Python >= 3.8 is required." \ "Use --python=/path/to/python to specify a supported Python." else error_exit "Python not found. Use --python=/path/to/python"
Signature · 1 line
2.41.0
Re: [PATCH 3/4] configure: fix error message to say Python 3.8
Quoted 1 line · John Snow
Signed-off-by John Snow <[email protected]>
Signature · 2 lines
Best regards, Vladimir
PATCH 4/4 Python: Enable python3.12 support
In reply to John SnowPython 3.12 has released, so update the test infrastructure to test against this version. Update the configure script to look for it when an explicit Python interpreter isn't chosen.
--- configure | 3 ++- python/setup.cfg | 3 ++- tests/docker/dockerfiles/python.docker | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-)
configure +2 -1
@@ -561,7 +561,8 @@ first_python= if test -z "${PYTHON}"; then # A bare 'python' is traditionally python 2.x, but some distros # have it as python 3.x, so check in both places. - for binary in python3 python python3.11 python3.10 python3.9 python3.8; do + for binary in python3 python python3.12 python3.11 \ + python3.10 python3.9 python3.8; do if has "$binary"; then python=$(command -v "$binary") if check_py_version "$python"; then
python/setup.cfg +2 -1
@@ -18,6 +18,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Typing :: Typed [options]
@@ -182,7 +183,7 @@ multi_line_output=3 # of python available on your system to run this test. [tox:tox] -envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 skip_missing_interpreters = true [testenv]
tests/docker/dockerfiles/python.docker +5 -1
@@ -11,7 +11,11 @@ ENV PACKAGES \ python3-pip \ python3-tox \ python3-virtualenv \ - python3.10 + python3.10 \ + python3.11 \ + python3.12 \ + python3.8 \ + python3.9 RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt
Signature · 1 line
2.41.0
Quoted 51 lines · John Snow
Python 3.12 has released, so update the test infrastructure to test against this version. Update the configure script to look for it when an explicit Python interpreter isn't chosen.
Signed-off-by John Snow <[email protected]>--- configure | 3 ++- python/setup.cfg | 3 ++- tests/docker/dockerfiles/python.docker | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-)configure +2
-1@@ -561,7 +561,8 @@ first_python= if test -z "${PYTHON}"; then # A bare 'python' is traditionally python 2.x, but some distros # have it as python 3.x, so check in both places. - for binary in python3 python python3.11 python3.10 python3.9 python3.8; do + for binary in python3 python python3.12 python3.11 \ + python3.10 python3.9 python3.8; do if has "$binary"; then python=$(command -v "$binary") if check_py_version "$python"; thenpython/setup.cfg +2
-1@@ -18,6 +18,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Typing :: Typed [options]@@ -182,7 +183,7 @@ multi_line_output=3 # of python available on your system to run this test. [tox:tox] -envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 skip_missing_interpreters = true [testenv]tests/docker/dockerfiles/python.docker +0
-0
tests/docker/dockerfiles/python.docker ENV PACKAGES \ · line 18
Quoted 9 lines
tests/docker/dockerfiles/python.docker +5
-1@@ -11,7 +11,11 @@ ENV PACKAGES \ python3-pip \ python3-tox \ python3-virtualenv \ - python3.10 + python3.10 \ + python3.11 \ + python3.12 \ + python3.8 \ + python3.9
Hmm, interesting, how did it work before? Only 3.10 was tested?
tests/docker/dockerfiles/python.docker ENV PACKAGES \ · line 21
Quoted 3 lines
tests/docker/dockerfiles/python.docker +0
-0RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txt
weak, I'm unsure about how this all works, I just see that 3.12 is added like others in all hunks except python.docker, but I think adding several python versions to docker should be safe anyway:
Signature · 2 lines
Best regards, Vladimir
Quoted 61 lines · Vladimir Sementsov-Ogievskiy
Quoted 48 lines · John Snow
Python 3.12 has released, so update the test infrastructure to test against this version. Update the configure script to look for it when an explicit Python interpreter isn't chosen.
Signed-off-by John Snow <[email protected]>---
configure | 3 ++- python/setup.cfg | 3 ++- tests/docker/dockerfiles/python.docker | 6 +++++-3 files changed, 9 insertions(+), 3 deletions(-)configure +0
-0@@ -561,7 +561,8 @@ first_python=if test -z "${PYTHON}"; then
# A bare 'python' is traditionally python 2.x, but some distros# have it as python 3.x, so check in both places. - for binary in python3 python python3.11 python3.10 python3.9 python3.8; do + for binary in python3 python python3.12 python3.11 \ + python3.10 python3.9 python3.8; do if has "$binary"; then python=$(command -v "$binary") if check_py_version "$python"; thenpython/setup.cfg +0
-0@@ -18,6 +18,7 @@ classifiers =Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
+ Programming Language :: Python :: 3.12
Typing :: Typed
[options]python/setup.cfg +0
-0@@ -182,7 +183,7 @@ multi_line_output=3 # of python available on your system to run this test.[tox:tox]
python/setup.cfg +1
-1-envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312
skip_missing_interpreters= true
[testenv]tests/docker/dockerfiles/python.docker +0
-0tests/docker/dockerfiles/python.docker ENV PACKAGES \ · line 18
Quoted 9 lines
tests/docker/dockerfiles/python.docker +5
-1@@ -11,7 +11,11 @@ ENV PACKAGES \ python3-pip \ python3-tox \ python3-virtualenv \ - python3.10 + python3.10 \ + python3.11 \ + python3.12 \ + python3.8 \ + python3.9Hmm, interesting, how did it work before? Only 3.10 was tested?
Quoted 6 lines
Quoted 2 lines
RUN dnf install -y $PACKAGES
RUN rpm -q $PACKAGES | sort > /packages.txtweak, I'm unsure about how this all works, I just see that 3.12 is added like others in all hunks except python.docker, but I think adding several python versions to docker should be safe anyway:
Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>
I meant, r-b is weak, not the patch :)
Signature · 2 lines
Best regards, Vladimir
Quoted 56 lines · Vladimir Sementsov-Ogievskiy
Quoted 54 lines · John Snow
Python 3.12 has released, so update the test infrastructure to test against this version. Update the configure script to look for it when an explicit Python interpreter isn't chosen.
Signed-off-by John Snow <[email protected]>--- configure | 3 ++- python/setup.cfg | 3 ++- tests/docker/dockerfiles/python.docker | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-)configure +2
-1@@ -561,7 +561,8 @@ first_python= if test -z "${PYTHON}"; then # A bare 'python' is traditionally python 2.x, but some distros # have it as python 3.x, so check in both places. - for binary in python3 python python3.11 python3.10 python3.9 python3.8; do + for binary in python3 python python3.12 python3.11 \ + python3.10 python3.9 python3.8; do if has "$binary"; then python=$(command -v "$binary") if check_py_version "$python"; thenpython/setup.cfg +2
-1@@ -18,6 +18,7 @@ classifiers = Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 Typing :: Typed [options]@@ -182,7 +183,7 @@ multi_line_output=3 # of python available on your system to run this test. [tox:tox] -envlist = py38, py39, py310, py311 +envlist = py38, py39, py310, py311, py312 skip_missing_interpreters = true [testenv]tests/docker/dockerfiles/python.docker +0
-0@@ -11,7 +11,11 @@ ENV PACKAGES \ python3-pip \ python3-tox \ python3-virtualenv \
Quoted 8 lines
tests/docker/dockerfiles/python.docker ENV PACKAGES \ · line 18
Quoted 6 lines
tests/docker/dockerfiles/python.docker +5
-1- python3.10 + python3.10 \ + python3.11 \ + python3.12 \ + python3.8 \ + python3.9Hmm, interesting, how did it work before? Only 3.10 was tested?
I was relying on dependencies to pull in other versions -- tox usually pulls in all but the very latest version. I made it explicit instead. I can explain this in the commit.
Quoted 7 lines
tests/docker/dockerfiles/python.docker ENV PACKAGES \ · line 21
Quoted 4 lines
tests/docker/dockerfiles/python.docker +0
-0RUN dnf install -y $PACKAGES RUN rpm -q $PACKAGES | sort > /packages.txtweak, I'm unsure about how this all works, I just see that 3.12 is added like others in all hunks except python.docker, but I think adding several python versions to docker should be safe anyway:
Reviewed-by Vladimir Sementsov-Ogievskiy <[email protected]>
Thanks -- and I see your patches for iotests. I'll try to look into them shortly.
Quoted 5 lines
--
Best regards,
Vladimir