Пример #1
0
    def test_endist_metadata_simple(self):
        # Given
        source = os.path.join(self.prefix, os.path.basename(NOSE_1_2_1))
        shutil.copy(NOSE_1_2_1, source)

        target = os.path.join(self.prefix, "babar-1.2.1-2.egg")
        endist = os.path.join(self.prefix, "endist.dat")
        with open(endist, "w") as fp:
            data = textwrap.dedent("""\
            packages = ["foo"]

            name = "babar"
            """)
            fp.write(data)

        # When
        with chdir(self.prefix):
            repack(source, 2, "rh5-64")

        # Then
        self.assertTrue(os.path.exists(target))
        with ZipFile(target) as zp:
            info = info_from_z(zp)
        assertCountEqual(self, info["packages"], ["foo"])
        assertCountEqual(self, info["name"], "babar")
Пример #2
0
    def test_endist_metadata_simple(self):
        # Given
        source = os.path.join(self.prefix, os.path.basename(NOSE_1_2_1))
        shutil.copy(NOSE_1_2_1, source)

        target = os.path.join(self.prefix, "babar-1.2.1-2.egg")
        endist = os.path.join(self.prefix, "endist.dat")
        with open(endist, "w") as fp:
            data = textwrap.dedent("""\
            packages = ["foo"]

            name = "babar"
            """)
            fp.write(data)

        # When
        with chdir(self.prefix):
            repack(source, 2, "rh5-64")

        # Then
        self.assertTrue(os.path.exists(target))
        with ZipFile(target) as zp:
            info = info_from_z(zp)
        assertCountEqual(self, info["packages"], ["foo"])
        assertCountEqual(self, info["name"], "babar")
Пример #3
0
 def from_egg(cls, path):
     """
     Create an instance from an egg filename.
     """
     with ZipFile(path) as zp:
         metadata = info_from_z(zp)
     metadata["packages"] = metadata.get("packages", [])
     return cls.from_json_dict(os.path.basename(path), metadata)
Пример #4
0
 def from_egg(cls, path):
     """
     Create an instance from an egg filename.
     """
     with ZipFile(path) as zp:
         metadata = info_from_z(zp)
     metadata["packages"] = metadata.get("packages", [])
     return cls.from_json_dict(os.path.basename(path), metadata)
Пример #5
0
 def from_egg(cls, path, ctime, store_location):
     """
     Create an instance from an egg filename.
     """
     with ZipFile(path) as zp:
         metadata = info_from_z(zp)
     metadata["packages"] = metadata.get("packages", [])
     metadata["ctime"] = ctime
     metadata["store_location"] = store_location
     metadata["key"] = os.path.basename(path)
     return cls.from_installed_meta_dict(metadata)
Пример #6
0
    def from_egg(cls, path, ctime, prefix=None):
        """
        Create an instance from an egg filename.
        """
        prefix = prefix or sys.prefix

        with ZipFile(path) as zp:
            metadata = info_from_z(zp)
        metadata["packages"] = metadata.get("packages", [])
        metadata["ctime"] = ctime
        metadata["key"] = os.path.basename(path)
        return cls.from_installed_meta_dict(metadata, prefix)
Пример #7
0
    def test_name_casing(self):
        r_metadata = {
            "name": "pil",
            "version": "1.1.7",
            "build": 3,
            "arch": "x86",
            "platform": "win32",
            "osdist": None,
            "python": "2.7",
            "packages": [],
            "type": "egg",
        }

        s = _create_inmemory_egg({"EGG-INFO/spec/depend": PIL_1_1_7_WIN32})
        with ZipFile(s) as z:
            metadata = info_from_z(z)
            self.assertEqual(metadata, r_metadata)
Пример #8
0
    def test_simple(self):
        r_metadata = {
            "name": "numpy",
            "version": "1.4.0",
            "build": 3,
            "arch": "x86",
            "platform": "win32",
            "osdist": None,
            "python": "2.6",
            "packages": [],
            "type": "egg",
        }

        s = _create_inmemory_egg({"EGG-INFO/spec/depend": NUMPY_1_4_0_WIN32})
        with ZipFile(s) as z:
            metadata = info_from_z(z)
            self.assertEqual(metadata, r_metadata)
Пример #9
0
    def from_egg(cls, path, repository_info=None, python_version=PY_VER):
        """
        Create an instance from an egg filename.
        """
        with ZipFile(path) as zp:
            metadata = info_from_z(zp)

        repository_info = repository_info or \
            FSRepositoryInfo(path_to_uri(os.path.dirname(path)))

        metadata["packages"] = metadata.get("packages", [])
        st = os.stat(path)
        metadata["size"] = st.st_size
        metadata["md5"] = compute_md5(path)
        metadata["mtime"] = st.st_mtime
        return cls.from_json_dict(os.path.basename(path), metadata,
                                  repository_info)
