Skip to contentSkip to conversation

Failure to install on RHELWS4

StGIT In review Petr Baudis 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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.

Signature · 2 lines
				Petr "Pasky" Baudis
The last good thing written in C++ was the Pachelbel Canon. -- J. Olson
#2 lore raw
Quoted 9 lines · Thomas Rast
Quoted 2 lines
	    pyver = '.'.join(str(n) for n in sys.version_info)
	                              ^

[...]

Quoted 1 line

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.)

#3 lore raw

PATCH 1/1 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.

---
 setup.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
setup.py +1 -1
index 8d8f7a8..44cc6ea 100755
@@ -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)
Signature · 1 line
1.5.6.2.450.g8d367.dirty
#4 lore raw

PATCH 1/1 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.

---
 setup.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
setup.py +2 -1
index 44cc6ea..a685cf6 100755
@@ -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)
 
Signature · 1 line
1.5.6.2.450.g8d367.dirty
#5 lore raw

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

setup.py if sys.argv[1] in ['install', 'build']: · line 74

Quoted 9 lines · Miklos Vajna
setup.py +2 -0
@@ -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' \
Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#6 lore raw

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

In reply to Miklos Vajna

setup.py def __check_min_version(min_ver, ver): · line 31

Quoted 6 lines · Miklos Vajna

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.

setup.py +1 -1
-    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).

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#7 lore raw
In reply to Miklos Vajna

2008/7/11 Miklos Vajna <[email protected]>:

Quoted 12 lines · Thomas Rast
Quoted 9 lines
Quoted 2 lines

pyver = '.'.join(str(n) for n in sys.version_info)
^

[...]

Quoted 1 line

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.

Quoted 4 lines

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.

Signature · 1 line
Catalin