def get_entry_point(self, config): global space1, space2, w_entry_point_1, w_entry_point_2 space1 = StdObjSpace(config) space2 = StdObjSpace(config) space1.setattr(space1.getbuiltinmodule('sys'), space1.wrap('pypy_space'), space1.wrap(1)) space2.setattr(space2.getbuiltinmodule('sys'), space2.wrap('pypy_space'), space2.wrap(2)) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') w_dict = space1.newdict() space1.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_1 = space1.getitem(w_dict, space1.wrap('entry_point')) w_dict = space2.newdict() space2.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_2 = space2.getitem(w_dict, space2.wrap('entry_point')) # sanity-check: call the entry point res = entry_point(["pypy", "app_basic_example.py"]) assert res == 0 res = entry_point(["pypy", "--space2", "app_basic_example.py"]) assert res == 0 return entry_point, None, PyPyAnnotatorPolicy()
def run_module(module_name, args, space=None): """Implements PEP 338 'Executing modules as scripts', overwriting sys.argv[1:] using `args` and executing the module `module_name`. sys.argv[0] always is `module_name`. Delegates the real work to the runpy module provided as the reference implementation. """ if space is None: from pypy.objspace.std.objspace import StdObjSpace space = StdObjSpace() argv = [module_name] if args is not None: argv.extend(args) space.setitem(space.sys.w_dict, space.newtext('argv'), space.wrap(argv)) w_import = space.builtin.get('__import__') runpy = space.call_function(w_import, space.newtext('runpy')) w_run_module = space.getitem(runpy.w_dict, space.newtext('run_module')) return space.call_function(w_run_module, space.newtext(module_name), space.w_None, space.newtext('__main__'), space.w_True)
def get_entry_point(self, config): global space1, space2, w_entry_point_1, w_entry_point_2 space1 = StdObjSpace(config) space2 = StdObjSpace(config) space1.setattr(space1.getbuiltinmodule("sys"), space1.wrap("pypy_space"), space1.wrap(1)) space2.setattr(space2.getbuiltinmodule("sys"), space2.wrap("pypy_space"), space2.wrap(2)) # manually imports app_main.py filename = os.path.join(this_dir, "app_main.py") w_dict = space1.newdict() space1.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_1 = space1.getitem(w_dict, space1.wrap("entry_point")) w_dict = space2.newdict() space2.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_2 = space2.getitem(w_dict, space2.wrap("entry_point")) return entry_point, None, PyPyAnnotatorPolicy()
def get_entry_point(self, config): global space1, space2, w_entry_point_1, w_entry_point_2 space1 = StdObjSpace(config) space2 = StdObjSpace(config) space1.setattr(space1.getbuiltinmodule('sys'), space1.wrap('pypy_space'), space1.wrap(1)) space2.setattr(space2.getbuiltinmodule('sys'), space2.wrap('pypy_space'), space2.wrap(2)) # manually imports app_main.py filename = os.path.join(this_dir, 'app_main.py') w_dict = space1.newdict() space1.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_1 = space1.getitem(w_dict, space1.wrap('entry_point')) w_dict = space2.newdict() space2.exec_(open(filename).read(), w_dict, w_dict) w_entry_point_2 = space2.getitem(w_dict, space2.wrap('entry_point')) return entry_point, None, PyPyAnnotatorPolicy()
def wrap(self, x): w_res = StdObjSpace.wrap(self, x) self.dumper.dump_returned_wrapped(' wrap', w_res) return w_res
def wrap(self, x): w_res = StdObjSpace.wrap(self, x) self.dumper.dump_returned_wrapped(' wrap', w_res) return w_res