build: allow the waf build to work with python 3.0 and 3.1
authorThomas Nagy <tnagy1024@gmail.com>
Wed, 7 Apr 2010 21:45:46 +0000 (07:45 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 7 Apr 2010 21:46:39 +0000 (07:46 +1000)
Python 3.x is a bit fussier about print statements and indentation.

Signed-off-by: Andrew Tridgell <tridge@samba.org>
14 files changed:
buildtools/wafsamba/samba_autoconf.py
buildtools/wafsamba/samba_deps.py
buildtools/wafsamba/samba_install.py
buildtools/wafsamba/samba_utils.py
buildtools/wafsamba/wafsamba.py
lib/socket_wrapper/wscript
lib/util/wscript_configure
lib/wscript_build
pidl/wscript
source4/dynconfig/wscript
source4/scripting/wscript_build
source4/selftest/wscript
source4/setup/wscript_build
source4/wscript

index d1b43d4e8a4311b68962f28a26e9a97028f8a08e..32c7463981723ce4b11c77acc2dc509175bd0723 100644 (file)
@@ -545,7 +545,7 @@ def SAMBA_CONFIG_H(conf, path=None):
                         testflags=True)
 
     if Options.options.pedantic:
-       conf.ADD_CFLAGS('-W', testflags=True)
+        conf.ADD_CFLAGS('-W', testflags=True)
 
     if path is None:
         conf.write_config_header('config.h', top=True)
index 08a24db5bb27d998661d1a0104226120ffeb90ef..be77d2c611f1f4eed38c2d90ef117443f9d9f612 100644 (file)
@@ -96,10 +96,9 @@ def build_dependencies(self):
 
     if getattr(self, 'uselib', None):
         up_list = []
