configure: Require python3 >= 3.5
diff mbox series

Message ID 20190508182339.22447-1-ehabkost@redhat.com
State New
Headers show
Series
  • configure: Require python3 >= 3.5
Related show

Commit Message

Eduardo Habkost May 8, 2019, 6:23 p.m. UTC
The oldest python3 version in distros that will be supported by
QEMU 4.1 is 3.5.3 (the one in Debian Stretch).  Error out if
running python3 < 3.5.

We have a .travis.yml job configured to use Python 3.4.  Change
it to use Python 3.5.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 configure   | 5 +++--
 .travis.yml | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

Comments

Thomas Huth May 9, 2019, 5:40 a.m. UTC | #1
On 08/05/2019 20.23, Eduardo Habkost wrote:
> The oldest python3 version in distros that will be supported by
> QEMU 4.1 is 3.5.3 (the one in Debian Stretch).  Error out if
> running python3 < 3.5.
> 
> We have a .travis.yml job configured to use Python 3.4.  Change
> it to use Python 3.5.
> 
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  configure   | 5 +++--
>  .travis.yml | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/configure b/configure
> index 6b3ed8c532..520c207d66 100755
> --- a/configure
> +++ b/configure
> @@ -1841,8 +1841,9 @@ fi
>  
>  # Note that if the Python conditional here evaluates True we will exit
>  # with status 1 which is a shell 'false' value.
> -if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
> -  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
> +if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7) or \
> +                                      (3,0) <= sys.version_info < (3,5))'; then
> +  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 >= 3.5 is required." \

Nit: There won't be a Python2 > 2.7 anymore, so you could also replace
"2 >= 2.7" with "2.7" here. But well, it will go away next year anyway, so:

Reviewed-by: Thomas Huth <thuth@redhat.com>
Markus Armbruster May 9, 2019, 5:45 a.m. UTC | #2
Eduardo Habkost <ehabkost@redhat.com> writes:

> The oldest python3 version in distros that will be supported by
> QEMU 4.1 is 3.5.3 (the one in Debian Stretch).  Error out if
> running python3 < 3.5.
>
> We have a .travis.yml job configured to use Python 3.4.  Change
> it to use Python 3.5.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
>  configure   | 5 +++--
>  .travis.yml | 2 +-
>  2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 6b3ed8c532..520c207d66 100755
> --- a/configure
> +++ b/configure
> @@ -1841,8 +1841,9 @@ fi
>  
>  # Note that if the Python conditional here evaluates True we will exit
>  # with status 1 which is a shell 'false' value.
> -if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
> -  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
> +if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7) or \
> +                                      (3,0) <= sys.version_info < (3,5))'; then
> +  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 >= 3.5 is required." \
>        "Use --python=/path/to/python to specify a supported Python."
>  fi
>  
> diff --git a/.travis.yml b/.travis.yml
> index 66448d99d6..0f6986b3f1 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -211,7 +211,7 @@ matrix:
>          - CONFIG="--target-list=x86_64-softmmu"
>        language: python
>        python:
> -        - "3.4"
> +        - "3.5"
>  
>  
>      - env:

Easily missed, good work.

My grep for similar references to Python versions we don't support found
a few 2.x, x < 7.  Not this patch's problem, of course, but let me show
them anyway:

* scripts/qapi/common.py

        # re.subn() lacks flags support before Python 2.7, use re.compile()

  I'll clean this up.

* tests/image-fuzzer/

  docs/image-fuzzer.txt "Fuzzer requirements" item "17. Should be
  compatible with python version 2.4-2.7".

  Stefan, does the fuzzer need porting to Python 3?

  Two spots in the code are marked as 2.4 work-arounds:

    tests/image-fuzzer/qcow2/fuzz.py:        in Python 2.4
    tests/image-fuzzer/runner.py:        # Python 2.4 doesn't support 'finally' and 'except' in the same 'try'

Grep also found tests/vm/netbsd and tests/vm/openbsd pass
--python=python2.7 to configure.  Eduardo, should they be upgraded to a
suitable version of Python 3?  Possibly in your "[PATCH] Deprecate
Python 2 support"?

