Commits

Alexander Hesse  committed dd8815a

Added /goals for pypy. Moved pypy.tool.progressbar to rpython

  • Participants
  • Parent commits 7cae095
  • Branches split-rpython

Comments (0)

Files changed (10)

File goal/ann_override.py

+# overrides for annotation specific to PyPy codebase
+from rpython.annotator.policy import AnnotatorPolicy, Sig
+# for some reason, model must be imported first,
+# or we create a cycle.
+from rpython.flowspace.model import Constant
+from rpython.annotator import model as annmodel
+from rpython.annotator.bookkeeper import getbookkeeper
+from rpython.annotator import specialize
+from pypy.interpreter import baseobjspace
+
+def isidentifier(s):
+    if not s: return False
+    s = s.replace('_', 'x')
+    return s[0].isalpha() and s.isalnum()
+
+# patch - mostly for debugging, to enforce some signatures
+baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
+                                                             bool)
+
+
+class PyPyAnnotatorPolicy(AnnotatorPolicy):
+    def __init__(pol, single_space=None):
+        pol.lookups = {}
+        pol.lookups_where = {}
+        pol.pypytypes = {}
+        pol.single_space = single_space
+
+    def specialize__wrap(pol,  funcdesc, args_s):
+        from pypy.interpreter.baseobjspace import Wrappable
+        from rpython.annotator.classdef import ClassDef
+        Wrappable_def = funcdesc.bookkeeper.getuniqueclassdef(Wrappable)
+        typ = args_s[1].knowntype
+        if isinstance(typ, ClassDef):
+            assert typ.issubclass(Wrappable_def)
+            typ = Wrappable
+        else:
+            assert not issubclass(typ, Wrappable)
+            assert typ != tuple, "space.wrap(tuple) forbidden; use newtuple()"
+            assert typ != list, "space.wrap(list) forbidden; use newlist()"
+            assert typ != dict, "space.wrap(dict) forbidden; use newdict()"
+            assert typ != object, "degenerated space.wrap(object)"
+            if args_s[0].is_constant() and args_s[1].is_constant():
+                if typ in (str, bool, int, float):
+                    space = args_s[0].const
+                    x = args_s[1].const
+                    def fold():
+                        if typ is str and isidentifier(x):
+                            return space.new_interned_str(x)
+                        else:
+                            return space.wrap(x)
+                    builder = specialize.make_constgraphbuilder(2, factory=fold,
+                                                                srcmodule='<ann_override.wrap>')
+                    return funcdesc.cachedgraph((typ, x), builder=builder)
+        if typ is str:
+            if args_s[1].can_be_None:
+                typ = (None, str)
+        return funcdesc.cachedgraph(typ)
+
+    def _remember_immutable(pol, t, cached):
+        # for jit benefit
+        if cached not in t._immutable_fields_: # accessed this way just
+                                               # for convenience
+            t._immutable_fields_.append(cached)        
+    
+    def attach_lookup(pol, t, attr):
+        cached = "cached_%s" % attr
+        if not t.is_heaptype() and not t.is_cpytype():
+            pol._remember_immutable(t, cached)
+            setattr(t, cached, t._lookup(attr))
+            return True
+        return False
+
+    def attach_lookup_in_type_where(pol, t, attr):
+        cached = "cached_where_%s" % attr
+        if not t.is_heaptype() and not t.is_cpytype():
+            pol._remember_immutable(t, cached)
+            setattr(t, cached, t._lookup_where(attr))
+            return True
+        return False
+
+    def consider_lookup(pol, bookkeeper, attr):
+        from rpython.annotator.classdef import InstanceSource
+        assert attr not in pol.lookups
+        from pypy.objspace.std import typeobject
+        cached = "cached_%s" % attr
+        clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
+        classdesc = clsdef.classdesc
+        classdesc.classdict[cached] = Constant(None)
+        clsdef.add_source_for_attribute(cached, classdesc)
+        for t in pol.pypytypes:
+            if pol.attach_lookup(t, attr):
+                source = InstanceSource(bookkeeper, t)
+                clsdef.add_source_for_attribute(cached, source)
+        pol.lookups[attr] = True
+
+    def consider_lookup_in_type_where(pol, bookkeeper, attr):
+        from rpython.annotator.classdef import InstanceSource
+        assert attr not in pol.lookups_where
+        from pypy.objspace.std import typeobject
+        cached = "cached_where_%s" % attr
+        clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
+        classdesc = clsdef.classdesc
+        classdesc.classdict[cached] = Constant((None, None))
+        clsdef.add_source_for_attribute(cached, classdesc)
+        for t in pol.pypytypes:
+            if pol.attach_lookup_in_type_where(t, attr):
+                source = InstanceSource(bookkeeper, t)
+                clsdef.add_source_for_attribute(cached, source)
+        pol.lookups_where[attr] = True
+
+    def specialize__lookup(pol, funcdesc, args_s):
+        s_space, s_obj, s_name = args_s
+        if s_name.is_constant():
+            attr = s_name.const
+            def builder(translator, func):
+                #print "LOOKUP", attr
+                pol.consider_lookup(funcdesc.bookkeeper, attr)
+                d = {'__name__': '<ann_override_lookup>'}
+                exec CACHED_LOOKUP % {'attr': attr} in d
+                return translator.buildflowgraph(d['lookup_'+attr])
+            return funcdesc.cachedgraph(attr, builder=builder)
+        else:
+            pol.lookups[None] = True
+            return funcdesc.cachedgraph(None) # don't specialize
+
+    def specialize__lookup_in_type_where(pol, funcdesc, args_s):
+        s_space, s_obj, s_name = args_s
+        if s_name.is_constant():
+            attr = s_name.const
+            def builder(translator, func):
+                #print "LOOKUP_IN_TYPE_WHERE", attr
+                pol.consider_lookup_in_type_where(funcdesc.bookkeeper, attr)
+                d = {'__name__': '<ann_override_lookup>'}
+                exec CACHED_LOOKUP_IN_TYPE_WHERE % {'attr': attr} in d
+                return translator.buildflowgraph(d['lookup_in_type_where_'+attr])
+            return funcdesc.cachedgraph(attr, builder=builder)
+        else:
+            pol.lookups_where[None] = True
+            return funcdesc.cachedgraph(None)
+
+    def event(pol, bookkeeper, what, x):
+        from pypy.objspace.std import typeobject
+        if isinstance(x, typeobject.W_TypeObject):
+            from rpython.annotator.classdef import InstanceSource
+            clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
+            pol.pypytypes[x] = True
+            #print "TYPE", x
+            for attr in pol.lookups:
+                if attr and pol.attach_lookup(x, attr):
+                    cached = "cached_%s" % attr
+                    source = InstanceSource(bookkeeper, x)
+                    clsdef.add_source_for_attribute(cached, source)
+            for attr in pol.lookups_where:
+                if attr and pol.attach_lookup_in_type_where(x, attr):
+                    cached = "cached_where_%s" % attr
+                    source = InstanceSource(bookkeeper, x)
+                    clsdef.add_source_for_attribute(cached, source)
+        return
+
+CACHED_LOOKUP = """
+def lookup_%(attr)s(space, w_obj, name):
+    w_type = space.type(w_obj)
+    if not w_type.is_heaptype() and not w_type.is_cpytype():
+        return w_type.cached_%(attr)s
+    return w_type.lookup("%(attr)s")
+"""
+
+CACHED_LOOKUP_IN_TYPE_WHERE = """
+def lookup_in_type_where_%(attr)s(space, w_type, name):
+    if not w_type.is_heaptype() and not w_type.is_cpytype():
+        return w_type.cached_where_%(attr)s
+    return w_type.lookup_where("%(attr)s")
+"""

