Skip to contentSkip to conversation

README: require Python 2.4 or newer

PATCH In review Doug Goldstein 1 participant 3 messages Feb 28, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 README: require Python 2.4 or newer

Increase the minimum required Python to 2.4 or newer.

---
CC: Andrew Cooper <[email protected]>
CC: George Dunlap <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
---
change from v1:
- changed from Python 2.6 to Python 2.4 based on

While the tools are broke with Python 2.4 currently there are some scripts that people have an interest in still being able to run with Python 2.4 so changed the documented information there. I'm working on some updates to the Travis CI test loop (actually switching to GitLab CI) to give us more flexibility in what is being tested.

See
https://lists.xenproject.org/archives/html/xen-devel/2017-09/msg02389.html
for context on the build failures in tools with Python 2.4

---
 README | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
README +1 -1
index e96cdd2862..4ed03b7fe2 100644
@@ -46,7 +46,7 @@ provided by your OS distributor:
         - GCC 4.8 or later
         - GNU Binutils 2.24 or later
     * Development install of zlib (e.g., zlib-dev)
-    * Development install of Python v2.3 or later (e.g., python-dev)
+    * Development install of Python v2.4 or later (e.g., python-dev)
     * Development install of curses (e.g., libncurses-dev)
     * Development install of openssl (e.g., openssl-dev)
     * Development install of x11 (e.g. xorg-x11-dev)
Signature · 7 lines
2.16.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#1 lore raw

PATCH v2 2/2 xen/tools: support Python 2 and Python 3

These changes should make it possible to support modern Pythons as well as the oldest Python 2 still supported.

---
CC: Andrew Cooper <[email protected]>
CC: George Dunlap <[email protected]>
CC: Ian Jackson <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Konrad Rzeszutek Wilk <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Tim Deegan <[email protected]>
CC: Wei Liu <[email protected]>
---
changes since v1:
- switched to print() in cases where it works from Andrew Cooper
- dropped long() magic from Andrew Cooper. This is unnecessary with Python 2.4 and newer.

---
 xen/tools/compat-build-header.py |  2 +-
 xen/tools/compat-build-source.py |  2 +-
 xen/tools/gen-cpuid.py           | 34 ++++++++++++++++++++++++----------
 xen/tools/get-fields.sh          |  2 +-
 4 files changed, 27 insertions(+), 13 deletions(-)
xen/tools/compat-build-header.py +1 -1
index 32421b645b..b85c43f13f 100755
@@ -23,4 +23,4 @@ pats = [
 for line in sys.stdin.readlines():
     for pat in pats:
         line = re.subn(pat[0], pat[1], line)[0]
-    print line.rstrip()
+    print(line.rstrip())
xen/tools/compat-build-source.py +1 -1
index 595bc3ff58..c664eb85e6 100755
@@ -26,4 +26,4 @@ for pat in pats:
 for line in sys.stdin.readlines():
     for pat in pats:
         line = re.sub(pat[0], pat[1], line)
-    print line.rstrip()
+    print(line.rstrip())
xen/tools/gen-cpuid.py +24 -10
index 613b909c3d..6359afb704 100755
@@ -3,6 +3,10 @@
 
 import sys, os, re
 
+if (sys.version_info > (3, 0)):
+    def xrange(x):
+        return range(x)
+
 class Fail(Exception):
     pass
 
@@ -98,13 +102,13 @@ def parse_definitions(state):
 def featureset_to_uint32s(fs, nr):
     """ Represent a featureset as a list of C-compatible uint32_t's """
 
-    bitmap = 0L
+    bitmap = 0
     for f in fs:
-        bitmap |= 1L << f
+        bitmap |= 1 << f
 
     words = []
     while bitmap:
-        words.append(bitmap & ((1L << 32) - 1))
+        words.append(bitmap & ((1 << 32) - 1))
         bitmap >>= 32
 
     assert len(words) <= nr
@@ -276,8 +280,8 @@ def crunch_numbers(state):
             # To debug, uncomment the following lines:
             # def repl(l):
             #     return "[" + ", ".join((state.names[x] for x in l)) + "]"
-            # print >>sys.stderr, "Feature %s, seen %s, to_process %s " % \
-            #     (state.names[feat], repl(seen), repl(to_process))
+            # sys.stderr.write("Feature %s, seen %s, to_process %s \n" % \
+            #     (state.names[feat], repl(seen), repl(to_process)))
 
             f = to_process.pop(0)
 
@@ -293,7 +297,12 @@ def crunch_numbers(state):
     state.deep_features = featureset_to_uint32s(deps.keys(), nr_entries)
     state.nr_deep_deps = len(state.deep_deps.keys())
 
-    for k, v in state.deep_deps.iteritems():
+    try:
+        _tmp = state.deep_deps.iteritems()
+    except AttributeError:
+        _tmp = state.deep_deps.items()
+
+    for k, v in _tmp:
         state.deep_deps[k] = featureset_to_uint32s(v, nr_entries)
 
     # Calculate the bitfield name declarations
@@ -410,7 +419,8 @@ def open_file_or_fd(val, mode, buffering):
         else:
             return open(val, mode, buffering)
 
-    except StandardError, e:
+    except StandardError:
+        e = sys.exc_info()[1]
         if fd != -1:
             raise Fail("Unable to open fd %d: %s: %s" %
                        (fd, e.__class__.__name__, e))
@@ -453,10 +463,14 @@ def main():
 if __name__ == "__main__":
     try:
         sys.exit(main())
-    except Fail, e:
-        print >>sys.stderr, "%s:" % (sys.argv[0],), e
+    except Fail:
+        e = sys.exc_info()[1]
+        sys.stderr.write("%s:" % (sys.argv[0],))
+        sys.stderr.write(e)
+        sys.stderr.write("\n")
         sys.exit(1)
-    except SystemExit, e:
+    except SystemExit:
+        e = sys.exc_info()[1]
         sys.exit(e.code)
     except KeyboardInterrupt:
         sys.exit(2)
xen/tools/get-fields.sh +1 -1
index 887feec370..45a0e2ed50 100644
@@ -139,7 +139,7 @@ handle_field ()
 		local tag=$(echo "$5" | ${PYTHON} -c '
 import re,sys
 for line in sys.stdin.readlines():
-    print re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip()
+    sys.stdout.write(re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip() + "\n")
 ')
 		echo " \\"
 		printf %s "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);"
Signature · 7 lines
2.16.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel