def write_code_as_pyc(fname, code): st = os.stat(fname) timestamp = long_type(st.st_mtime) cfile = get_bytecode_path(fname) try: os.makedirs(os.path.dirname(cfile)) except (IOError, OSError): pass with builtins.open(cfile, 'wb') as fc: fc.write(MAGIC) wr_long(fc, timestamp) if PY3: wr_long(fc, st.st_size) marshal.dump(code, fc)
def write_code_as_pyc(fname, code): st = os.stat(fname) timestamp = long_type(st.st_mtime) cfile = get_bytecode_path(fname) try: os.makedirs(os.path.dirname(cfile)) except (IOError, OSError): pass with builtins.open(cfile, 'wb') as fc: fc.write(MAGIC) wr_long(fc, timestamp) if PY3: wr_long(fc, st.st_size) marshal.dump(code, fc)
def write_code_as_pyc(fname, code): st = os.stat(fname) timestamp = long_type(st.st_mtime) cfile = get_bytecode_path(fname) try: os.makedirs(os.path.dirname(cfile)) except (IOError, OSError): pass with builtins.open(cfile, 'wb') as fc: fc.write(MAGIC) if PY37: # With PEP 552, the header structure has a new flags field # that we need to fill in. All zeros preserve the legacy # behaviour, but should we implement reproducible builds, # this is where we'd add the information. wr_long(fc, 0) wr_long(fc, timestamp) if PY3: wr_long(fc, st.st_size) marshal.dump(code, fc)
def write_code_as_pyc(fname, code): st = os.stat(fname) timestamp = long_type(st.st_mtime) cfile = get_bytecode_path(fname) try: os.makedirs(os.path.dirname(cfile)) except (IOError, OSError): pass with builtins.open(cfile, 'wb') as fc: fc.write(MAGIC) if PY37: # With PEP 552, the header structure has a new flags field # that we need to fill in. All zeros preserve the legacy # behaviour, but should we implement reproducible builds, # this is where we'd add the information. wr_long(fc, 0) wr_long(fc, timestamp) if PY3: wr_long(fc, st.st_size) marshal.dump(code, fc)