File goal/multibuild.py

+from pypy.config.pypyoption import get_pypy_config
+from rpython.translator.goal import translate
+from rpython.translator.goal import targetpypystandalone
+from rpython.translator.driver import TranslationDriver
+import os, sys, traceback, random
+
+def longoptfromname(config, name):
+    from pypy.config.makerestdoc import get_cmdline
+    # begin horror
+    h, n = config._cfgimpl_get_home_by_path(name)
+    opt = getattr(h._cfgimpl_descr, n)
+    # end horror
+    cmdline = get_cmdline(opt.cmdline, name)
+    assert cmdline is not None
+    shortest_long_option = 'X'*1000
+    for cmd in cmdline.split():
+        if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
+            shortest_long_option = cmd
+    return shortest_long_option
+
+def exe_name_from_options(config, opts):
+    from pypy.module.sys.version import svn_revision
+
+    backend = config.translation.backend
+    if not backend:
+        backend = 'c'
+    rev = svn_revision()
+
+    nameparts = []
+
+    for opt, v in opts.iteritems():
+        if opt == 'translation.backend':
+            backend = v
+        optname = longoptfromname(config, opt).strip('-')
+        if v is False:
+            optname = 'no-' + optname
+        elif v is not True:
+            optname += '=' + str(v)
+        nameparts.append(optname)
+
+    suffix = ''
+    if nameparts:
+        def k(s):
+            if s.startswith('no-'):
+                return s[3:]
+            else:
+                return s
+        nameparts.sort(key=k)
+        suffix = '-' + '-'.join(nameparts)
+
+    return 'pypy-%s-%d%s'%(backend, rev, suffix)
+
+def _build(config, exe_name):
+    driver = TranslationDriver.from_targetspec(
+        targetpypystandalone.__dict__,
+        config=config)
+    driver.exe_name = exe_name
+    driver.compile()
+
+def build_pypy_with_options(basedir, opts):
+    config = get_pypy_config(translate.OVERRIDES, translating=True)
+
+    try:
+        config.set(**opts)
+    except:
+        return exe_name_from_options(config, opts), "didn't configure"
+
+    exe_name = os.path.join(basedir, exe_name_from_options(config, opts))
+
+    print exe_name,
+    sys.stdout.flush()
+
+    pid = os.fork()
+
+    if pid == 0:
+        logfile = open(exe_name + '-log', 'w')
+        davenull = os.open('/dev/null', os.O_RDONLY)
+        os.dup2(davenull, 0)
+        os.dup2(logfile.fileno(), 1)
+        os.dup2(logfile.fileno(), 2)
+        try:
+            try:
+                r = _build(config, exe_name)
+            finally:
+                logfile.close()
+        except:
+            os._exit(1)
+        else:
+            os._exit(0)
+    else:
+        pid, status = os.waitpid(pid, 0)
+        if status:
+            r = 'failed'
+        else:
+            r = 'succeeded'
+        print r
+        return exe_name, r
+
+def get_options(fname):
+    def gen_opts(sofar, remaining):
+        if not remaining:
+            yield sofar
+        else:
+            for (k, v) in remaining[0]:
+                d2 = sofar.copy()
+                d2[k] = v
+                for d in gen_opts(d2, remaining[1:]):
+                    yield d
+    options = []
+    for line in open(fname):
+        l = []
+        optname, options_ = line.split(':')
+        options.append([(optname.strip(), eval(optval.strip())) for optval in options_.split(',')])
+    return gen_opts({}, options)
+
+
+if __name__ == '__main__':
+    basedir = sys.argv[1]
+    optionsfile = sys.argv[2]
+    results = []
+    options = list(get_options(optionsfile))
+    random.shuffle(options)
+    for opts in options:
+        results.append(build_pypy_with_options(basedir, opts))
+    out = open(os.path.join(basedir, 'results'), 'w')
+    for exe, r in results:
+        print >>out, exe, r

File goal/targetpypystandalone.py

