threads / discuss / 14412

[StGIT] Failure to install on RHELWS4

Subject: [StGIT] Failure to install on RHELWS4

## tl;dr

8 messages between Jul 11, 2008 and Jul 16, 2008.

replies: 7people: 5as markdown or json

Petr Baudis· Jul 11, 2008, 17:03 UTC · lore
  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· Jul 11, 2008, 19:26 UTC · re: Petr Baudis · lore

Re: [StGIT] Failure to install on RHELWS4

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· Jul 11, 2008, 20:07 UTC · re: Thomas Rast · lore

Re: [StGIT] Failure to install on RHELWS4

On Fri, Jul 11, 2008 at 09:26:29PM +0200, Thomas Rast <trast@student.ethz.ch> wrote:
Show 9 quoted lines
> > 	    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· Jul 11, 2008, 20:09 UTC · re: Miklos Vajna · lore

[PATCH] setup.py: fix error message when running with python-2.3

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· Jul 11, 2008, 20:09 UTC · re: Miklos Vajna · lore

[PATCH] setup.py: don't try to import stgit.run before the python version check

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
Karl Hasselström· Jul 16, 2008, 04:39 UTC · re: Miklos Vajna · lore

Re: [PATCH] setup.py: don't try to import stgit.run before the python version check

On 2008-07-11 22:09:32 +0200, Miklos Vajna wrote:
Show 9 quoted lines
> @@ -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
Karl Hasselström· Jul 12, 2008, 05:19 UTC · re: Miklos Vajna · lore

Re: [PATCH] setup.py: fix error message when running with python-2.3

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
Catalin Marinas· Jul 11, 2008, 21:35 UTC · re: Miklos Vajna · lore

Re: [StGIT] Failure to install on RHELWS4

2008/7/11 Miklos Vajna <vmiklos@frugalware.org>:
Show 12 quoted lines
> 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

← back to recent threads