Пример #10
0
    def test_name_casing(self):
        r_metadata = {
            "name": "pil",
            "version": "1.1.7",
            "build": 3,
            "arch": "x86",
            "platform": "win32",
            "osdist": None,
            "python": "2.7",
            "packages": [],
            "type": "egg",
        }

        s = _create_inmemory_egg({"EGG-INFO/spec/depend": PIL_1_1_7_WIN32})
        with ZipFile(s) as z:
            metadata = info_from_z(z)
            self.assertEqual(metadata, r_metadata)
Пример #11
0
    def test_simple(self):
        r_metadata = {
            "name": "numpy",
            "version": "1.4.0",
            "build": 3,
            "arch": "x86",
            "platform": "win32",
            "osdist": None,
            "python": "2.6",
            "packages": [],
            "type": "egg",
        }

        s = _create_inmemory_egg({"EGG-INFO/spec/depend": NUMPY_1_4_0_WIN32})
        with ZipFile(s) as z:
            metadata = info_from_z(z)
            self.assertEqual(metadata, r_metadata)
Пример #12
0
    def test_repack_default_platform(self):
        # Given
        source = os.path.join(self.prefix, "nose-1.2.1-py2.7.egg")
        shutil.copy(STANDARD_EGG, source)

        target = os.path.join(self.prefix, "nose-1.2.1-1.egg")

        # When
        mocked = "enstaller.tools.repack.EPDPlatform.from_running_system"
        platform = EPDPlatform.from_epd_string("rh5-32")
        with mock.patch(mocked, return_value=platform):
            repack(source, 1)

        # Then
        self.assertTrue(os.path.exists(target))
        with ZipFile(target) as zp:
            spec = info_from_z(zp)
        self.assertEqual(spec["arch"], "x86")
Пример #13
0
    def test_repack_default_platform(self):
        # Given
        source = os.path.join(self.prefix, "nose-1.2.1-py2.7.egg")
        shutil.copy(STANDARD_EGG, source)

        target = os.path.join(self.prefix, "nose-1.2.1-1.egg")

        # When
        mocked = "enstaller.tools.repack.LegacyEPDPlatform." \
                 "from_running_system"
        platform = LegacyEPDPlatform.from_epd_platform_string("rh5-32")
        with mock.patch(mocked, return_value=platform):
            repack(source, 1)

        # Then
        self.assertTrue(os.path.exists(target))
        with ZipFile(target) as zp:
            spec = info_from_z(zp)
        self.assertEqual(spec["arch"], "x86")
Пример #14
0
    def from_egg(cls, path, store_location=""):
        """
        Create an instance from an egg filename.
        """
        with ZipFile(path) as zp:
            metadata = info_from_z(zp)

        if len(store_location) == 0:
            store_location = path_to_uri(os.path.dirname(path)) + "/"

        if not store_location.endswith("/"):
            msg = "Invalid uri for store location: {0!r} (expected an uri " \
                  "ending with '/')".format(store_location)
            raise ValueError(msg)

        metadata["packages"] = metadata.get("packages", [])
        st = os.stat(path)
        metadata["size"] = st.st_size
        metadata["md5"] = compute_md5(path)
        metadata["mtime"] = st.st_mtime
        metadata["store_location"] = store_location
        return cls.from_json_dict(os.path.basename(path), metadata)
Пример #15
0
def info_from_egg(path):
    z = zipfile.ZipFile(path)
    res = info_from_z(z)
    z.close()
    return res
Пример #16
0
def info_from_egg(path):
    z = zipfile.ZipFile(path)
    res = info_from_z(z)
    z.close()
    return res
"""
Small script to check there is no discrepency between our info_from_z and
the one from egginst.

It compares both implementations on every egg we in our repo.
"""
import glob
import os
import zipfile

import os.path as op

from egginst import eggmeta
from okonomiyaki.models.common import info_from_z

PREFIX = "/export/repo/epd/eggs"
ARCNAME = op.join("EGG-INFO/spec/depend")

for d in ["Windows/x86", "Windows/amd64", "RedHat/RH5_x86", "RedHat/RH5_amd64",
          "RedHat/RH3_x86", "RedHat/RH3_amd64", "MacOSX/x86", "MacOSX/amd64"]:
    print d
    for egg in glob.glob(op.join(PREFIX, d, "*egg")):
        with zipfile.ZipFile(egg, "r") as fp:
            r_spec = eggmeta.info_from_z(fp)
            spec = info_from_z(fp)

            if  r_spec != spec:
                print egg
Пример #18
0
def info_from_egg(path):
    with zipfile.ZipFile(path) as z:
        return info_from_z(z)