+import py
+
+import os, sys
+
+from pypy.interpreter import gateway
+from pypy.interpreter.error import OperationError
+from rpython.translator.goal.ann_override import PyPyAnnotatorPolicy
+from pypy.config.config import Config, to_optparse, make_dict, SUPPRESS_USAGE
+from pypy.config.config import ConflictConfigError
+from pypy.tool.option import make_objspace
+from pypy.conftest import pypydir
+
+thisdir = py.path.local(__file__).dirpath()
+
+try:
+    this_dir = os.path.dirname(__file__)
+except NameError:
+    this_dir = os.path.dirname(sys.argv[0])
+
+def debug(msg):
+    os.write(2, "debug: " + msg + '\n')
+
+# __________  Entry point  __________
+
+def create_entry_point(space, w_dict):
+    w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
+    w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
+    w_call_finish_gateway = space.wrap(gateway.interp2app(call_finish))
+    w_call_startup_gateway = space.wrap(gateway.interp2app(call_startup))
+    withjit = space.config.objspace.usemodules.pypyjit
+
+    def entry_point(argv):
+        if withjit:
+            from rpython.jit.backend.hlinfo import highleveljitinfo
+            highleveljitinfo.sys_executable = argv[0]
+
+        #debug("entry point starting") 
+        #for arg in argv: 
+        #    debug(" argv -> " + arg)
+        if len(argv) > 2 and argv[1] == '--heapsize':
+            # Undocumented option, handled at interp-level.
+            # It has silently no effect with some GCs.
+            # It works in Boehm and in the semispace or generational GCs
+            # (but see comments in semispace.py:set_max_heap_size()).
+            # At the moment this option exists mainly to support sandboxing.
+            from rpython.rlib import rgc
+            rgc.set_max_heap_size(int(argv[2]))
+            argv = argv[:1] + argv[3:]
+        try:
+            try:
+                space.call_function(w_run_toplevel, w_call_startup_gateway)
+                w_executable = space.wrap(argv[0])
+                w_argv = space.newlist([space.wrap(s) for s in argv[1:]])
+                w_exitcode = space.call_function(w_entry_point, w_executable, w_argv)
+                exitcode = space.int_w(w_exitcode)
+                # try to pull it all in
+            ##    from pypy.interpreter import main, interactive, error
+            ##    con = interactive.PyPyConsole(space)
+            ##    con.interact()
+            except OperationError, e:
+                debug("OperationError:")
+                debug(" operror-type: " + e.w_type.getname(space))
+                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
+                return 1
+        finally:
+            try:
+                space.call_function(w_run_toplevel, w_call_finish_gateway)
+            except OperationError, e:
+                debug("OperationError:")
+                debug(" operror-type: " + e.w_type.getname(space))
+                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
+                return 1
+        return exitcode
+    return entry_point
+
+def call_finish(space):
+    space.finish()
+
+def call_startup(space):
+    space.startup()
+
+# _____ Define and setup target ___
+
+# for now this will do for option handling
+
+class PyPyTarget(object):
+
+    usage = SUPPRESS_USAGE
+
+    take_options = True
+
+    def opt_parser(self, config):
+        parser = to_optparse(config, useoptions=["objspace.*"],
+                             parserkwargs={'usage': self.usage})
+        return parser
+
+    def handle_config(self, config, translateconfig):
+        if (not translateconfig.help and
+            translateconfig._cfgimpl_value_owners['opt'] == 'default'):
+            raise Exception("You have to specify the --opt level.\n"
+                    "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .")
+        self.translateconfig = translateconfig
+        # set up the objspace optimizations based on the --opt argument
+        from pypy.config.pypyoption import set_pypy_opt_level
+        set_pypy_opt_level(config, translateconfig.opt)
+
+        # as of revision 27081, multimethod.py uses the InstallerVersion1 by default
+        # because it is much faster both to initialize and run on top of CPython.
+        # The InstallerVersion2 is optimized for making a translator-friendly
+        # structure for low level backends. However, InstallerVersion1 is still
+        # preferable for high level backends, so we patch here.
+
+        from pypy.objspace.std import multimethod
+        if config.objspace.std.multimethods == 'mrd':
+            assert multimethod.InstallerVersion1.instance_counter == 0,\
+                   'The wrong Installer version has already been instatiated'
+            multimethod.Installer = multimethod.InstallerVersion2
+        elif config.objspace.std.multimethods == 'doubledispatch':
+            # don't rely on the default, set again here
+            assert multimethod.InstallerVersion2.instance_counter == 0,\
+                   'The wrong Installer version has already been instatiated'
+            multimethod.Installer = multimethod.InstallerVersion1
+
+    def print_help(self, config):
+        self.opt_parser(config).print_help()
+
+    def get_additional_config_options(self):
+        from pypy.config.pypyoption import pypy_optiondescription
+        return pypy_optiondescription
+
+    def target(self, driver, args):
+        driver.exe_name = 'pypy-%(backend)s'
+
+        config = driver.config
+        parser = self.opt_parser(config)
+
+        parser.parse_args(args)
+
+        # expose the following variables to ease debugging
+        global space, entry_point
+
+        if config.objspace.allworkingmodules:
+            from pypy.config.pypyoption import enable_allworkingmodules
+            enable_allworkingmodules(config)
+        if config.objspace.translationmodules:
+            from pypy.config.pypyoption import enable_translationmodules
+            enable_translationmodules(config)
+
+        ## if config.translation.type_system == 'ootype':
+        ##     config.objspace.usemodules.suggest(rbench=True)
+
+        config.translation.suggest(check_str_without_nul=True)
+
+        if config.translation.thread:
+            config.objspace.usemodules.thread = True
+        elif config.objspace.usemodules.thread:
+            try:
+                config.translation.thread = True
+            except ConflictConfigError:
+                # If --allworkingmodules is given, we reach this point
+                # if threads cannot be enabled (e.g. they conflict with
+                # something else).  In this case, we can try setting the
+                # usemodules.thread option to False again.  It will
+                # cleanly fail if that option was set to True by the
+                # command-line directly instead of via --allworkingmodules.
+                config.objspace.usemodules.thread = False
+
+        if config.translation.continuation:
+            config.objspace.usemodules._continuation = True
+        elif config.objspace.usemodules._continuation:
+            try:
+                config.translation.continuation = True
+            except ConflictConfigError:
+                # Same as above: try to auto-disable the _continuation
+                # module if translation.continuation cannot be enabled
+                config.objspace.usemodules._continuation = False
+
+        if not config.translation.rweakref:
+            config.objspace.usemodules._weakref = False
+
+        if config.translation.jit:
+            config.objspace.usemodules.pypyjit = True
+        elif config.objspace.usemodules.pypyjit:
+            config.translation.jit = True
+
+        if config.translation.backend == "cli":
+            config.objspace.usemodules.clr = True
+        # XXX did it ever work?
+        #elif config.objspace.usemodules.clr:
+        #    config.translation.backend == "cli"
+
+        if config.translation.sandbox:
+            config.objspace.lonepycfiles = False
+            config.objspace.usepycfiles = False
+
+        config.translating = True
+
+        import translate
+        translate.log_config(config.objspace, "PyPy config object")
+
+        # obscure hack to stuff the translation options into the translated PyPy
+        import pypy.module.sys
+        options = make_dict(config)
+        wrapstr = 'space.wrap(%r)' % (options)
+        pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr
+
+        if config.translation.backend in ["cli", "jvm"] and sys.platform == "win32":
+            # HACK: The ftruncate implementation in streamio.py which is used for the Win32 platform
+            # is specific for the C backend and can't be generated on CLI or JVM. Because of that,
+            # we have to patch it out.
+            from rpython.rlib import streamio
+            def ftruncate_win32_dummy(fd, size): pass
+            def _setfd_binary_dummy(fd): pass
+            streamio.ftruncate_win32 = ftruncate_win32_dummy
+            streamio._setfd_binary = _setfd_binary_dummy
+
+        return self.get_entry_point(config)
+
+    def jitpolicy(self, driver):
+        from pypy.module.pypyjit.policy import PyPyJitPolicy, pypy_hooks
+        return PyPyJitPolicy(pypy_hooks)
+    
+    def get_entry_point(self, config):
+        from pypy.tool.lib_pypy import import_from_lib_pypy
+        rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild')
+        rebuild.try_rebuild()
+
+        space = make_objspace(config)
+
+        # manually imports app_main.py
+        filename = os.path.join(pypydir, 'interpreter', 'app_main.py')
+        app = gateway.applevel(open(filename).read(), 'app_main.py', 'app_main')
+        app.hidden_applevel = False
+        w_dict = app.getwdict(space)
+        entry_point = create_entry_point(space, w_dict)
+
+        return entry_point, None, PyPyAnnotatorPolicy(single_space = space)
+
+    def interface(self, ns):
+        for name in ['take_options', 'handle_config', 'print_help', 'target',
+                     'jitpolicy', 'get_entry_point',
+                     'get_additional_config_options']:
+            ns[name] = getattr(self, name)
+
+
+PyPyTarget().interface(globals())
+

File pypy/tool/terminal.py

-# Copyright: 2009 Nadia Alramli
-# License: BSD
-
-"""Terminal controller module
-Example of usage:
-    print BG_BLUE + 'Text on blue background' + NORMAL
-    print BLUE + UNDERLINE + 'Blue underlined text' + NORMAL
-    print BLUE + BG_YELLOW + BOLD + 'text' + NORMAL
-"""
-
-import sys
-
-# The current module
-MODULE = sys.modules[__name__]
-
-COLORS = "BLUE GREEN CYAN RED MAGENTA YELLOW WHITE BLACK".split()
-# List of terminal controls, you can add more to the list.
-CONTROLS = {
-    'BOL':'cr', 'UP':'cuu1', 'DOWN':'cud1', 'LEFT':'cub1', 'RIGHT':'cuf1',
-    'CLEAR_SCREEN':'clear', 'CLEAR_EOL':'el', 'CLEAR_BOL':'el1',
-    'CLEAR_EOS':'ed', 'BOLD':'bold', 'BLINK':'blink', 'DIM':'dim',
-    'REVERSE':'rev', 'UNDERLINE':'smul', 'NORMAL':'sgr0',
-    'HIDE_CURSOR':'cinvis', 'SHOW_CURSOR':'cnorm'
-}
-
-# List of numeric capabilities
-VALUES = {
-    'COLUMNS':'cols', # Width of the terminal (80 for unknown)
-    'LINES':'lines',  # Height of the terminal (25 for unknown)
-    'MAX_COLORS': 'colors',
-}
-
-def default():
-    """Set the default attribute values"""
-    for color in COLORS:
-        setattr(MODULE, color, '')
-        setattr(MODULE, 'BG_%s' % color, '')
-    for control in CONTROLS:
-        setattr(MODULE, control, '')
-    MODULE.COLUMNS = 80
-    MODULE.LINES = 25
-    MODULE.MAX_COLORS = 1
-
-def setup():
-    """Set the terminal control strings"""
-    # Initializing the terminal
-    curses.setupterm()
-    # Get the color escape sequence template or '' if not supported
-    # setab and setaf are for ANSI escape sequences
-    bgColorSeq = curses.tigetstr('setab') or curses.tigetstr('setb') or ''
-    fgColorSeq = curses.tigetstr('setaf') or curses.tigetstr('setf') or ''
-
-    for color in COLORS:
-        # Get the color index from curses
-        colorIndex = getattr(curses, 'COLOR_%s' % color)
-        # Set the color escape sequence after filling the template with index
-        setattr(MODULE, color, curses.tparm(fgColorSeq, colorIndex))
-        # Set background escape sequence
-        setattr(
-            MODULE, 'BG_%s' % color, curses.tparm(bgColorSeq, colorIndex)
-        )
-    for control in CONTROLS:
-        # Set the control escape sequence
-        setattr(MODULE, control, curses.tigetstr(CONTROLS[control]) or '')
-    if hasattr(curses, 'tigetnum'):
-        for value in VALUES:
-            # Set terminal related values
-            setattr(MODULE, value, curses.tigetnum(VALUES[value]))
-
-def render(text):
-    """Helper function to apply controls easily
-    Example:
-    apply("%(GREEN)s%(BOLD)stext%(NORMAL)s") -> a bold green text
-    """
-    return text % MODULE.__dict__
-
-try:
-    if '__pypy__' in sys.builtin_module_names:
-        # this is not really the whole curses, but our _minimal_curses it's
-        # better than nothing
-        import _minimal_curses as curses
-        # a bit of a hack: we have tigetstr but not tigetnum, so we call
-        # default() to have default values, then setup() will overwrite the
-        # ones it can
-        default()
-    else:
-        import curses
-    setup()
-except Exception, e:
-    # There is a failure; set all attributes to default
-    print 'Warning: %s' % e
-    default()

File rpython/tool/progressbar.py

     p.render(percentage, message)
 """
  
-from pypy.tool import terminal
+from rpython.tool import terminal
 import sys
  
 class ProgressBar(object):

File rpython/tool/terminal.py

+# Copyright: 2009 Nadia Alramli
+# License: BSD
+
+"""Terminal controller module
+Example of usage:
+    print BG_BLUE + 'Text on blue background' + NORMAL
+    print BLUE + UNDERLINE + 'Blue underlined text' + NORMAL
+    print BLUE + BG_YELLOW + BOLD + 'text' + NORMAL
+"""
+
+import sys
+
+# The current module
+MODULE = sys.modules[__name__]
+
+COLORS = "BLUE GREEN CYAN RED MAGENTA YELLOW WHITE BLACK".split()
+# List of terminal controls, you can add more to the list.
+CONTROLS = {
+    'BOL':'cr', 'UP':'cuu1', 'DOWN':'cud1', 'LEFT':'cub1', 'RIGHT':'cuf1',
+    'CLEAR_SCREEN':'clear', 'CLEAR_EOL':'el', 'CLEAR_BOL':'el1',
+    'CLEAR_EOS':'ed', 'BOLD':'bold', 'BLINK':'blink', 'DIM':'dim',
+    'REVERSE':'rev', 'UNDERLINE':'smul', 'NORMAL':'sgr0',
+    'HIDE_CURSOR':'cinvis', 'SHOW_CURSOR':'cnorm'
+}
+
+# List of numeric capabilities
+VALUES = {
+    'COLUMNS':'cols', # Width of the terminal (80 for unknown)
+    'LINES':'lines',  # Height of the terminal (25 for unknown)
+    'MAX_COLORS': 'colors',
+}
+
+def default():
+    """Set the default attribute values"""
+    for color in COLORS:
+        setattr(MODULE, color, '')
+        setattr(MODULE, 'BG_%s' % color, '')
+    for control in CONTROLS:
+        setattr(MODULE, control, '')
+    MODULE.COLUMNS = 80
+    MODULE.LINES = 25
+    MODULE.MAX_COLORS = 1
+
+def setup():
+    """Set the terminal control strings"""
+    # Initializing the terminal
+    curses.setupterm()
+    # Get the color escape sequence template or '' if not supported
+    # setab and setaf are for ANSI escape sequences
+    bgColorSeq = curses.tigetstr('setab') or curses.tigetstr('setb') or ''
+    fgColorSeq = curses.tigetstr('setaf') or curses.tigetstr('setf') or ''
+
+    for color in COLORS:
+        # Get the color index from curses
+        colorIndex = getattr(curses, 'COLOR_%s' % color)
+        # Set the color escape sequence after filling the template with index
+        setattr(MODULE, color, curses.tparm(fgColorSeq, colorIndex))
+        # Set background escape sequence
+        setattr(
+            MODULE, 'BG_%s' % color, curses.tparm(bgColorSeq, colorIndex)
+        )
+    for control in CONTROLS:
+        # Set the control escape sequence
+        setattr(MODULE, control, curses.tigetstr(CONTROLS[control]) or '')
+    if hasattr(curses, 'tigetnum'):
+        for value in VALUES:
+            # Set terminal related values
+            setattr(MODULE, value, curses.tigetnum(VALUES[value]))
+
+def render(text):
+    """Helper function to apply controls easily
+    Example:
+    apply("%(GREEN)s%(BOLD)stext%(NORMAL)s") -> a bold green text
+    """
+    return text % MODULE.__dict__
+
+try:
+    if '__pypy__' in sys.builtin_module_names:
+        # this is not really the whole curses, but our _minimal_curses it's
+        # better than nothing
+        import _minimal_curses as curses
+        # a bit of a hack: we have tigetstr but not tigetnum, so we call
+        # default() to have default values, then setup() will overwrite the
+        # ones it can
+        default()
+    else:
+        import curses
+    setup()
+except Exception, e:
+    # There is a failure; set all attributes to default
+    print 'Warning: %s' % e
+    default()

File rpython/translator/goal/ann_override.py

-# overrides for annotation specific to PyPy codebase
-from rpython.annotator.policy import AnnotatorPolicy, Sig
-# for some reason, model must be imported first,
-# or we create a cycle.
-from rpython.flowspace.model import Constant
-from rpython.annotator import model as annmodel
-from rpython.annotator.bookkeeper import getbookkeeper
-from rpython.annotator import specialize
-from pypy.interpreter import baseobjspace
-
-def isidentifier(s):
-    if not s: return False
-    s = s.replace('_', 'x')
-    return s[0].isalpha() and s.isalnum()
-
-# patch - mostly for debugging, to enforce some signatures
-baseobjspace.ObjSpace.newbool.im_func._annenforceargs_ = Sig(lambda s1,s2: s1,
-                                                             bool)
-
-
-class PyPyAnnotatorPolicy(AnnotatorPolicy):
-    def __init__(pol, single_space=None):
-        pol.lookups = {}
-        pol.lookups_where = {}
-        pol.pypytypes = {}
-        pol.single_space = single_space
-
-    def specialize__wrap(pol,  funcdesc, args_s):
-        from pypy.interpreter.baseobjspace import Wrappable
-        from rpython.annotator.classdef import ClassDef
-        Wrappable_def = funcdesc.bookkeeper.getuniqueclassdef(Wrappable)
-        typ = args_s[1].knowntype
-        if isinstance(typ, ClassDef):
-            assert typ.issubclass(Wrappable_def)
-            typ = Wrappable
-        else:
-            assert not issubclass(typ, Wrappable)
-            assert typ != tuple, "space.wrap(tuple) forbidden; use newtuple()"
-            assert typ != list, "space.wrap(list) forbidden; use newlist()"
-            assert typ != dict, "space.wrap(dict) forbidden; use newdict()"
-            assert typ != object, "degenerated space.wrap(object)"
-            if args_s[0].is_constant() and args_s[1].is_constant():
-                if typ in (str, bool, int, float):
-                    space = args_s[0].const
-                    x = args_s[1].const
-                    def fold():
-                        if typ is str and isidentifier(x):
-                            return space.new_interned_str(x)
-                        else:
-                            return space.wrap(x)
-                    builder = specialize.make_constgraphbuilder(2, factory=fold,
-                                                                srcmodule='<ann_override.wrap>')
-                    return funcdesc.cachedgraph((typ, x), builder=builder)
-        if typ is str:
-            if args_s[1].can_be_None:
-                typ = (None, str)
-        return funcdesc.cachedgraph(typ)
-
-    def _remember_immutable(pol, t, cached):
-        # for jit benefit
-        if cached not in t._immutable_fields_: # accessed this way just
-                                               # for convenience
-            t._immutable_fields_.append(cached)        
-    
-    def attach_lookup(pol, t, attr):
-        cached = "cached_%s" % attr
-        if not t.is_heaptype() and not t.is_cpytype():
-            pol._remember_immutable(t, cached)
-            setattr(t, cached, t._lookup(attr))
-            return True
-        return False
-
-    def attach_lookup_in_type_where(pol, t, attr):
-        cached = "cached_where_%s" % attr
-        if not t.is_heaptype() and not t.is_cpytype():
-            pol._remember_immutable(t, cached)
-            setattr(t, cached, t._lookup_where(attr))
-            return True
-        return False
-
-    def consider_lookup(pol, bookkeeper, attr):
-        from rpython.annotator.classdef import InstanceSource
-        assert attr not in pol.lookups
-        from pypy.objspace.std import typeobject
-        cached = "cached_%s" % attr
-        clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
-        classdesc = clsdef.classdesc
-        classdesc.classdict[cached] = Constant(None)
-        clsdef.add_source_for_attribute(cached, classdesc)
-        for t in pol.pypytypes:
-            if pol.attach_lookup(t, attr):
-                source = InstanceSource(bookkeeper, t)
-                clsdef.add_source_for_attribute(cached, source)
-        pol.lookups[attr] = True
-
-    def consider_lookup_in_type_where(pol, bookkeeper, attr):
-        from rpython.annotator.classdef import InstanceSource
-        assert attr not in pol.lookups_where
-        from pypy.objspace.std import typeobject
-        cached = "cached_where_%s" % attr
-        clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
-        classdesc = clsdef.classdesc
-        classdesc.classdict[cached] = Constant((None, None))
-        clsdef.add_source_for_attribute(cached, classdesc)
-        for t in pol.pypytypes:
-            if pol.attach_lookup_in_type_where(t, attr):
-                source = InstanceSource(bookkeeper, t)
-                clsdef.add_source_for_attribute(cached, source)
-        pol.lookups_where[attr] = True
-
-    def specialize__lookup(pol, funcdesc, args_s):
-        s_space, s_obj, s_name = args_s
-        if s_name.is_constant():
-            attr = s_name.const
-            def builder(translator, func):
-                #print "LOOKUP", attr
-                pol.consider_lookup(funcdesc.bookkeeper, attr)
-                d = {'__name__': '<ann_override_lookup>'}
-                exec CACHED_LOOKUP % {'attr': attr} in d
-                return translator.buildflowgraph(d['lookup_'+attr])
-            return funcdesc.cachedgraph(attr, builder=builder)
-        else:
-            pol.lookups[None] = True
-            return funcdesc.cachedgraph(None) # don't specialize
-
-    def specialize__lookup_in_type_where(pol, funcdesc, args_s):
-        s_space, s_obj, s_name = args_s
-        if s_name.is_constant():
-            attr = s_name.const
-            def builder(translator, func):
-                #print "LOOKUP_IN_TYPE_WHERE", attr
-                pol.consider_lookup_in_type_where(funcdesc.bookkeeper, attr)
-                d = {'__name__': '<ann_override_lookup>'}
-                exec CACHED_LOOKUP_IN_TYPE_WHERE % {'attr': attr} in d
-                return translator.buildflowgraph(d['lookup_in_type_where_'+attr])
-            return funcdesc.cachedgraph(attr, builder=builder)
-        else:
-            pol.lookups_where[None] = True
-            return funcdesc.cachedgraph(None)
-
-    def event(pol, bookkeeper, what, x):
-        from pypy.objspace.std import typeobject
-        if isinstance(x, typeobject.W_TypeObject):
-            from rpython.annotator.classdef import InstanceSource
-            clsdef = bookkeeper.getuniqueclassdef(typeobject.W_TypeObject)
-            pol.pypytypes[x] = True
-            #print "TYPE", x
-            for attr in pol.lookups:
-                if attr and pol.attach_lookup(x, attr):
-                    cached = "cached_%s" % attr
-                    source = InstanceSource(bookkeeper, x)
-                    clsdef.add_source_for_attribute(cached, source)
-            for attr in pol.lookups_where:
-                if attr and pol.attach_lookup_in_type_where(x, attr):
-                    cached = "cached_where_%s" % attr
-                    source = InstanceSource(bookkeeper, x)
-                    clsdef.add_source_for_attribute(cached, source)
-        return
-
-CACHED_LOOKUP = """
-def lookup_%(attr)s(space, w_obj, name):
-    w_type = space.type(w_obj)
-    if not w_type.is_heaptype() and not w_type.is_cpytype():
-        return w_type.cached_%(attr)s
-    return w_type.lookup("%(attr)s")
-"""
-
-CACHED_LOOKUP_IN_TYPE_WHERE = """
-def lookup_in_type_where_%(attr)s(space, w_type, name):
-    if not w_type.is_heaptype() and not w_type.is_cpytype():
-        return w_type.cached_where_%(attr)s
-    return w_type.lookup_where("%(attr)s")
-"""

File rpython/translator/goal/multibuild.py

-from pypy.config.pypyoption import get_pypy_config
-from rpython.translator.goal import translate
-from rpython.translator.goal import targetpypystandalone
-from rpython.translator.driver import TranslationDriver
-import os, sys, traceback, random
-
-def longoptfromname(config, name):
-    from pypy.config.makerestdoc import get_cmdline
-    # begin horror
-    h, n = config._cfgimpl_get_home_by_path(name)
-    opt = getattr(h._cfgimpl_descr, n)
-    # end horror
-    cmdline = get_cmdline(opt.cmdline, name)
-    assert cmdline is not None
-    shortest_long_option = 'X'*1000
-    for cmd in cmdline.split():
-        if cmd.startswith('--') and len(cmd) < len(shortest_long_option):
-            shortest_long_option = cmd
-    return shortest_long_option
-
-def exe_name_from_options(config, opts):
-    from pypy.module.sys.version import svn_revision
-
-    backend = config.translation.backend
-    if not backend:
-        backend = 'c'
-    rev = svn_revision()
-
-    nameparts = []
-
-    for opt, v in opts.iteritems():
-        if opt == 'translation.backend':
-            backend = v
-        optname = longoptfromname(config, opt).strip('-')
-        if v is False:
-            optname = 'no-' + optname
-        elif v is not True:
-            optname += '=' + str(v)
-        nameparts.append(optname)
-
-    suffix = ''
-    if nameparts:
-        def k(s):
-            if s.startswith('no-'):
-                return s[3:]
-            else:
-                return s
-        nameparts.sort(key=k)
-        suffix = '-' + '-'.join(nameparts)
-
-    return 'pypy-%s-%d%s'%(backend, rev, suffix)
-
-def _build(config, exe_name):
-    driver = TranslationDriver.from_targetspec(
-        targetpypystandalone.__dict__,
-        config=config)
-    driver.exe_name = exe_name
-    driver.compile()
-
-def build_pypy_with_options(basedir, opts):
-    config = get_pypy_config(translate.OVERRIDES, translating=True)
-
-    try:
-        config.set(**opts)
-    except:
-        return exe_name_from_options(config, opts), "didn't configure"
-
-    exe_name = os.path.join(basedir, exe_name_from_options(config, opts))
-
-    print exe_name,
-    sys.stdout.flush()
-
-    pid = os.fork()
-
-    if pid == 0:
-        logfile = open(exe_name + '-log', 'w')
-        davenull = os.open('/dev/null', os.O_RDONLY)
-        os.dup2(davenull, 0)
-        os.dup2(logfile.fileno(), 1)
-        os.dup2(logfile.fileno(), 2)
-        try:
-            try:
-                r = _build(config, exe_name)
-            finally:
-                logfile.close()
-        except:
-            os._exit(1)
-        else:
-            os._exit(0)
-    else:
-        pid, status = os.waitpid(pid, 0)
-        if status:
-            r = 'failed'
-        else:
-            r = 'succeeded'
-        print r
-        return exe_name, r
-
-def get_options(fname):
-    def gen_opts(sofar, remaining):
-        if not remaining:
-            yield sofar
-        else:
-            for (k, v) in remaining[0]:
-                d2 = sofar.copy()
-                d2[k] = v
-                for d in gen_opts(d2, remaining[1:]):
-                    yield d
-    options = []
-    for line in open(fname):
-        l = []
-        optname, options_ = line.split(':')
-        options.append([(optname.strip(), eval(optval.strip())) for optval in options_.split(',')])
-    return gen_opts({}, options)
-
-
-if __name__ == '__main__':
-    basedir = sys.argv[1]
-    optionsfile = sys.argv[2]
-    results = []
-    options = list(get_options(optionsfile))
-    random.shuffle(options)
-    for opts in options:
-        results.append(build_pypy_with_options(basedir, opts))
-    out = open(os.path.join(basedir, 'results'), 'w')
-    for exe, r in results:
-        print >>out, exe, r

File rpython/translator/goal/test2/test_targetpypy.py

 
 import py
-from rpython.translator.goal.targetpypystandalone import get_entry_point
+from goal.targetpypystandalone import get_entry_point
 from pypy.config.pypyoption import get_pypy_config
 
 class TestTargetPyPy(object):

File targetpypystandalone.py

-import py
-
-import os, sys
-
-from pypy.interpreter import gateway
-from pypy.interpreter.error import OperationError
-from rpython.translator.goal.ann_override import PyPyAnnotatorPolicy
-from pypy.config.config import Config, to_optparse, make_dict, SUPPRESS_USAGE
-from pypy.config.config import ConflictConfigError
-from pypy.tool.option import make_objspace
-from pypy.conftest import pypydir
-
-thisdir = py.path.local(__file__).dirpath()
-
-try:
-    this_dir = os.path.dirname(__file__)
-except NameError:
-    this_dir = os.path.dirname(sys.argv[0])
-
-def debug(msg):
-    os.write(2, "debug: " + msg + '\n')
-
-# __________  Entry point  __________
-
-def create_entry_point(space, w_dict):
-    w_entry_point = space.getitem(w_dict, space.wrap('entry_point'))
-    w_run_toplevel = space.getitem(w_dict, space.wrap('run_toplevel'))
-    w_call_finish_gateway = space.wrap(gateway.interp2app(call_finish))
-    w_call_startup_gateway = space.wrap(gateway.interp2app(call_startup))
-    withjit = space.config.objspace.usemodules.pypyjit
-
-    def entry_point(argv):
-        if withjit:
-            from rpython.jit.backend.hlinfo import highleveljitinfo
-            highleveljitinfo.sys_executable = argv[0]
-
-        #debug("entry point starting") 
-        #for arg in argv: 
-        #    debug(" argv -> " + arg)
-        if len(argv) > 2 and argv[1] == '--heapsize':
-            # Undocumented option, handled at interp-level.
-            # It has silently no effect with some GCs.
-            # It works in Boehm and in the semispace or generational GCs
-            # (but see comments in semispace.py:set_max_heap_size()).
-            # At the moment this option exists mainly to support sandboxing.
-            from rpython.rlib import rgc
-            rgc.set_max_heap_size(int(argv[2]))
-            argv = argv[:1] + argv[3:]
-        try:
-            try:
-                space.call_function(w_run_toplevel, w_call_startup_gateway)
-                w_executable = space.wrap(argv[0])
-                w_argv = space.newlist([space.wrap(s) for s in argv[1:]])
-                w_exitcode = space.call_function(w_entry_point, w_executable, w_argv)
-                exitcode = space.int_w(w_exitcode)
-                # try to pull it all in
-            ##    from pypy.interpreter import main, interactive, error
-            ##    con = interactive.PyPyConsole(space)
-            ##    con.interact()
-            except OperationError, e:
-                debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space))
-                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
-                return 1
-        finally:
-            try:
-                space.call_function(w_run_toplevel, w_call_finish_gateway)
-            except OperationError, e:
-                debug("OperationError:")
-                debug(" operror-type: " + e.w_type.getname(space))
-                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
-                return 1
-        return exitcode
-    return entry_point
-
-def call_finish(space):
-    space.finish()
-
-def call_startup(space):
-    space.startup()
-
-# _____ Define and setup target ___
-
-# for now this will do for option handling
-
-class PyPyTarget(object):
-
-    usage = SUPPRESS_USAGE
-
-    take_options = True
-
-    def opt_parser(self, config):
-        parser = to_optparse(config, useoptions=["objspace.*"],
-                             parserkwargs={'usage': self.usage})
-        return parser
-
-    def handle_config(self, config, translateconfig):
-        if (not translateconfig.help and
-            translateconfig._cfgimpl_value_owners['opt'] == 'default'):
-            raise Exception("You have to specify the --opt level.\n"
-                    "Try --opt=2 or --opt=jit, or equivalently -O2 or -Ojit .")
-        self.translateconfig = translateconfig
-        # set up the objspace optimizations based on the --opt argument
-        from pypy.config.pypyoption import set_pypy_opt_level
-        set_pypy_opt_level(config, translateconfig.opt)
-
-        # as of revision 27081, multimethod.py uses the InstallerVersion1 by default
-        # because it is much faster both to initialize and run on top of CPython.
-        # The InstallerVersion2 is optimized for making a translator-friendly
-        # structure for low level backends. However, InstallerVersion1 is still
-        # preferable for high level backends, so we patch here.
-
-        from pypy.objspace.std import multimethod
-        if config.objspace.std.multimethods == 'mrd':
-            assert multimethod.InstallerVersion1.instance_counter == 0,\
-                   'The wrong Installer version has already been instatiated'
-            multimethod.Installer = multimethod.InstallerVersion2
-        elif config.objspace.std.multimethods == 'doubledispatch':
-            # don't rely on the default, set again here
-            assert multimethod.InstallerVersion2.instance_counter == 0,\
-                   'The wrong Installer version has already been instatiated'
-            multimethod.Installer = multimethod.InstallerVersion1
-
-    def print_help(self, config):
-        self.opt_parser(config).print_help()
-
-    def get_additional_config_options(self):
-        from pypy.config.pypyoption import pypy_optiondescription
-        return pypy_optiondescription
-
-    def target(self, driver, args):
-        driver.exe_name = 'pypy-%(backend)s'
-
-        config = driver.config
-        parser = self.opt_parser(config)
-
-        parser.parse_args(args)
-
-        # expose the following variables to ease debugging
-        global space, entry_point
-
-        if config.objspace.allworkingmodules:
-            from pypy.config.pypyoption import enable_allworkingmodules
-            enable_allworkingmodules(config)
-        if config.objspace.translationmodules:
-            from pypy.config.pypyoption import enable_translationmodules
-            enable_translationmodules(config)
-
-        ## if config.translation.type_system == 'ootype':
-        ##     config.objspace.usemodules.suggest(rbench=True)
-
-        config.translation.suggest(check_str_without_nul=True)
-
-        if config.translation.thread:
-            config.objspace.usemodules.thread = True
-        elif config.objspace.usemodules.thread:
-            try:
-                config.translation.thread = True
-            except ConflictConfigError:
-                # If --allworkingmodules is given, we reach this point
-                # if threads cannot be enabled (e.g. they conflict with
-                # something else).  In this case, we can try setting the
-                # usemodules.thread option to False again.  It will
-                # cleanly fail if that option was set to True by the
-                # command-line directly instead of via --allworkingmodules.
-                config.objspace.usemodules.thread = False
-
-        if config.translation.continuation:
-            config.objspace.usemodules._continuation = True
-        elif config.objspace.usemodules._continuation:
-            try:
-                config.translation.continuation = True
-            except ConflictConfigError:
-                # Same as above: try to auto-disable the _continuation
-                # module if translation.continuation cannot be enabled
-                config.objspace.usemodules._continuation = False
-
-        if not config.translation.rweakref:
-            config.objspace.usemodules._weakref = False
-
-        if config.translation.jit:
-            config.objspace.usemodules.pypyjit = True
-        elif config.objspace.usemodules.pypyjit:
-            config.translation.jit = True
-
-        if config.translation.backend == "cli":
-            config.objspace.usemodules.clr = True
-        # XXX did it ever work?
-        #elif config.objspace.usemodules.clr:
-        #    config.translation.backend == "cli"
-
-        if config.translation.sandbox:
-            config.objspace.lonepycfiles = False
-            config.objspace.usepycfiles = False
-
-        config.translating = True
-
-        import translate
-        translate.log_config(config.objspace, "PyPy config object")
-
-        # obscure hack to stuff the translation options into the translated PyPy
-        import pypy.module.sys
-        options = make_dict(config)
-        wrapstr = 'space.wrap(%r)' % (options)
-        pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr
-
-        if config.translation.backend in ["cli", "jvm"] and sys.platform == "win32":
-            # HACK: The ftruncate implementation in streamio.py which is used for the Win32 platform
-            # is specific for the C backend and can't be generated on CLI or JVM. Because of that,
-            # we have to patch it out.
-            from rpython.rlib import streamio
-            def ftruncate_win32_dummy(fd, size): pass
-            def _setfd_binary_dummy(fd): pass
-            streamio.ftruncate_win32 = ftruncate_win32_dummy
-            streamio._setfd_binary = _setfd_binary_dummy
-
-        return self.get_entry_point(config)
-
-    def jitpolicy(self, driver):
-        from pypy.module.pypyjit.policy import PyPyJitPolicy, pypy_hooks
-        return PyPyJitPolicy(pypy_hooks)
-    
-    def get_entry_point(self, config):
-        from pypy.tool.lib_pypy import import_from_lib_pypy
-        rebuild = import_from_lib_pypy('ctypes_config_cache/rebuild')
-        rebuild.try_rebuild()
-
-        space = make_objspace(config)
-
-        # manually imports app_main.py
-        filename = os.path.join(pypydir, 'interpreter', 'app_main.py')
-        app = gateway.applevel(open(filename).read(), 'app_main.py', 'app_main')
-        app.hidden_applevel = False
-        w_dict = app.getwdict(space)
-        entry_point = create_entry_point(space, w_dict)
-
-        return entry_point, None, PyPyAnnotatorPolicy(single_space = space)
-
-    def interface(self, ns):
-        for name in ['take_options', 'handle_config', 'print_help', 'target',
-                     'jitpolicy', 'get_entry_point',
-                     'get_additional_config_options']:
-            ns[name] = getattr(self, name)
-
-
-PyPyTarget().interface(globals())
-