Beispiel #1
0
def extract_egg(egg, extract_dir):
    # Given a bento-produced egg, extract its content in the given directory,
    # and returned the corresponding ipkg info instance
    ipkg = InstalledPkgDescription.from_egg(egg)
    # egg scheme
    ipkg.update_paths({"prefix": ".", "eprefix": ".", "sitedir": "."})

    zid = zipfile.ZipFile(egg)
    try:
        for type, sections in ipkg.files.items():
            for name, section in sections.items():
                target_dir = ipkg.resolve_path(section.target_dir)
                section.source_dir = os.path.join(extract_dir, target_dir)
                for source, target in section.files:
                    g = os.path.join(target_dir, target)
                    g = os.path.normpath(g)
                    zid.extract(g, extract_dir)
    finally:
        zid.close()

    return ipkg
Beispiel #2
0
    import \
        create_scripts

if __name__ == "__main__":
    import tempfile

    TMPDIR = tempfile.mkdtemp()
    try:
        EGG_PATH = sys.argv[1]

        zid = zipfile.ZipFile(EGG_PATH)
        try:
            zid.extractall(path=TMPDIR)
        finally:
            zid.close()
        ipkg = InstalledPkgDescription.from_egg(EGG_PATH)

        # Build executables
        bdir = os.path.join(TMPDIR, "SCRIPTS")
        os.makedirs(bdir)
        create_scripts(ipkg.executables, bdir)
        # XXX: use internal API
        for k in ipkg.files["executables"]:
            ipkg.files["executables"][k].source_dir = bdir

        meta = PackageMetadata.from_ipkg(ipkg)
        wininst = wininst_filename(meta.fullname)
        create_wininst(ipkg, src_root_dir=TMPDIR, wininst=wininst)
    finally:
        #shutil.rmtree(TMPDIR)
        pass