def initpkg(pkgname, exportdefs, attr=None, eager=False):
attr = attr or {}<EOL>oldmod = sys.modules.get(pkgname)<EOL>d = {}<EOL>f = getattr(oldmod, '<STR_LIT>', None)<EOL>if f:<EOL><INDENT>f = _py_abspath(f)<EOL><DEDENT>d['<STR_LIT>'] = f<EOL>if hasattr(oldmod, '<STR_LIT>'):<EOL><INDENT>d['<STR_LIT>'] = oldmod.__version__<EOL><DEDENT>if hasattr(oldmod, '<STR_LIT>'):<EOL><INDENT>d['<STR_LIT>'] = oldmod.__loader__<EOL><DEDENT>if hasattr(oldmod, '<STR_LIT>'):<EOL><INDENT>d['<STR_LIT>'] = [_py_abspath(p) for p in oldmod.__path__]<EOL><DEDENT>if hasattr(oldmod, '<STR_LIT>'):<EOL><INDENT>d['<STR_LIT>'] = oldmod.__package__<EOL><DEDENT>if '<STR_LIT>' not in exportdefs and getattr(oldmod, '<STR_LIT>', None):<EOL><INDENT>d['<STR_LIT>'] = oldmod.__doc__<EOL><DEDENT>d.update(attr)<EOL>if hasattr(oldmod, "<STR_LIT>"):<EOL><INDENT>oldmod.__dict__.update(d)<EOL><DEDENT>mod = ApiModule(pkgname, exportdefs, implprefix=pkgname, attr=d)<EOL>sys.modules[pkgname] = mod<EOL>if '<STR_LIT>' in sys.modules or eager:<EOL><INDENT>for module in list(sys.modules.values()):<EOL><INDENT>if isinstance(module, ApiModule):<EOL><INDENT>module.__dict__<EOL><DEDENT><DEDENT><DEDENT>
initialize given package from the export definitions.