If yes, then https://wiki.qemu.org/Hosts/BSD also needs an update.
Kevin Wolf May 9, 2019, 9:24 a.m. UTC | #3
Am 09.05.2019 um 07:45 hat Markus Armbruster geschrieben:
> Eduardo Habkost <ehabkost@redhat.com> writes:
> > diff --git a/.travis.yml b/.travis.yml
> > index 66448d99d6..0f6986b3f1 100644
> > --- a/.travis.yml
> > +++ b/.travis.yml
> > @@ -211,7 +211,7 @@ matrix:
> >          - CONFIG="--target-list=x86_64-softmmu"
> >        language: python
> >        python:
> > -        - "3.4"
> > +        - "3.5"
> >  
> >  
> >      - env:
> 
> Easily missed, good work.
> 
> My grep for similar references to Python versions we don't support found
> a few 2.x, x < 7.  Not this patch's problem, of course, but let me show
> them anyway:

I'm sure that we have a few more instances of Python 2 compatibility
code in qemu-iotests that can be removed after this is merged. These are
what I could find quickly, but there are probably more:

    242:        # Read one byte in a way compatible with Python 2
    iotests.py:        # Python < 3.4 needs to know not to add whitespace when pretty-printing:

    149:from __future__ import print_function
    165:from __future__ import print_function
    iotests.py:from __future__ import print_function
    nbd-fault-injector.py:from __future__ import print_function
    qcow2.py:from __future__ import print_function
    qed.py:from __future__ import print_function

    044:if sys.version_info.major == 2:
    163:if sys.version_info.major == 2:
    iotests.py:    if sys.version_info.major >= 3:
    iotests.py:        if sys.version_info.major >= 3:
    nbd-fault-injector.py:if sys.version_info.major >= 3:

I'm planning to take care of the qemu-iotests ones.

Also, with Python 3.5 as the new minimum, I think I'd like to add type
hints to iotests.py and possibly the qemu package (for QEMUQtestMachine
and friends). The syntax isn't as nice as if we could go straight to
3.6, but still, finally some type checking instead of running into
stupid runtime bugs!

Kevin
Kevin Wolf May 9, 2019, 9:36 a.m. UTC | #4
Am 09.05.2019 um 11:24 hat Kevin Wolf geschrieben:
> Am 09.05.2019 um 07:45 hat Markus Armbruster geschrieben:
> > Eduardo Habkost <ehabkost@redhat.com> writes:
> > > diff --git a/.travis.yml b/.travis.yml
> > > index 66448d99d6..0f6986b3f1 100644
> > > --- a/.travis.yml
> > > +++ b/.travis.yml
> > > @@ -211,7 +211,7 @@ matrix:
> > >          - CONFIG="--target-list=x86_64-softmmu"
> > >        language: python
> > >        python:
> > > -        - "3.4"
> > > +        - "3.5"
> > >  
> > >  
> > >      - env:
> > 
> > Easily missed, good work.
> > 
> > My grep for similar references to Python versions we don't support found
> > a few 2.x, x < 7.  Not this patch's problem, of course, but let me show
> > them anyway:
> 
> I'm sure that we have a few more instances of Python 2 compatibility
> code in qemu-iotests that can be removed after this is merged. These are
> what I could find quickly, but there are probably more:
> 
>     242:        # Read one byte in a way compatible with Python 2
>     iotests.py:        # Python < 3.4 needs to know not to add whitespace when pretty-printing:
> 
>     149:from __future__ import print_function
>     165:from __future__ import print_function
>     iotests.py:from __future__ import print_function
>     nbd-fault-injector.py:from __future__ import print_function
>     qcow2.py:from __future__ import print_function
>     qed.py:from __future__ import print_function
> 
>     044:if sys.version_info.major == 2:
>     163:if sys.version_info.major == 2:
>     iotests.py:    if sys.version_info.major >= 3:
>     iotests.py:        if sys.version_info.major >= 3:
>     nbd-fault-injector.py:if sys.version_info.major >= 3:
> 
> I'm planning to take care of the qemu-iotests ones.
> 
> Also, with Python 3.5 as the new minimum, I think I'd like to add type
> hints to iotests.py and possibly the qemu package (for QEMUQtestMachine
> and friends). The syntax isn't as nice as if we could go straight to
> 3.6, but still, finally some type checking instead of running into
> stupid runtime bugs!

