def test_pyc(): """Test pyc compilation.""" f = tempfile.NamedTemporaryFile(suffix='.hy', delete=False) f.write(b'(defn pyctest [s] (+ "X" s "Y"))') f.close() write_hy_as_pyc(f.name) os.remove(f.name) cfile = get_bytecode_path(f.name) mod = imp.load_compiled('pyc', cfile) os.remove(cfile) assert mod.pyctest('Foo') == 'XFooY'
def test_pyc(): """Test pyc compilation.""" f = tempfile.NamedTemporaryFile(suffix='.hy', delete=False) f.write(b'(defn pyctest [s] s)') f.close() write_hy_as_pyc(f.name) os.unlink(f.name) cfile = "%s.pyc" % f.name[:-len(".hy")] mod = imp.load_compiled('pyc', cfile) os.unlink(cfile) assert mod.pyctest('Foo') == 'Foo'
def hyc_main(): from hy.importer import write_hy_as_pyc parser = argparse.ArgumentParser(prog="hyc") parser.add_argument("files", metavar="FILE", nargs="+", help="file to compile") parser.add_argument("-v", action="version", version=VERSION) options = parser.parse_args(sys.argv[1:]) for file in options.files: try: write_hy_as_pyc(file) print("Compiling %s" % file) except IOError as x: sys.stderr.write("hyc: Can't open file '%s': [Errno %d] %s\n" % (x.filename, x.errno, x.strerror)) sys.exit(x.errno)
def hyc_main(): from hy.importer import write_hy_as_pyc parser = argparse.ArgumentParser(prog="hyc") parser.add_argument("files", metavar="FILE", nargs='+', help="file to compile") parser.add_argument("-v", action="version", version=VERSION) options = parser.parse_args(sys.argv[1:]) for file in options.files: try: write_hy_as_pyc(file) print("Compiling %s" % file) except IOError as x: sys.stderr.write("hyc: Can't open file '%s': [Errno %d] %s\n" % (x.filename, x.errno, x.strerror)) sys.exit(x.errno)
def hyc_main(): from hy.importer import write_hy_as_pyc write_hy_as_pyc(sys.argv[1])