# [StGIT] Failure to install on RHELWS4

8 messages from 2008-07-11 to 2008-07-16. Participants: Petr Baudis, Thomas Rast, Miklos Vajna, Catalin Marinas, Karl Hasselström.
Thread: https://gitlist.dev/t/14412

## Petr Baudis, 2008-07-11 17:03

Subject: [StGIT] Failure to install on RHELWS4
Message-ID: <20080711170356.GF32184@machine.or.cz>
URL: https://gitlist.dev/e/20080711170356.GF32184%40machine.or.cz

```
  Hi,

  I wanted to install latest HEAD of StGIT on a rather ancient-feeling
RHEL4, however, when doing python setup.py install, I'm getting

	  File "setup.py", line 31
	    pyver = '.'.join(str(n) for n in sys.version_info)
	                              ^
SyntaxError: invalid syntax

I don't really know python and the ^ is rather curiously-positioned, so
I don't have much clue on what is going on. Python version is 2.3.4 -
maybe that's too old, but I didn't find any word on the minimal Python
version nowhere in the documentation.

-- 
				Petr "Pasky" Baudis
The last good thing written in C++ was the Pachelbel Canon. -- J. Olson

```

## Thomas Rast, 2008-07-11 19:26

Subject: Re: [StGIT] Failure to install on RHELWS4
Message-ID: <200807112126.39729.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200807112126.39729.trast%40student.ethz.ch
In-Reply-To: <20080711170356.GF32184@machine.or.cz>

```
Petr Baudis wrote:
> 
> 	    pyver = '.'.join(str(n) for n in sys.version_info)
> 	                              ^
[...]
> Python version is 2.3.4

That is indeed too old.  Generator expressions like the above were
introduced in 2.4:

  http://www.python.org/dev/peps/pep-0289/

- Thomas

-- 
Thomas Rast
trast@student.ethz.ch



```

## Miklos Vajna, 2008-07-11 20:07

Subject: Re: [StGIT] Failure to install on RHELWS4
Message-ID: <20080711200735.GK10347@genesis.frugalware.org>
URL: https://gitlist.dev/e/20080711200735.GK10347%40genesis.frugalware.org
In-Reply-To: <200807112126.39729.trast@student.ethz.ch>

```
On Fri, Jul 11, 2008 at 09:26:29PM +0200, Thomas Rast <trast@student.ethz.ch> wrote:
> > 	    pyver = '.'.join(str(n) for n in sys.version_info)
> > 	                              ^
> [...]
> > Python version is 2.3.4
> 
> That is indeed too old.  Generator expressions like the above were
> introduced in 2.4:
> 
>   http://www.python.org/dev/peps/pep-0289/

So obviously it's a bad idea to use generators for such a version check.

Also, setup.py would try to import stgit.run before the version check.

I'm sending two patches, which restore the wished "Python version 2.4 or
newer required. Found 2.2.1.final.0" error message.

(Tested with Python 2.2.1.)

```

## Miklos Vajna, 2008-07-11 20:09

Subject: [PATCH] setup.py: fix error message when running with python-2.3
Message-ID: <1215806972-18713-1-git-send-email-vmiklos@frugalware.org>
URL: https://gitlist.dev/e/1215806972-18713-1-git-send-email-vmiklos%40frugalware.org
In-Reply-To: <20080711200735.GK10347@genesis.frugalware.org>

```
When setup.py tries to check the python version, the check actually
won't give a usable error message but it'll raise a SyntaxError. Fix
this by not using generator expressions.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 setup.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/setup.py b/setup.py
index 8d8f7a8..44cc6ea 100755
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,7 @@ def __check_min_version(min_ver, ver):
 def __check_python_version():
     """Check the minimum Python version
     """
-    pyver = '.'.join(str(n) for n in sys.version_info)
+    pyver = '.'.join(map(lambda x: str(x), sys.version_info))
     if not __check_min_version(version.python_min_ver, pyver):
         print >> sys.stderr, 'Python version %s or newer required. Found %s' \
               % (version.python_min_ver, pyver)
-- 
1.5.6.2.450.g8d367.dirty

```

## Miklos Vajna, 2008-07-11 20:09

