LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File gpsd-python3.patch of Package gpsd (Project home:KAMiKAZOW)

Index: gpsd-3.17/SConstruct
===================================================================
--- gpsd-3.17.orig/SConstruct
+++ gpsd-3.17/SConstruct
@@ -23,6 +23,14 @@
 # * Out-of-directory builds: see http://www.scons.org/wiki/UsingBuildDir
 # * Coveraging mode: gcc "-coverage" flag requires a hack
 #   for building the python bindings
+# * Python 3 compatibility in this recipe
+
+# Since SCons 3.0.0 forces print_function on us, it needs to be unconditional.
+# This is recognized to be a bug in SCons, but we need to live with it for now,
+# and we'll need this for eventual Python 3 compatibility, anyway.
+# Python requires this to precede any non-comment code.
+from __future__ import print_function
+from functools import reduce
 
 # Release identification begins here
 gpsd_version = "3.17"
@@ -111,6 +119,8 @@ def filtered_spawn(sh, escape, cmd, args
 # Build-control options
 #

+Decider('timestamp-match')
+
 # Start by reading configuration variables from the cache
 opts = Variables('.scons-option-cache')

@@ -354,7 +364,7 @@ for flag in ["LDFLAGS", "SHLINKFLAGS", "
 
 
 # Keep scan-build options in the environment
-for key, value in os.environ.iteritems():
+for key, value in os.environ.items():
     if key.startswith('CCC_'):
         env.Append(ENV={key: value})
 
@@ -375,7 +383,7 @@ if env.GetOption("silent"):
 
 def announce(msg):
     if not env.GetOption("silent"):
-        print msg
+        print(msg)
 
 # DESTDIR environment variable means user prefix the installation root.
 DESTDIR = os.environ.get('DESTDIR', '')
@@ -460,6 +468,8 @@ if env['sysroot']:
     env.MergeFlags({"LINKFLAGS": ["--sysroot=%s" % env['sysroot']]})
 
 # Build help
+def cmp(a, b):
+    return (a > b) - (a < b)
 
 Help("""Arguments may be a mixture of switches and targets in any order.
 Switches apply to the entire build regardless of where they are in the order.
@@ -843,9 +853,9 @@ else:
         "dbus_export": ["libdbus-1"],
     }
 
-    keys = map(lambda x: (x[0], x[2]), boolopts)  \
-        + map(lambda x: (x[0], x[2]), nonboolopts) \
-        + map(lambda x: (x[0], x[2]), pathopts)
+    keys = list(map(lambda x: (x[0], x[2]), boolopts))  \
+        + list(map(lambda x: (x[0], x[2]), nonboolopts)) \
+        + list(map(lambda x: (x[0], x[2]), pathopts))
     keys.sort()
     for (key, help) in keys:
         value = env[key]
@@ -946,7 +956,7 @@ if helping:
 
     # If helping just get usable config info from the local Python
     target_python_path = ''
-    py_config_text = str(eval(PYTHON_CONFIG_CALL))
+    Py_config_text = str(eval(PYTHON_CONFIG_CALL))
     python_libdir = str(eval(PYTHON_LIBDIR_CALL))
 
 else:
@@ -982,7 +992,7 @@ else:
 if env['python']:  # May have been turned off by error
     env['PYTHON'] = target_python_path
     env['ENV']['PYTHON'] = target_python_path  # For regress-driver
-    py_config_vars = ast.literal_eval(py_config_text)
+    py_config_vars = ast.literal_eval(py_config_text.decode())
     py_config_vars = [[] if x is None else x for x in py_config_vars]
     python_config = dict(zip(PYTHON_CONFIG_NAMES, py_config_vars))
 
@@ -1371,7 +1381,7 @@ else:
 
     python_objects = {}
     python_compiled_libs = {}
-    for ext, sources in python_extensions.iteritems():
+    for ext, sources in python_extensions.items():
         python_objects[ext] = []
         for src in sources:
             python_objects[ext].append(
@@ -1401,7 +1411,7 @@ Platform: UNKNOWN
     python_egg_info = python_env.Textfile(target="gps-%s.egg-info"
                                           % (gpsd_version, ),
                                           source=python_egg_info_source)
-    python_built_extensions = python_compiled_libs.values()
+    python_built_extensions = list(python_compiled_libs.values())
     python_targets = python_built_extensions + [python_egg_info]
 
 env.Command(target="packet_names.h", source="packet_states.h", action="""
@@ -1546,8 +1556,8 @@ def substituter(target, source, env):
         content = content.replace(s, t)
     m = re.search("@[A-Z]+@", content)
     if m and m.group(0) not in map(lambda x: x[0], substmap):
-        print >>sys.stderr, "Unknown subst token %s in %s." \
-            % (m.group(0), sfp.name)
+        print("Unknown subst token %s in %s." % (m.group(0), sfp.name),
+              file=sys.stderr)
     tfp = open(str(target[0]), "w")
     tfp.write(content)
     tfp.close()
@@ -1604,14 +1614,14 @@ if env['xgps']:
         "xgpsspeed.1": "gps.xml",
         "xgps.1": "gps.xml",
     })
-all_manpages = base_manpages.keys() + python_manpages.keys()
+all_manpages = list(base_manpages.keys()) + list(python_manpages.keys())
 
 man_env = env.Clone()
 if man_env.GetOption('silent'):
     man_env['SPAWN'] = filtered_spawn  # Suppress stderr chatter
 manpage_targets = []
 if manbuilder:
-    for (man, xml) in base_manpages.items() + python_manpages.items():
+    for (man, xml) in list(base_manpages.items()) + list(python_manpages.items()):
         manpage_targets.append(man_env.Man(source=xml, target=man))
 
 # Where it all comes together
@@ -1692,7 +1702,7 @@ if qt_env:
 
 
 maninstall = []
-for manpage in base_manpages.keys() + python_manpages.keys():
+for manpage in list(base_manpages.keys()) + list(python_manpages.keys()):
     if not manbuilder and not os.path.exists(manpage):
         continue
     section = manpage.split(".")[1]
@@ -2177,7 +2187,7 @@ htmlpages = Split('''
     www/writing-a-driver.html
     ''')
 
-webpages = htmlpages + asciidocs + map(lambda f: f[:-3], glob.glob("www/*.in"))
+webpages = htmlpages + asciidocs + list(map(lambda f: f[:-3], glob.glob("www/*.in")))
 
 www = env.Alias('www', webpages)
 
@@ -2190,7 +2200,7 @@ def validation_list(target, source, env)
         if '-head' not in page:
             fp = open(page)
             if "Valid HTML" in fp.read():
-                print os.path.join(website, os.path.basename(page))
+                print(os.path.join(website, os.path.basename(page)))
             fp.close()
 Utility("validation-list", [www], validation_list)