Permalink
Browse files

Make build scripts compile under OPy.

They just needed Python 3-style print functions.
  • Loading branch information...
Andy Chu
Andy Chu committed Mar 17, 2018
1 parent 8addbf5 commit 72e4d13c38cd8aaaa9f7143561e5214308b60c3d
Showing with 17 additions and 14 deletions.
  1. +7 −6 build/app_deps.py
  2. +2 −1 build/app_deps_test.py
  3. +7 −6 build/runpy_deps.py
  4. +1 −1 opy/build.sh
View
@@ -1,4 +1,5 @@
#!/usr/bin/python -S
from __future__ import print_function
"""
py_deps.py
@@ -21,7 +22,7 @@
def log(msg, *args):
if args:
msg = msg % args
print >>sys.stderr, '\t', msg
print('\t', msg, file=sys.stderr)
def ImportMain(main_module, old_modules):
@@ -118,11 +119,11 @@ def main(argv):
with open(py_out_path, 'w') as py_out, open(c_out_path, 'w') as c_out:
for mod_type, x, y in FilterModules(modules):
if mod_type == PY_MODULE:
print >>py_out, x, y
print >>py_out, x + 'c', y + 'c' # .pyc goes in bytecode.zip too
print(x, y, file=py_out)
print(x + 'c', y + 'c', file=py_out) # .pyc goes in bytecode.zip too
elif mod_type == C_MODULE:
print >>c_out, x, y # mod_name, full_path
print(x, y, file=c_out) # mod_name, full_path
else:
raise AssertionError(mod_type)
@@ -133,7 +134,7 @@ def main(argv):
if mod_type == PY_MODULE:
opy_input = full_path
opy_output = rel_path + 'c' # output is .pyc
print opy_input, opy_output
print(opy_input, opy_output)
else:
raise RuntimeError('Invalid action %r' % action)
@@ -143,5 +144,5 @@ def main(argv):
try:
sys.exit(main(sys.argv))
except RuntimeError as e:
print >>sys.stderr, '%s: %s' % (sys.argv[0], e.args[0])
print('%s: %s' % (sys.argv[0], e.args[0]), file=sys.stderr)
sys.exit(1)
View
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
"""
app_deps_test.py: Tests for app_deps.py
"""
@@ -19,7 +20,7 @@ def testModules(self):
'/home/andy/dev/simplejson-2.1.5/simplejson/__init__.py')
]
for mod_type, x, y in app_deps.FilterModules(pairs):
print mod_type, x, y
print(mod_type, x, y)
if __name__ == '__main__':
View
@@ -1,4 +1,5 @@
#!/usr/bin/python -S
from __future__ import print_function
"""
runpy_deps.py
@@ -64,25 +65,25 @@ def main(argv):
with open(py_out_path, 'w') as py_out, open(c_out_path, 'w') as c_out:
for mod_type, x, y in FilterModules(sys.modules, stdlib_dir):
if mod_type == PY_MODULE:
print >>py_out, x, y
print >>py_out, x + 'c', y + 'c' # .pyc goes in bytecode.zip too
print(x, y, file=py_out)
print(x + 'c', y + 'c', file=py_out) # .pyc goes in bytecode.zip too
pass
elif mod_type == C_MODULE:
print >>c_out, x, y # mod_name, full_path
print(x, y, file=c_out) # mod_name, full_path
else:
raise AssertionError(mod_type)
print >>sys.stderr, '-- Wrote %s and %s' % (py_out_path, c_out_path)
print('-- Wrote %s and %s' % (py_out_path, c_out_path), file=sys.stderr)
elif action == 'py':
for mod_type, full_path, rel_path in \
FilterModules(sys.modules, stdlib_dir):
if mod_type == PY_MODULE:
opy_input = full_path
opy_output = rel_path + 'c' # output is .pyc
print opy_input, opy_output
print(opy_input, opy_output)
else:
raise RuntimeError('Invalid action %r' % action)
@@ -92,5 +93,5 @@ def main(argv):
try:
main(sys.argv)
except RuntimeError as e:
print >>sys.stderr, '%s: %s' % (sys.argv[0], e.args[0])
print('%s: %s' % (sys.argv[0], e.args[0]), file=sys.stderr)
sys.exit(1)
View
@@ -54,7 +54,7 @@ _compile-tree() {
elif test $version = ccompile; then
_ccompile-one $src_tree/${rel_path} $dest
elif test $version = opy; then
_compile-one $src_tree/${rel_path} $dest
$THIS_DIR/../bin/opyc compile $src_tree/${rel_path} $dest
else
die "bad"
fi

0 comments on commit 72e4d13

Please sign in to comment.