From 7f3116a63d7d91f4c0d26adf8fcdef0a5a957971 Mon Sep 17 00:00:00 2001 From: Thomas Nagy Date: Thu, 8 Apr 2010 07:45:46 +1000 Subject: build: allow the waf build to work with python 3.0 and 3.1 Python 3.x is a bit fussier about print statements and indentation. Signed-off-by: Andrew Tridgell --- buildtools/wafsamba/samba_autoconf.py | 2 +- buildtools/wafsamba/samba_deps.py | 21 ++++++++++----------- buildtools/wafsamba/samba_install.py | 4 +++- buildtools/wafsamba/samba_utils.py | 6 +++--- buildtools/wafsamba/wafsamba.py | 10 ++++++---- lib/socket_wrapper/wscript | 6 ++---- lib/util/wscript_configure | 2 +- lib/wscript_build | 2 +- pidl/wscript | 4 ++-- source4/dynconfig/wscript | 4 ++-- source4/scripting/wscript_build | 3 ++- source4/selftest/wscript | 8 ++++---- source4/setup/wscript_build | 3 ++- source4/wscript | 10 +++++----- 14 files changed, 44 insertions(+), 41 deletions(-) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index d1b43d4e8a..32c7463981 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -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) diff --git a/buildtools/wafsamba/samba_deps.py b/buildtools/wafsamba/samba_deps.py index 08a24db5bb..be77d2c611 100644 --- a/buildtools/wafsamba/samba_deps.py +++ b/buildtools/wafsamba/samba_deps.py @@ -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): diff --git a/buildtools/wafsamba/samba_install.py b/buildtools/wafsamba/samba_install.py index 2f861616c1..30b607bf4c 100644 --- a/buildtools/wafsamba/samba_install.py +++ b/buildtools/wafsamba/samba_install.py @@ -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) diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 8a8a7e3975..a527e811fa 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -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 diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index a28f1ebb79..75639d47ab 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -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 diff --git a/lib/socket_wrapper/wscript b/lib/socket_wrapper/wscript index 6d9a95795d..aa00e591d1 100644 --- a/lib/socket_wrapper/wscript +++ b/lib/socket_wrapper/wscript @@ -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') diff --git a/lib/util/wscript_configure b/lib/util/wscript_configure index 8bd196f8d3..ae3a4f2e05 100644 --- a/lib/util/wscript_configure +++ b/lib/util/wscript_configure @@ -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 diff --git a/lib/wscript_build b/lib/wscript_build index 9892fd646b..55ca7537c8 100644 --- a/lib/wscript_build +++ b/lib/wscript_build @@ -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: diff --git a/pidl/wscript b/pidl/wscript index f8d12c1c07..872e2385de 100644 --- a/pidl/wscript +++ b/pidl/wscript @@ -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') diff --git a/source4/dynconfig/wscript b/source4/dynconfig/wscript index 835fc64ad0..7a9f419add 100644 --- a/source4/dynconfig/wscript +++ b/source4/dynconfig/wscript @@ -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) diff --git a/source4/scripting/wscript_build b/source4/scripting/wscript_build index d48f24c681..5911364ce3 100644 --- a/source4/scripting/wscript_build +++ b/source4/scripting/wscript_build @@ -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) diff --git a/source4/selftest/wscript b/source4/selftest/wscript index 5f4216f0e2..a36b93561e 100644 --- a/source4/selftest/wscript +++ b/source4/selftest/wscript @@ -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) diff --git a/source4/setup/wscript_build b/source4/setup/wscript_build index ea06750aee..59112b8f36 100644 --- a/source4/setup/wscript_build +++ b/source4/setup/wscript_build @@ -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') diff --git a/source4/wscript b/source4/wscript index a1ca61f0a1..d40d434397 100644 --- a/source4/wscript +++ b/source4/wscript @@ -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) -- cgit