

def build_egg(build_manifest, build_node, source_root, output_dir=None, output_file=None):
    meta = PackageMetadata.from_build_manifest(build_manifest)
    egg_info = EggInfo.from_build_manifest(build_manifest, build_node)
    if (output_dir is None):
        if (output_file is None):
            egg = egg_filename(os.path.join('dist', meta.fullname))
        else:
            egg = os.path.join('dist', output_file)
    elif (output_file is None):
        egg = egg_filename(os.path.join(output_dir, meta.fullname))
    else:
        egg = os.path.join(output_dir, output_file)
    bento.utils.path.ensure_dir(egg)
    egg_scheme = {
        'prefix': source_root.abspath(),
        'eprefix': source_root.abspath(),
        'sitedir': source_root.abspath(),
    }
    zid = compat.ZipFile(egg, 'w', compat.ZIP_DEFLATED)
    try:
        for (filename, cnt) in egg_info.iter_meta(build_node):
            zid.writestr(os.path.join('EGG-INFO', filename), cnt)
        for (kind, source, target) in build_manifest.iter_built_files(egg, egg_scheme):
            if (not (kind in ['executables'])):
                zid.write(source.abspath(), target.path_from(source_root))
            if (kind == 'pythonfiles'):
                try:
                    bytecode = bcompile(source.abspath())
                except PyCompileError:
                    e = extract_exception()
                    warnings.warn(('Error byte-compiling %r' % source.abspath()))
                else:
                    zid.writestr(('%sc' % target.path_from(source_root)), bcompile(source.abspath()))
    finally:
        zid.close()
    return

dataset/ETHPy150Open cournape/Bento/bento/commands/build_egg.py build_egg/VarMisuse@255/361 `source_root`->`egg`