def cache_from_source(space, pathname, w_debug_override=None): """cache_from_source(path, [debug_override]) -> path Given the path to a .py file, return the path to its .pyc/.pyo file. The .py file does not need to exist; this simply returns the path to the .pyc/.pyo file calculated as if the .py file were imported. The extension will be .pyc unless __debug__ is not defined, then it will be .pyo. If debug_override is not None, then it must be a boolean and is taken as the value of __debug__ instead.""" return space.fsdecode( space.wrapbytes(importing.make_compiled_pathname(pathname)))
def cache_from_source(space, pathname, w_debug_override=None): """cache_from_source(path, [debug_override]) -> path Given the path to a .py file, return the path to its .pyc/.pyo file. The .py file does not need to exist; this simply returns the path to the .pyc/.pyo file calculated as if the .py file were imported. The extension will be .pyc unless __debug__ is not defined, then it will be .pyo. If debug_override is not None, then it must be a boolean and is taken as the value of __debug__ instead.""" return space.fsdecode(space.wrapbytes( importing.make_compiled_pathname(pathname)))
def PyImport_ExecCodeModuleEx(space, name, w_code, pathname): """Like PyImport_ExecCodeModule(), but the __file__ attribute of the module object is set to pathname if it is non-NULL.""" code = space.interp_w(PyCode, w_code) w_name = space.wrap(rffi.charp2str(name)) if pathname: pathname = rffi.charp2str(pathname) else: pathname = code.co_filename w_mod = importing.add_module(space, w_name) space.setattr(w_mod, space.wrap('__file__'), space.wrap(pathname)) cpathname = importing.make_compiled_pathname(pathname) importing.exec_code_module(space, w_mod, code, pathname, cpathname) return w_mod
def PyImport_ExecCodeModuleEx(space, name, w_code, pathname): """Like PyImport_ExecCodeModule(), but the __file__ attribute of the module object is set to pathname if it is non-NULL.""" code = space.interp_w(PyCode, w_code) w_name = space.wrap(rffi.charp2str(name)) if pathname: pathname = rffi.charp2str(pathname) else: pathname = code.co_filename w_mod = importing.add_module(space, w_name) space.setattr(w_mod, space.wrap("__file__"), space.wrap(pathname)) cpathname = importing.make_compiled_pathname(pathname) importing.exec_code_module(space, w_mod, code, pathname, cpathname) return w_mod
def f(): return importing.make_compiled_pathname('abc/foo.py')