Subject: [PATCH] setup.py: don't try to import stgit.run before the python version check
Message-ID: <1215806972-18713-2-git-send-email-vmiklos@frugalware.org>
URL: https://gitlist.dev/e/1215806972-18713-2-git-send-email-vmiklos%40frugalware.org
In-Reply-To: <1215806972-18713-1-git-send-email-vmiklos@frugalware.org>

```
stgit.run would import datetime, which is not available in older python
versions. import it just after the version check passed.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 setup.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/setup.py b/setup.py
index 44cc6ea..a685cf6 100755
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,6 @@ import sys, glob, os
 from distutils.core import setup
 
 from stgit import version
-from stgit.run import Run
 
 def __version_to_list(version):
     """Convert a version string to a list of numbers or strings
@@ -68,6 +67,8 @@ if sys.argv[1] in ['install', 'build']:
     __check_python_version()
     __check_git_version()
 
+from stgit.run import Run
+
 # ensure readable template files
 old_mask = os.umask(0022)
 
-- 
1.5.6.2.450.g8d367.dirty

```

## Catalin Marinas, 2008-07-11 21:35

Subject: Re: [StGIT] Failure to install on RHELWS4
Message-ID: <b0943d9e0807111435h414697faj8a9f789ddc6a938@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0807111435h414697faj8a9f789ddc6a938%40mail.gmail.com
In-Reply-To: <20080711200735.GK10347@genesis.frugalware.org>

```
2008/7/11 Miklos Vajna <vmiklos@frugalware.org>:
> On Fri, Jul 11, 2008 at 09:26:29PM +0200, Thomas Rast <trast@student.ethz.ch> wrote:
>> >         pyver = '.'.join(str(n) for n in sys.version_info)
>> >                                   ^
>> [...]
>> > Python version is 2.3.4
>>
>> That is indeed too old.  Generator expressions like the above were
>> introduced in 2.4:
>>
>>   http://www.python.org/dev/peps/pep-0289/
>
> So obviously it's a bad idea to use generators for such a version check.

Yes, I agree.

> Also, setup.py would try to import stgit.run before the version check.
>
> I'm sending two patches, which restore the wished "Python version 2.4 or
> newer required. Found 2.2.1.final.0" error message.

Thanks.

-- 
Catalin

```

## Karl Hasselström, 2008-07-12 05:19

Subject: Re: [PATCH] setup.py: fix error message when running with python-2.3
Message-ID: <20080712051937.GA17996@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080712051937.GA17996%40diana.vm.bytemark.co.uk
In-Reply-To: <1215806972-18713-1-git-send-email-vmiklos@frugalware.org>

```
On 2008-07-11 22:09:31 +0200, Miklos Vajna wrote:

> When setup.py tries to check the python version, the check actually
> won't give a usable error message but it'll raise a SyntaxError. Fix
> this by not using generator expressions.

> -    pyver = '.'.join(str(n) for n in sys.version_info)
> +    pyver = '.'.join(map(lambda x: str(x), sys.version_info))

Thanks. And by not using a list comprehension, you stay compatible
with pre-2.0 versions as well (though I guess we'd need to test that,
since there may be other 2.0 things we rely on in this code path).

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Karl Hasselström, 2008-07-16 04:39

Subject: Re: [PATCH] setup.py: don't try to import stgit.run before the python version check
Message-ID: <20080716043956.GA31132@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080716043956.GA31132%40diana.vm.bytemark.co.uk
In-Reply-To: <1215806972-18713-2-git-send-email-vmiklos@frugalware.org>

```
On 2008-07-11 22:09:32 +0200, Miklos Vajna wrote:

> @@ -68,6 +67,8 @@ if sys.argv[1] in ['install', 'build']:
>      __check_python_version()
>      __check_git_version()
>  
> +from stgit.run import Run
> +
>  # ensure readable template files
>  old_mask = os.umask(0022)
>  

I had to modify the second hunk to make it work:

@@ -37,6 +36,7 @@ def __check_python_version():
 def __check_git_version():
     """Check the minimum GIT version
     """
+    from stgit.run import Run
     gitver = Run('git', '--version').output_one_line().split()[2]
     if not __check_min_version(git_min_ver, gitver):
         print >> sys.stderr, 'GIT version %s or newer required. Found %s' \

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```
