Skip to content

Support building with py2 or py3

Daniel P. Berrange qemu-devel 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest14 patches 15 repliesIn review
  2. v413 patches 7 repliesSuperseded
  3. v313 patches 9 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v25 patches4 repliesSuperseded

Changes in v5 from the cover letter

- Fix broken rebase which accidentally squashed first two patches together
- Unset LC_ALL, and set LANG + LC_CTYPE, instead of only LANG (Eric)

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14qapi: convert to use python print function instead of statementscripts/qapi.py scripts/qapi2texi.py tests/qapi-schema/test-qapi.py+32 -300 replies
2/14qapi: use items()/values() intead of iteritems()/itervalues()scripts/qapi.py scripts/qapi2texi.py tests/qapi-schema/test-qapi.py+8 -80 replies
3/14qapi: Use OrderedDict from standard library if availablescripts/qapi.py+4 -10 replies
4/14qapi: adapt to moved location of StringIO module in py3scripts/qapi.py+5 -20 replies
5/14qapi: Adapt to moved location of 'maketrans' function in py3scripts/qapi.py+4 -10 replies
6/14qapi: remove '-q' arg to diff when comparing QAPI outputtests/Makefile.include+3 -33 replies
7/14qapi: ensure stable sort ordering when checking QAPI entitiesscripts/qapi.py+1 -10 replies
8/14qapi: force a UTF-8 locale for running PythonMakefile+12 -101 reply
9/14scripts: ensure signrom treats data as bytesscripts/signrom.py+2 -20 replies
10/14configure: allow use of python 3configure+2 -31 reply
11/14input: add missing JIS keys to virtio inputhw/input/virtio-input-hid.c qapi/ui.json ui/keycodemapdb+12 -24 replies
12/14ui: update keycodemapdb to get py3 fixesui/keycodemapdb+1 -11 reply
13/14travis: improve python version test coverage.travis.yml+9 -54 replies
14/14docker: change Fedora images to run with python3tests/docker/dockerfiles/fedora.docker+2 -10 replies

Reviews trailers per patch

12 of 14 patches have a Reviewed-by or Acked-by.

PatchPhilippe Mathieu-DaudéEric Blake
1/14R-b
2/14R-b
3/14R-b
4/14R-b
5/14R-b
6/14R-b
7/14R-b
8/14R-b
9/14R-b
10/14R-b
11/14R-b
12/14R-b
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v5 thread

Cover letter [Qemu-devel] [PATCH v5 00/14] Support building with py2 or py3

This is an update for my previously posted series:

v2: https://lists.gnu.org/archive/html/qemu-devel/2017-08/msg06528.html
v3: https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg02978.html
v4: https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg03150.html

This series enables some level of CI testing for py3 so that our CI jobs will get coverage of both py2 and py3 builds to avoid bitrot.

I did a test travis build with py 3.0 and py 3.6 and got success:

https://travis-ci.org/berrange/qemu/builds/328223261

The goal was to achieve the following

  ./configure --python=/usr/bin/python3
  make
  make check

This still requires passing python path to configure explicitly. A further improvement would be for configure to automatically detect a pythjon 3 binary and use it preferentially to python 2.

I have not attempted to fix/validate the block I/O tests. I would expect them to be broken, but easily fixable with the similar kind of scope changes as seen here. I felt it better to tackle that separately to avoid this initial series getting too large.

Although the Python 2 EOL date is 2020, we already have distros which are not shipping Python 2 by default (Fedora >= 26 has dropped Py2 from the default install). Any new releases of long life and/or enterprise distros may well not ship Python 2 given that it would go EOL long before the EOL of the distro itself. IOW QEMU does have a fairly pressing need to be able to support Python 3 for building.

A request for py3 is tracked here:

https://bugs.launchpad.net/qemu/+bug/1708462

If, rather than supporting py2+py3 in parallel, we wish to entirely drop py2 support, this series would not change significantly

- The "from __future__ import print_function" line can be removed from patch 1.
- The code in patches 2, 3, 4 to deal with changed module names for a few functions can be simpified to only try the py3 location
- The travis + docker jobs would be fully updated to install py3, or delete jobs which can't support py3

Given how little code is removed should we drop py2 support, I don't believe it is in our immediate interests to do this. It would create extra pain for consumers of QEMU, with little benefit to QEMU code maintainance. The key thing is ensuring our travis+docker jobs provide satisfactory automated test coverage for the variety of python versions in the distros we care about targetting.

NB, Patch 11 here is not related to python 3 work - it was just a temporary pre-requisite of pulling in the keycodemapdb update.

Changes since v4:

- Fix broken rebase which accidentally squashed first two patches together
- Unset LC_ALL, and set LANG + LC_CTYPE, instead of only LANG (Eric)

Changes since v3:

- Remove space before '(' in print() function calls (Phillippe)
- Force use of en_US.UTF-8 for QAPI code generation (Patchew)

Changes since v2:

- Pull in fix for keycodemapdb
- Enable testing with Travis
- Enable testing with Fedora Docker images
- Fix for sort ordering to fix 'make check-qapi-schema'
- Fix for signrom data

Daniel P. Berrange (13):
qapi: convert to use python print function instead of statement
qapi: use items()/values() intead of iteritems()/itervalues()
qapi: Use OrderedDict from standard library if available
qapi: adapt to moved location of StringIO module in py3
qapi: Adapt to moved location of 'maketrans' function in py3
qapi: remove '-q' arg to diff when comparing QAPI output
qapi: ensure stable sort ordering when checking QAPI entities
qapi: force a UTF-8 locale for running Python
scripts: ensure signrom treats data as bytes
configure: allow use of python 3
ui: update keycodemapdb to get py3 fixes
travis: improve python version test coverage
docker: change Fedora images to run with python3

Miika S (1):
input: add missing JIS keys to virtio input

 .travis.yml                            | 14 +++++++----
 Makefile                               | 22 +++++++++--------
 configure                              |  5 ++--
 hw/input/virtio-input-hid.c            |  7 ++++++
 qapi/ui.json                           |  5 +++-
 scripts/qapi.py                        | 43 ++++++++++++++++++++--------------
 scripts/qapi2texi.py                   | 11 +++++----
 scripts/signrom.py                     |  4 ++--
 tests/Makefile.include                 |  6 ++---
 tests/docker/dockerfiles/fedora.docker |  3 ++-
 tests/qapi-schema/test-qapi.py         | 43 +++++++++++++++++-----------------
 ui/keycodemapdb                        |  2 +-
 12 files changed, 96 insertions(+), 69 deletions(-)
Signature · 1 line
2.14.3