[Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility

Stefan Hajnoczi posted 3 patches 6 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20170825155732.15665-1-stefanha@redhat.com
Test FreeBSD passed
Test checkpatch failed
Test docker passed
Test s390x passed
COPYING.PYTHON                     |  270 ++++
scripts/argparse.py                | 2406 ++++++++++++++++++++++++++++++++++++
tests/docker/docker.py             |    4 +-
tests/migration/guestperf/shell.py |    8 +-
4 files changed, 2684 insertions(+), 4 deletions(-)
create mode 100644 COPYING.PYTHON
create mode 100644 scripts/argparse.py
[Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Stefan Hajnoczi 6 years, 8 months ago
Many scripts can benefit from the standard library argparse module, which has
improvements over the older optparse module.  Unfortunately argparse was only
shipped in Python 2.7 so we need a fallback for Python 2.6.

This patch series adds a copy of argparse.py and updates scripts as necessary
to import it.

Stefan Hajnoczi (3):
  scripts: add argparse module for Python 2.6 compatibility
  docker.py: Python 2.6 argparse compatibility
  tests: migration/guestperf Python 2.6 argparse compatibility

 COPYING.PYTHON                     |  270 ++++
 scripts/argparse.py                | 2406 ++++++++++++++++++++++++++++++++++++
 tests/docker/docker.py             |    4 +-
 tests/migration/guestperf/shell.py |    8 +-
 4 files changed, 2684 insertions(+), 4 deletions(-)
 create mode 100644 COPYING.PYTHON
 create mode 100644 scripts/argparse.py

-- 
2.13.5


Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by no-reply@patchew.org 6 years, 8 months ago
Hi,

This series seems to have some coding style problems. See output below for
more information:

Type: series
Message-id: 20170825155732.15665-1-stefanha@redhat.com
Subject: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
b0f75bbee1 tests: migration/guestperf Python 2.6 argparse compatibility
a0976d88ae docker.py: Python 2.6 argparse compatibility
3f9dfc445a scripts: add argparse module for Python 2.6 compatibility

=== OUTPUT BEGIN ===
Checking PATCH 1/3: scripts: add argparse module for Python 2.6 compatibility...
ERROR: trailing whitespace
#115: FILE: COPYING.PYTHON:93:
+Reserved" are retained in Python alone or in any derivative version $

total: 1 errors, 0 warnings, 2676 lines checked

Your patch has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

Checking PATCH 2/3: docker.py: Python 2.6 argparse compatibility...
Checking PATCH 3/3: tests: migration/guestperf Python 2.6 argparse compatibility...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org
Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Stefan Hajnoczi 6 years, 7 months ago
On Fri, Aug 25, 2017 at 09:24:36AM -0700, no-reply@patchew.org wrote:
> === OUTPUT BEGIN ===
> Checking PATCH 1/3: scripts: add argparse module for Python 2.6 compatibility...
> ERROR: trailing whitespace
> #115: FILE: COPYING.PYTHON:93:
> +Reserved" are retained in Python alone or in any derivative version $
> 
> total: 1 errors, 0 warnings, 2676 lines checked

I'm not going to modify the Python Software Foundation License text for
the sake of checkpatch.pl.  Let's keep it verbatim.

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Philippe Mathieu-Daudé 6 years, 8 months ago
Hi Stefan,

On 08/25/2017 12:57 PM, Stefan Hajnoczi wrote:
> Many scripts can benefit from the standard library argparse module, which has
> improvements over the older optparse module.  Unfortunately argparse was only
> shipped in Python 2.7 so we need a fallback for Python 2.6.

I probably missed some discussion about it, but what are the reasons to 
stay 2.6 compatible?

Python 2.6 support ended during October 2013, 4 years ago... [1] Why 
don't kill it, start deprecating 2.7 which support will end in less than 
3 years from now [2], and move efforts to version 3...?

Apparently we expect a C compiler compatible with GCC >= 4.1 which was 
released on 2006, before Python 2.5 :S
Then QEMU_BUILD_BUG_ON() try to use C11 feature...

[1] https://www.python.org/dev/peps/pep-0361/ and
https://mail.python.org/pipermail/python-dev/2013-September/128287.html
[2] https://www.python.org/dev/peps/pep-0373/ and
https://pythonclock.org/

Regards,

Phil.

> 
> This patch series adds a copy of argparse.py and updates scripts as necessary
> to import it.
> 
> Stefan Hajnoczi (3):
>    scripts: add argparse module for Python 2.6 compatibility
>    docker.py: Python 2.6 argparse compatibility
>    tests: migration/guestperf Python 2.6 argparse compatibility
> 
>   COPYING.PYTHON                     |  270 ++++
>   scripts/argparse.py                | 2406 ++++++++++++++++++++++++++++++++++++
>   tests/docker/docker.py             |    4 +-
>   tests/migration/guestperf/shell.py |    8 +-
>   4 files changed, 2684 insertions(+), 4 deletions(-)
>   create mode 100644 COPYING.PYTHON
>   create mode 100644 scripts/argparse.py
> 

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Peter Maydell 6 years, 8 months ago
On 25 August 2017 at 17:35, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
> Hi Stefan,
>
> On 08/25/2017 12:57 PM, Stefan Hajnoczi wrote:
>>
>> Many scripts can benefit from the standard library argparse module, which
>> has
>> improvements over the older optparse module.  Unfortunately argparse was
>> only
>> shipped in Python 2.7 so we need a fallback for Python 2.6.
>
>
> I probably missed some discussion about it, but what are the reasons to stay
> 2.6 compatible?
>
> Python 2.6 support ended during October 2013, 4 years ago... [1] Why don't
> kill it, start deprecating 2.7 which support will end in less than 3 years
> from now [2], and move efforts to version 3...?

Our choices about our dependencies are generally driven by "what
are the versions available on the oldest distros which we wish
to support building QEMU on", which typically is whatever the
long-term-support versions of Ubuntu, SUSE, Redhat, etc are.

Has somebody checked what that means for our Python version
requirements? (It would certainly be nicer if we could get away
with bumping the version-req rather than including a big lump
of code with yet-another-software-license, but maybe we can't.)

> Apparently we expect a C compiler compatible with GCC >= 4.1 which was
> released on 2006, before Python 2.5 :S
> Then QEMU_BUILD_BUG_ON() try to use C11 feature...

That's protected by a configure check for exactly this reason.

thanks
-- PMM

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Eric Blake 6 years, 8 months ago
On 08/25/2017 11:40 AM, Peter Maydell wrote:
> Our choices about our dependencies are generally driven by "what
> are the versions available on the oldest distros which we wish
> to support building QEMU on", which typically is whatever the
> long-term-support versions of Ubuntu, SUSE, Redhat, etc are.
> 
> Has somebody checked what that means for our Python version
> requirements?

At least this one:

RHEL/CentOS 6: Python-2.6.6

> (It would certainly be nicer if we could get away
> with bumping the version-req rather than including a big lump
> of code with yet-another-software-license, but maybe we can't.)

Based on the above, no sooner than when Red Hat is done supporting RHEL
6 (well, upstream can always decide to bump the minimum requirements it
and make Red Hat do the downstream back-compat work in isolation, but
there's enough Red Hat contributors that it shouldn't surprise anyone
that back-compat work patches will still be posted upstream...)

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Stefan Hajnoczi 6 years, 7 months ago
On Fri, Aug 25, 2017 at 12:42:44PM -0500, Eric Blake wrote:
> On 08/25/2017 11:40 AM, Peter Maydell wrote:
> > Our choices about our dependencies are generally driven by "what
> > are the versions available on the oldest distros which we wish
> > to support building QEMU on", which typically is whatever the
> > long-term-support versions of Ubuntu, SUSE, Redhat, etc are.
> > 
> > Has somebody checked what that means for our Python version
> > requirements?
> 
> At least this one:
> 
> RHEL/CentOS 6: Python-2.6.6

Thanks for checking this.

Stefan

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Philippe Mathieu-Daudé 6 years, 7 months ago
On 08/29/2017 07:01 AM, Stefan Hajnoczi wrote:
> On Fri, Aug 25, 2017 at 12:42:44PM -0500, Eric Blake wrote:
>> On 08/25/2017 11:40 AM, Peter Maydell wrote:
>>> Our choices about our dependencies are generally driven by "what
>>> are the versions available on the oldest distros which we wish
>>> to support building QEMU on", which typically is whatever the
>>> long-term-support versions of Ubuntu, SUSE, Redhat, etc are.
>>>
>>> Has somebody checked what that means for our Python version
>>> requirements?
>>
>> At least this one:
>>
>> RHEL/CentOS 6: Python-2.6.6

$ docker run --rm qemu:centos6 yum -q list python
Installed Packages
python.x86_64                     2.6.6-66.el6_8 
@CentOS/6.9

Good news, we have a docker image using Python2.6

Do you have some migration/guestperf test we can add to the testsuite?

Regards,

Phil.

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by John Snow 6 years, 7 months ago

On 08/25/2017 11:57 AM, Stefan Hajnoczi wrote:
> Many scripts can benefit from the standard library argparse module, which has
> improvements over the older optparse module.  Unfortunately argparse was only
> shipped in Python 2.7 so we need a fallback for Python 2.6.
> 
> This patch series adds a copy of argparse.py and updates scripts as necessary
> to import it.
> 
> Stefan Hajnoczi (3):
>   scripts: add argparse module for Python 2.6 compatibility
>   docker.py: Python 2.6 argparse compatibility
>   tests: migration/guestperf Python 2.6 argparse compatibility
> 
>  COPYING.PYTHON                     |  270 ++++
>  scripts/argparse.py                | 2406 ++++++++++++++++++++++++++++++++++++
>  tests/docker/docker.py             |    4 +-
>  tests/migration/guestperf/shell.py |    8 +-
>  4 files changed, 2684 insertions(+), 4 deletions(-)
>  create mode 100644 COPYING.PYTHON
>  create mode 100644 scripts/argparse.py
> 

Acked-by: John Snow <jsnow@redhat.com>

Seems sane to me, provided it actually works in those 2.6 contexts we
wish it to...

Re: [Qemu-devel] [PATCH 0/3] scripts: add argparse module for Python 2.6 compatibility
Posted by Stefan Hajnoczi 6 years, 7 months ago
On Fri, Aug 25, 2017 at 04:57:29PM +0100, Stefan Hajnoczi wrote:
> Many scripts can benefit from the standard library argparse module, which has
> improvements over the older optparse module.  Unfortunately argparse was only
> shipped in Python 2.7 so we need a fallback for Python 2.6.
> 
> This patch series adds a copy of argparse.py and updates scripts as necessary
> to import it.
> 
> Stefan Hajnoczi (3):
>   scripts: add argparse module for Python 2.6 compatibility
>   docker.py: Python 2.6 argparse compatibility
>   tests: migration/guestperf Python 2.6 argparse compatibility
> 
>  COPYING.PYTHON                     |  270 ++++
>  scripts/argparse.py                | 2406 ++++++++++++++++++++++++++++++++++++
>  tests/docker/docker.py             |    4 +-
>  tests/migration/guestperf/shell.py |    8 +-
>  4 files changed, 2684 insertions(+), 4 deletions(-)
>  create mode 100644 COPYING.PYTHON
>  create mode 100644 scripts/argparse.py
> 
> -- 
> 2.13.5
> 
> 

Thanks, applied to my block-next tree:
https://github.com/stefanha/qemu/commits/block-next

Stefan