python-cryptography: bump to version 1.7.2
[buildroot-gz.git] / support / scripts / pycompile.py
blobfde711a42a2f899c3b27af94e530ba801a1bf2de
1 #!/usr/bin/env python
3 # Wrapper for python2 and python3 around compileall to raise exception
4 # when a python byte code generation failed.
6 # Inspired from:
7 # http://stackoverflow.com/questions/615632/how-to-detect-errors-from-compileall-compile-dir
9 from __future__ import print_function
10 import sys
11 import py_compile
12 import compileall
14 class ReportProblem:
15 def __nonzero__(self):
16 type, value, traceback = sys.exc_info()
17 if type is not None and issubclass(type, py_compile.PyCompileError):
18 print("Cannot compile %s" %value.file)
19 raise value
20 return 1
22 report_problem = ReportProblem()
24 compileall.compile_dir(sys.argv[1], quiet=report_problem)