Ah, sorry, I was getting too excited there. We only deprecate 2.x now
(and not even in this patch), but don't remove it yet. So I guess this
will have to wait until next year.

Kevin
Daniel P. Berrangé May 9, 2019, 9:40 a.m. UTC | #5
On Thu, May 09, 2019 at 11:36:04AM +0200, Kevin Wolf wrote:
> Am 09.05.2019 um 11:24 hat Kevin Wolf geschrieben:
> > Am 09.05.2019 um 07:45 hat Markus Armbruster geschrieben:
> > > Eduardo Habkost <ehabkost@redhat.com> writes:
> > > > diff --git a/.travis.yml b/.travis.yml
> > > > index 66448d99d6..0f6986b3f1 100644
> > > > --- a/.travis.yml
> > > > +++ b/.travis.yml
> > > > @@ -211,7 +211,7 @@ matrix:
> > > >          - CONFIG="--target-list=x86_64-softmmu"
> > > >        language: python
> > > >        python:
> > > > -        - "3.4"
> > > > +        - "3.5"
> > > >  
> > > >  
> > > >      - env:
> > > 
> > > Easily missed, good work.
> > > 
> > > My grep for similar references to Python versions we don't support found
> > > a few 2.x, x < 7.  Not this patch's problem, of course, but let me show
> > > them anyway:
> > 
> > I'm sure that we have a few more instances of Python 2 compatibility
> > code in qemu-iotests that can be removed after this is merged. These are
> > what I could find quickly, but there are probably more:
> > 
> >     242:        # Read one byte in a way compatible with Python 2
> >     iotests.py:        # Python < 3.4 needs to know not to add whitespace when pretty-printing:
> > 
> >     149:from __future__ import print_function
> >     165:from __future__ import print_function
> >     iotests.py:from __future__ import print_function
> >     nbd-fault-injector.py:from __future__ import print_function
> >     qcow2.py:from __future__ import print_function
> >     qed.py:from __future__ import print_function
> > 
> >     044:if sys.version_info.major == 2:
> >     163:if sys.version_info.major == 2:
> >     iotests.py:    if sys.version_info.major >= 3:
> >     iotests.py:        if sys.version_info.major >= 3:
> >     nbd-fault-injector.py:if sys.version_info.major >= 3:
> > 
> > I'm planning to take care of the qemu-iotests ones.
> > 
> > Also, with Python 3.5 as the new minimum, I think I'd like to add type
> > hints to iotests.py and possibly the qemu package (for QEMUQtestMachine
> > and friends). The syntax isn't as nice as if we could go straight to
> > 3.6, but still, finally some type checking instead of running into
> > stupid runtime bugs!
> 
> Ah, sorry, I was getting too excited there. We only deprecate 2.x now
> (and not even in this patch), but don't remove it yet. So I guess this
> will have to wait until next year.

If you're happy using one of the comment based hinting syntax, that
will work, or at least not break, with python 2

https://www.bernat.tech/the-state-of-type-hints-in-python/

Regards,
Daniel

Patch
diff mbox series

diff --git a/configure b/configure
index 6b3ed8c532..520c207d66 100755
--- a/configure
+++ b/configure
@@ -1841,8 +1841,9 @@  fi
 
 # Note that if the Python conditional here evaluates True we will exit
 # with status 1 which is a shell 'false' value.
-if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7))'; then
-  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 is required." \
+if ! $python -c 'import sys; sys.exit(sys.version_info < (2,7) or \
+                                      (3,0) <= sys.version_info < (3,5))'; then
+  error_exit "Cannot use '$python', Python 2 >= 2.7 or Python 3 >= 3.5 is required." \
       "Use --python=/path/to/python to specify a supported Python."
 fi
 
diff --git a/.travis.yml b/.travis.yml
index 66448d99d6..0f6986b3f1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -211,7 +211,7 @@  matrix:
         - CONFIG="--target-list=x86_64-softmmu"
       language: python
       python:
-        - "3.4"
+        - "3.5"
 
 
     - env: