def main():
    cache = nodecache.NodeCache(bitbakec.parsefile)
    # Read the Configuration
    my_init = bb.data.init()
    bb.data.inheritFromOS(my_init)
    my_init.setVar('TOPDIR', os.getcwd() )
    conf = bitbakec.parsefile(bb.which(os.environ['BBPATH'], "conf/bitbake.conf"), True)
    conf.eval( my_init, cache )


    # micro optimisation INHERIT the bases once...
    import ast
    root = ast.Root("none")
    inherits = (my_init.getVar('INHERIT', True) or "").split()
    inherits.insert(0, "base")
    for inherit in inherits:
        print "Inheriting %s" % inherit
        root.add_statement( ast.Inherit( inherit ) )

    root.eval( my_init, cache )
    cache.base_classes = root.classes
    cache.task_base    = root.tasks
    cache.queue_base   = root.anonqueue
    print cache.base_classes

    print root.handler
    add_handler( root, my_init )
    
    #sys.exit(-1)
    # Initialize the fetcher stuff
    def set_additional_vars(the_data):
        """Deduce rest of variables, e.g. ${A} out of ${SRC_URI}"""

        src_uri = bb.data.getVar('SRC_URI', the_data)
        if not src_uri:
            return
        src_uri = bb.data.expand(src_uri, the_data)

        a = bb.data.getVar('A', the_data)
        if a:
            a = bb.data.expand(a, the_data).split()
        else:
            a = []

        from bb import fetch
        try:
            fetch.init(src_uri.split(), the_data)
        except fetch.NoMethodError:
            pass
        except bb.MalformedUrl,e:
            raise bb.parse.ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e)

        a += fetch.localpaths(the_data)
        del fetch
        bb.data.setVar('A', " ".join(a), the_data)
    debug(2,"BB %s: set_additional_vars" % file)

    src_uri = data.getVar('SRC_URI', d)
    if not src_uri:
        return
    src_uri = data.expand(src_uri, d)

    a = data.getVar('A', d)
    if a:
        a = data.expand(a, d).split()
    else:
        a = []

    from bb import fetch
    try:
        fetch.init(src_uri.split(), d)
    except fetch.NoMethodError:
        pass
    except bb.MalformedUrl,e:
        raise ParseError("Unable to generate local paths for SRC_URI due to malformed uri: %s" % e)

    a += fetch.localpaths(d)
    del fetch
    data.setVar('A', " ".join(a), d)


# Add us to the handlers list
from bb.parse import handlers
handlers.append({'supports': supports, 'handle': handle, 'init': init})
del handlers