-       for l in self.uselib:
-           up_list.append(l.upper())
-       self.uselib = up_list
-
+        for l in self.uselib:
+           up_list.append(l.upper())
+        self.uselib = up_list
 
 def build_includes(self):
     '''This builds the right set of includes for a target.
@@ -280,7 +279,7 @@ def check_orpaned_targets(bld, tgt_list):
         type = target_dict[t.sname]
         if not type in ['BINARY', 'LIBRARY', 'MODULE', 'ET', 'PYTHON']:
             if re.search('^PIDL_', t.sname) is None:
-                print "Target %s of type %s is unused by any other target" % (t.sname, type)
+                print("Target %s of type %s is unused by any other target" % (t.sname, type))
 
 
 def show_final_deps(bld, tgt_list):
@@ -329,7 +328,7 @@ def build_direct_deps(bld, tgt_list):
             d = EXPAND_ALIAS(bld, d)
             if d == t.sname: continue
             if not d in targets:
-                print "Unknown dependency %s in %s" % (d, t.sname)
+                print("Unknown dependency %s in %s" % (d, t.sname))
                 raise
             if targets[d] in [ 'EMPTY', 'DISABLED' ]:
                 continue
@@ -344,7 +343,7 @@ def build_direct_deps(bld, tgt_list):
                 continue
             t2 = bld.name_to_obj(d, bld.env)
             if t2 is None:
-                print "no task %s type %s" % (d, targets[d])
+                print("no task %s type %s" % (d, targets[d]))
             if t2.samba_type in [ 'LIBRARY', 'MODULE' ]:
                 t.direct_libs.add(d)
             elif t2.samba_type in [ 'SUBSYSTEM', 'ASN1', 'PYTHON' ]:
@@ -823,7 +822,7 @@ def check_project_rules(bld):
             continue
         t = bld.name_to_obj(tgt, bld.env)
         if t is None:
-            print "Target %s of type %s has no task generator" % (tgt, type)
+            print("Target %s of type %s has no task generator" % (tgt, type))
             raise
         tgt_list.append(t)
 
@@ -832,7 +831,7 @@ def check_project_rules(bld):
     if load_samba_deps(bld, tgt_list):
         return
 
-    print "Checking project rules ..."
+    print("Checking project rules ...")
 
     debug('deps: project rules checking started')
 
@@ -851,7 +850,7 @@ def check_project_rules(bld):
     #check_orpaned_targets(bld, tgt_list)
 
     if not check_duplicate_sources(bld, tgt_list):
-        print "Duplicate sources present - aborting"
+        print("Duplicate sources present - aborting")
         sys.exit(1)
 
     show_final_deps(bld, tgt_list)
@@ -861,7 +860,7 @@ def check_project_rules(bld):
 
     save_samba_deps(bld, tgt_list)
 
-    print "Project rules pass"
+    print("Project rules pass")
 
 
 def CHECK_PROJECT_RULES(bld):
index 2f861616c185027fd3af4843a19ed588d5d8e776..30b607bf4c45a821ff0a29a045d5e93d24191525 100644 (file)
@@ -7,6 +7,8 @@ import Options
 from TaskGen import feature, before, after
 from samba_utils import *
 
+O755 = 493
+
 @feature('install_bin')
 @after('apply_core')
 @before('apply_link')
@@ -41,7 +43,7 @@ def install_binary(self):
     # tell waf to install the right binary
     bld.install_as(os.path.join(install_path, orig_target),
                    os.path.join(self.path.abspath(bld.env), self.target),
-                   chmod=0755)
+                   chmod=O755)
 
 
 
index 8a8a7e39752fa60f2883757f2767711a669562b5..a527e811fab931a9da831cc3ecee2af0d773da1c 100644 (file)
@@ -220,7 +220,7 @@ def subst_vars_error(string, env):
         if re.match('\$\{\w+\}', v):
             vname = v[2:-1]
             if not vname in env:
-                print "Failed to find variable %s in %s" % (vname, string)
+                print("Failed to find variable %s in %s" % (vname, string))
                 sys.exit(1)
             v = env[vname]
         out.append(v)
@@ -356,7 +356,7 @@ def RUN_COMMAND(cmd,
         return os.WEXITSTATUS(status)
     if os.WIFSIGNALED(status):
         return - os.WTERMSIG(status)
-    print "Unknown exit reason %d for command: %s" (status, cmd)
+    print("Unknown exit reason %d for command: %s" (status, cmd))
     return -1
 
 
@@ -434,7 +434,7 @@ def RECURSE(ctx, directory):
         return ctx.sub_config(relpath)
     if ctxclass == 'BuildContext':
         return ctx.add_subdirs(relpath)
-    print 'Unknown RECURSE context class', ctxclass
+    print('Unknown RECURSE context class', ctxclass)
     raise
 Options.Handler.RECURSE = RECURSE
 Build.BuildContext.RECURSE = RECURSE
index a28f1ebb79f36e5cff9677b7317953acb836162d..75639d47ab032b0f57683f9ecefb6ae2cb423972 100644 (file)
@@ -25,6 +25,8 @@ import irixcc
 import generic_cc
 import samba_dist
 
+O644 = 420
+
 # some systems have broken threading in python
 if os.environ.get('WAF_NOTHREADS') == '1':
     import nothreads
@@ -523,7 +525,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None):
 Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT
 
 
-def install_file(bld, destdir, file, chmod=0644, flat=False,
+def install_file(bld, destdir, file, chmod=O644, flat=False,
                  python_fixup=False, destname=None, base_name=None):
     '''install a file'''
     destdir = bld.EXPAND_VARIABLES(destdir)
@@ -545,7 +547,7 @@ def install_file(bld, destdir, file, chmod=0644, flat=False,
     bld.install_as(dest, file, chmod=chmod)
 
 
-def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
+def INSTALL_FILES(bld, destdir, files, chmod=O644, flat=False,
                   python_fixup=False, destname=None, base_name=None):
     '''install a set of files'''
     for f in TO_LIST(files):
@@ -555,7 +557,7 @@ def INSTALL_FILES(bld, destdir, files, chmod=0644, flat=False,
 Build.BuildContext.INSTALL_FILES = INSTALL_FILES
 
 
-def INSTALL_WILDCARD(bld, destdir, pattern, chmod=0644, flat=False,
+def INSTALL_WILDCARD(bld, destdir, pattern, chmod=O644, flat=False,
                      python_fixup=False, exclude=None, trim_path=None):
     '''install a set of files matching a wildcard pattern'''
     files=TO_LIST(bld.path.ant_glob(pattern))
@@ -623,7 +625,7 @@ def subst_at_vars(task):
             if not vname in task.env and vname.upper() in task.env:
                 vname = vname.upper()
             if not vname in task.env:
-                print "Unknown substitution %s in %s" % (v, task.name)
+                print("Unknown substitution %s in %s" % (v, task.name))
                 raise
             v = SUBST_VARS_RECURSIVE(task.env[vname], task.env)
             # now we back substitute the allowed pc vars
index 6d9a95795d42d7814a331d28ec1e1109fe8f241d..aa00e591d1028895b515e6e4e698738442a11c44 100644 (file)
@@ -8,9 +8,7 @@ def set_options(opt):
                    action="store_true", dest='enable_socket_wrapper', default=False)
 
 def configure(conf):
-    if (Options.options.enable_socket_wrapper or
-       Options.options.developer or
-       Options.options.enable_selftest):
+    if (Options.options.enable_socket_wrapper or Options.options.developer or Options.options.enable_selftest):
         conf.DEFINE('SOCKET_WRAPPER', 1)
-       conf.ADD_GLOBAL_DEPENDENCY('SOCKET_WRAPPER')
+    conf.ADD_GLOBAL_DEPENDENCY('SOCKET_WRAPPER')
 
index 8bd196f8d3b1dd054febffec6473370f4fe95a12..ae3a4f2e058f91ceaa3b1a805219ae26a2aa5aaa 100644 (file)
@@ -68,7 +68,7 @@ for (define, msg, code, headers) in statfs_types:
         break
 
 if not found_statfs:
-    print "FATAL: Failed to find a statfs method"
+    print("FATAL: Failed to find a statfs method")
     raise
 
 
index 9892fd646b4323a1a303534cdbf12512460bdd49..55ca7537c8f5b06f9c6e5bcc482526be9dc124e4 100644 (file)
@@ -10,7 +10,7 @@ external_libs = {
 
 list = []
 
-for module, package in external_libs.iteritems():
+for module, package in external_libs.items():
     try:
         __import__(module)
     except ImportError:
index f8d12c1c07920527fbc532660874546739603413..872e2385de28d1ae88ea95a8052dac378b7a29cf 100644 (file)
@@ -16,9 +16,9 @@ def configure(conf):
     # yapp is used for building the parser
     conf.find_program('yapp', var='YAPP')
 
-
+O755 = 493
 def build(bld):
-    bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=0755)
+    bld.INSTALL_FILES('${BINDIR}', 'pidl', chmod=O755)
 
     bld.RECURSE('lib')
 
index 835fc64ad0b126758a741672c28ee7b4cdab49f8..7a9f419addb5940d45100e7478e3ce9365a47455 100644 (file)
@@ -62,7 +62,7 @@ def get_varname(v):
     if v.startswith('with-'):
         v = v[5:]
     v = v.upper()
-    v = string.replace(v, '-', '_')
+    v = v.replace('-', '_')
     return v
 
 
@@ -101,7 +101,7 @@ def configure(conf):
 
     if (not Options.options.ENABLE_FHS and
         (conf.env.PREFIX == '/usr' or conf.env.PREFIX == '/usr/local')):
-        print "ERROR: Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)"
+        print("ERROR: Don't install directly under /usr or /usr/local without using the FHS option (--enable-fhs)")
         sys.exit(1)
 
 
index d48f24c68192bc32244c2ae5ba0f489ff80c8c9c..5911364ce30ee4ba7c2f35934e5492857b70c274 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
+O755 = 493
 bld.INSTALL_FILES('${SBINDIR}','bin/upgradeprovision bin/samba_dnsupdate',
-                  chmod=0755, python_fixup=True, flat=True)
+                  chmod=O755, python_fixup=True, flat=True)
 
 
index 5f4216f0e26a70915e9c9eb52c9a5b106697b00e..a36b93561e8534e340ff8ff001b2393a74f1613a 100644 (file)
@@ -49,7 +49,7 @@ def cmd_testonly(opt):
     if (not CONFIG_SET(opt, 'NSS_WRAPPER') or
         not CONFIG_SET(opt, 'UID_WRAPPER') or
         not CONFIG_SET(opt, 'SOCKET_WRAPPER')):
-        print "ERROR: You must use --enable-selftest to enable selftest"
+        print("ERROR: You must use --enable-selftest to enable selftest")
         sys.exit(1)
 
     env.TESTS  = Options.options.TESTS
@@ -73,12 +73,12 @@ def cmd_testonly(opt):
         env.FILTER_OPTIONS = '${FILTER_XFAIL} | ${FORMAT_TEST_OUTPUT}'
 
     if Options.options.VALGRIND:
-       os.environ['VALGRIND'] = 'valgrind -q --num-callers=30'
+        os.environ['VALGRIND'] = 'valgrind -q --num-callers=30'
         if Options.options.VALGRINDLOG is not None:
             os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG
 
     if Options.options.VALGRIND_SERVER:
-       os.environ['SAMBA_VALGRIND'] = 'xterm -n server -e ../selftest/valgrind_run A=B '
+        os.environ['SAMBA_VALGRIND'] = 'xterm -n server -e ../selftest/valgrind_run A=B '
 
     env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
 
@@ -95,7 +95,7 @@ def cmd_testonly(opt):
     cmd = '(${PERL} ../selftest/selftest.pl --prefix=${SELFTEST_PREFIX} --builddir=. --srcdir=. --exclude=./selftest/skip --testlist="./selftest/tests.sh|" ${OPTIONS} --socket-wrapper ${TESTS} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS}'
     cmd = EXPAND_VARIABLES(opt, cmd)
 
-    print "test: running %s" % cmd
+    print("test: running %s" % cmd)
     ret = RUN_COMMAND(cmd, env=env)
     if ret != 0:
         print("ERROR: test failed with exit code %d" % ret)
index ea06750aee9f5958c0c3bd7ce5622fa4cffa6618..59112b8f36866b3456c128abd583bdd44991e0fd 100644 (file)
@@ -3,7 +3,8 @@
 bld.INSTALL_WILDCARD('${SETUPDIR}', 'ad-schema/*.txt')
 bld.INSTALL_WILDCARD('${SETUPDIR}', 'display-specifiers/*.txt')
 
-bld.INSTALL_FILES('${SBINDIR}','provision', chmod=0755, python_fixup=True)
+O755 = 493
+bld.INSTALL_FILES('${SBINDIR}','provision', chmod=O755, python_fixup=True)
 
 bld.INSTALL_FILES('${PRIVATEDIR}', 'dns_update_list')
 
index a1ca61f0a12c72b24818ce0867f0987562ce477b..d40d4343971990f7dd97164d0731b38a626916b8 100644 (file)
@@ -89,7 +89,7 @@ def etags(ctx):
     import Utils
     source_root = os.path.dirname(Utils.g_module.root_path)
     cmd = 'etags $(find %s/.. -name "*.[ch]")' % source_root
-    print "Running: %s" % cmd
+    print("Running: %s" % cmd)
     os.system(cmd)
 
 def ctags(ctx):
@@ -97,7 +97,7 @@ def ctags(ctx):
     import Utils
     source_root = os.path.dirname(Utils.g_module.root_path)
     cmd = 'ctags $(find %s/.. -name "*.[ch]" | grep -v "*_proto\.h")' % source_root
-    print "Running: %s" % cmd
+    print("Running: %s" % cmd)
     os.system(cmd)
 
 # putting this here enabled build in the list
@@ -110,7 +110,7 @@ def build(bld):
 def pydoctor(ctx):
     '''build python apidocs'''
     cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=Samba --project-url=http://www.samba.org --make-html --docformat=restructuredtext --add-package bin/python/samba'
-    print "Running: %s" % cmd
+    print("Running: %s" % cmd)
     os.system(cmd)
 
 def wafdocs(ctx):
@@ -120,10 +120,10 @@ def wafdocs(ctx):
     list = recursive_dirlist('../buildtools/wafsamba', '.', pattern='*.py')
 
     cmd='LD_LIBRARY_PATH=bin/shared PYTHONPATH=bin/python pydoctor --project-name=wafsamba --project-url=http://www.samba.org --make-html --docformat=restructuredtext'
-    print list
+    print(list)
     for f in list:
         cmd += ' --add-module %s' % f
-    print "Running: %s" % cmd
+    print("Running: %s" % cmd)
     os.system(cmd)