From ffe488ee0bd8c295815de05325523a4f522e5fa9 Mon Sep 17 00:00:00 2001 From: Fernando Perez Date: Sat, 14 Apr 2012 01:26:34 -0700 Subject: [PATCH] Emergency fix for py3 breakage introduced in 576f6f (merge of #1538) Unicode literals (u'foo') aren't valid in Python 3.{1,2} (they will be again in 3.3, and I failed to notice this. This is a quick fix, will discuss further on-list. But I want master to remain working for py3 users. --- setupbase.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setupbase.py b/setupbase.py index 8803e76ce..fe6e35701 100644 --- a/setupbase.py +++ b/setupbase.py @@ -45,6 +45,9 @@ def oscmd(s): print(">", s) os.system(s) +# Py3 compatibility hacks, without assuming IPython itself is installed with +# the full py3compat machinery. + try: execfile except NameError: @@ -52,6 +55,11 @@ except NameError: locs = locs or globs exec(compile(open(fname).read(), fname, "exec"), globs, locs) +try: + unicode +except NameError: + unicode = str + # A little utility we'll need below, since glob() does NOT allow you to do # exclusion on multiple endings! def file_doesnt_endwith(test,endings): @@ -389,8 +397,8 @@ def record_commit_info(pkg_dir, build_cmd=build_py): # We write the installation commit even if it's empty out_pth = pjoin(self.build_lib, pkg_dir, 'utils', '_sysinfo.py') with io.open(out_pth, 'w') as out_file: - out_file.writelines([ - u"# GENERATED BY setup.py\n", - u"commit = '%s'\n" % repo_commit, - ]) + out_file.writelines(map(unicode, [ + '# GENERATED BY setup.py\n', + 'commit = "%s"\n' % repo_commit, + ])) return MyBuildPy