summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-10-21 19:20:33 (GMT)
committerEvan Martin <martine@danga.com>2012-10-21 19:20:33 (GMT)
commit56f1ffcc55925d6b499bba9eb90ec2eca4bfcd25 (patch)
treec302b14bc96e7c25142e91c08555feb5f6a2a181
parentb022e789fd9b087e0acbeca502d586d49dd3e2f2 (diff)
parentf4b1133d5c36b531a39606da4e1cadc38a784a2e (diff)
downloadNinja-56f1ffcc55925d6b499bba9eb90ec2eca4bfcd25.zip
Ninja-56f1ffcc55925d6b499bba9eb90ec2eca4bfcd25.tar.gz
Ninja-56f1ffcc55925d6b499bba9eb90ec2eca4bfcd25.tar.bz2
Merge pull request #450 from zchothia/zc/py3k
Add support for Python 3
-rwxr-xr-xbootstrap.py19
-rwxr-xr-xconfigure.py8
-rw-r--r--misc/ninja_syntax.py2
-rwxr-xr-xmisc/ninja_test.py6
4 files changed, 22 insertions, 13 deletions
diff --git a/bootstrap.py b/bootstrap.py
index 3032a9b..7dfc543 100755
--- a/bootstrap.py
+++ b/bootstrap.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from __future__ import print_function
+
from optparse import OptionParser
import sys
import os
@@ -44,11 +46,12 @@ if sys.platform.startswith('freebsd'):
cflags.append('-I/usr/local/include')
ldflags.append('-L/usr/local/lib')
-print 'Building ninja manually...'
+print('Building ninja manually...')
try:
os.mkdir('build')
-except OSError, e:
+except OSError:
+ e = sys.exc_info()[1]
if e.errno != errno.EEXIST:
raise
@@ -103,7 +106,7 @@ else:
args.extend(['-o', binary])
if options.verbose:
- print ' '.join(args)
+ print(' '.join(args))
run(args)
@@ -112,7 +115,7 @@ if options.verbose:
verbose = ['-v']
if sys.platform.startswith('win32'):
- print 'Building ninja using itself...'
+ print('Building ninja using itself...')
run([sys.executable, 'configure.py', '--with-ninja=%s' % binary] +
conf_args)
run(['./' + binary] + verbose)
@@ -124,17 +127,17 @@ if sys.platform.startswith('win32'):
for obj in glob.glob('*.obj'):
os.unlink(obj)
- print """
+ print("""
Done!
Note: to work around Windows file locking, where you can't rebuild an
in-use binary, to run ninja after making any changes to build ninja itself
you should run ninja.bootstrap instead. Your build is also configured to
use ninja.bootstrap.exe as the MSVC helper; see the --with-ninja flag of
-the --help output of configure.py."""
+the --help output of configure.py.""")
else:
- print 'Building ninja using itself...'
+ print('Building ninja using itself...')
run([sys.executable, 'configure.py'] + conf_args)
run(['./' + binary] + verbose)
os.unlink(binary)
- print 'Done!'
+ print('Done!')
diff --git a/configure.py b/configure.py
index cb0d45e..e41cf4e 100755
--- a/configure.py
+++ b/configure.py
@@ -19,6 +19,8 @@
Projects that use ninja themselves should either write a similar script
or use a meta-build system that supports Ninja output."""
+from __future__ import print_function
+
from optparse import OptionParser
import os
import sys
@@ -50,7 +52,7 @@ parser.add_option('--with-ninja', metavar='NAME',
default="ninja")
(options, args) = parser.parse_args()
if args:
- print 'ERROR: extra unparsed command-line arguments:', args
+ print('ERROR: extra unparsed command-line arguments:', args)
sys.exit(1)
platform = options.platform
@@ -256,7 +258,7 @@ if has_re2c():
n.build(src('depfile_parser.cc'), 're2c', src('depfile_parser.in.cc'))
n.build(src('lexer.cc'), 're2c', src('lexer.in.cc'))
else:
- print ("warning: A compatible version of re2c (>= 0.11.3) was not found; "
+ print("warning: A compatible version of re2c (>= 0.11.3) was not found; "
"changes to src/*.in.cc will not affect your build.")
n.newline()
@@ -436,4 +438,4 @@ if host == 'linux':
n.build('all', 'phony', all_targets)
-print 'wrote %s.' % BUILD_FILENAME
+print('wrote %s.' % BUILD_FILENAME)
diff --git a/misc/ninja_syntax.py b/misc/ninja_syntax.py
index 66babbe..3572dd9 100644
--- a/misc/ninja_syntax.py
+++ b/misc/ninja_syntax.py
@@ -71,7 +71,7 @@ class Writer(object):
if variables:
if isinstance(variables, dict):
- iterator = variables.iteritems()
+ iterator = iter(variables.items())
else:
iterator = iter(variables)
diff --git a/misc/ninja_test.py b/misc/ninja_test.py
index b56033e..2aef7ff 100755
--- a/misc/ninja_test.py
+++ b/misc/ninja_test.py
@@ -15,7 +15,11 @@
# limitations under the License.
import unittest
-from StringIO import StringIO
+
+try:
+ from StringIO import StringIO
+except ImportError:
+ from io import StringIO
import ninja_syntax