py_compile.py 490 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. from __future__ import print_function, absolute_import, division
  4. import marshal
  5. import sys
  6. def main():
  7. srcpathx, in_fname, out_fname = sys.argv[1:]
  8. srcpath = srcpathx[:-1]
  9. with open(in_fname, 'r') as in_file:
  10. source = in_file.read()
  11. code = compile(source, srcpath, 'exec', dont_inherit=True)
  12. with open(out_fname, 'wb') as out_file:
  13. marshal.dump(code, out_file)
  14. if __name__ == "__main__":
  15. main()