Patchwork [v2,4/5] configure: check for supported Python 2.x versions

login
register
mail settings
Submitter Stefan Hajnoczi
Date April 30, 2012, 11:06 a.m.
Message ID <1335783992-25149-5-git-send-email-stefanha@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/155836/
State New
Headers show

Comments

Stefan Hajnoczi - April 30, 2012, 11:06 a.m.
The tracetool code requires Python 2.4, which was released in 2004.
Check for a supported Python version so we can give a clear error
message.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
 configure |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
Lluís Vilanova - May 1, 2012, 1:20 p.m.
Stefan Hajnoczi writes:

> The tracetool code requires Python 2.4, which was released in 2004.
> Check for a supported Python version so we can give a clear error
> message.

> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
> ---
>  configure |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

> diff --git a/configure b/configure
> index 25697bb..0e6fbbc 100755
> --- a/configure
> +++ b/configure
> @@ -1247,9 +1247,10 @@ 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[0] >= 3)'; then
> -  echo "Python 2 required but '$python' is version 3 or better."
> -  echo "Use --python=/path/to/python to specify a Python 2."
> +if ! "$python" -c 'import sys; sys.version_info < (2,4) or sys.version_info >= (3,)'; then
> +  echo "Cannot use '$python', Python 2.4 or later is required."
> +  echo "Note that Python 3 or later is not yet supported."
> +  echo "Use --python=/path/to/python to specify a supported Python."
>    exit 1
>  fi

Shouldn't this be using "sys.exit(...version checks...)" ?


Lluis
Stefan Hajnoczi - May 1, 2012, 3:34 p.m.
On Tue, May 1, 2012 at 2:20 PM, Lluís Vilanova <vilanova@ac.upc.edu> wrote:
> Stefan Hajnoczi writes:
>
>> The tracetool code requires Python 2.4, which was released in 2004.
>> Check for a supported Python version so we can give a clear error
>> message.
>
>> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
>> ---
>>  configure |    7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>
>> diff --git a/configure b/configure
>> index 25697bb..0e6fbbc 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1247,9 +1247,10 @@ 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[0] >= 3)'; then
>> -  echo "Python 2 required but '$python' is version 3 or better."
>> -  echo "Use --python=/path/to/python to specify a Python 2."
>> +if ! "$python" -c 'import sys; sys.version_info < (2,4) or sys.version_info >= (3,)'; then
>> +  echo "Cannot use '$python', Python 2.4 or later is required."
>> +  echo "Note that Python 3 or later is not yet supported."
>> +  echo "Use --python=/path/to/python to specify a supported Python."
>>    exit 1
>>  fi
>
> Shouldn't this be using "sys.exit(...version checks...)" ?

Yes, thanks for pointing it out.

Stefan

Patch

diff --git a/configure b/configure
index 25697bb..0e6fbbc 100755
--- a/configure
+++ b/configure
@@ -1247,9 +1247,10 @@  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[0] >= 3)'; then
-  echo "Python 2 required but '$python' is version 3 or better."
-  echo "Use --python=/path/to/python to specify a Python 2."
+if ! "$python" -c 'import sys; sys.version_info < (2,4) or sys.version_info >= (3,)'; then
+  echo "Cannot use '$python', Python 2.4 or later is required."
+  echo "Note that Python 3 or later is not yet supported."
+  echo "Use --python=/path/to/python to specify a supported Python."
   exit 1
 fi