Example #1
0
    def install(self):
        if not isdir(self.meta_dir):
            os.makedirs(self.meta_dir)

        self.z = zipfile.ZipFile(self.fpath)
        self.arcnames = self.z.namelist()

        self.extract()

        if on_win:
            scripts.create_proxies(self)

        else:
            from egginst import links
            from egginst import object_code

            if self.verbose:
                links.verbose = object_code.verbose = True

            links.create(self)
            object_code.fix_files(self)

        self.entry_points()
        self.z.close()
        scripts.fix_scripts(self)
        self.run('post_egginst.py')
        self.install_app()
        self.write_meta()

        if self.hook:
            from egginst import registry

            registry.create_file(self)
Example #2
0
    def test_proxy_directory(self):
        """
        Test we handle correctly entries of the form 'path some_directory'.
        """
        with mkdtemp() as prefix:
            with mock.patch("sys.executable", op.join(prefix, "python.exe")):
                egginst = EggInst(DUMMY_EGG_WITH_PROXY_SCRIPTS, prefix)
                with zipfile.ZipFile(egginst.path) as zp:
                    egginst.z = zp
                    egginst.arcnames = zp.namelist()
                    create_proxies(egginst)

                    proxied_files = [op.join(prefix, "Scripts", "dummy.dll"), op.join(prefix, "Scripts", "dummy.lib")]
                    for proxied_file in proxied_files:
                        self.assertTrue(op.exists(proxied_file))
Example #3
0
    def test_proxy(self):
        """
        Test we handle correctly entries of the form 'path PROXY'.
        """
        r_python_proxy_data_template = """\
#!"%(executable)s"
# This proxy was created by egginst from an egg with special instructions
#
import sys
import subprocess

src = %(src)r

sys.exit(subprocess.call([src] + sys.argv[1:]))
"""

        with mkdtemp() as prefix:
            pythonexe = os.path.join(prefix, "python.exe")

            proxy_path = os.path.join(
                prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe"
            )
            if PY2:
                proxy_path = proxy_path.decode("utf8")
            r_python_proxy_data = r_python_proxy_data_template % \
                {'executable': pythonexe, 'src': proxy_path}

            runtime_info = self._runtime_info_factory(prefix)
            egginst = EggInst(DUMMY_EGG_WITH_PROXY, runtime_info=runtime_info)

            with ZipFile(egginst.path) as zp:
                egginst.z = zp
                egginst.arcnames = zp.namelist()
                create_proxies(egginst, pythonexe)

                python_proxy = os.path.join(prefix, "Scripts", "swig-script.py")
                coff_proxy = os.path.join(prefix, "Scripts", "swig.exe")

                self.assertTrue(os.path.exists(python_proxy))
                self.assertTrue(os.path.exists(coff_proxy))

                self.assertTrue(compute_md5(coff_proxy),
                                hashlib.md5(exe_data.cli).hexdigest())

                with open(python_proxy, "rt") as fp:
                    python_proxy_data = fp.read()
                    self.assertMultiLineEqual(python_proxy_data,
                                              r_python_proxy_data)
Example #4
0
    def install(self):
        if not isdir(self.meta_dir):
            os.makedirs(self.meta_dir)

        self.z = zipfile.ZipFile(self.fpath)
        self.arcnames = self.z.namelist()

        self.extract()

        scripts.create_proxies(self)

        self.entry_points()
        self.z.close()
        scripts.fix_scripts(self)
        self.run('post_egginst.py')
        self.write_meta()
Example #5
0
    def test_proxy_directory(self):
        """
        Test we handle correctly entries of the form 'path some_directory'.
        """
        with mkdtemp() as prefix:
            with mock.patch("sys.executable", os.path.join(prefix, "python.exe")):
                egginst = EggInst(DUMMY_EGG_WITH_PROXY_SCRIPTS, prefix)
                with ZipFile(egginst.path) as zp:
                    egginst.z = zp
                    egginst.arcnames = zp.namelist()
                    create_proxies(egginst)

                    proxied_files = [
                        os.path.join(prefix, "Scripts", "dummy.dll"),
                        os.path.join(prefix, "Scripts", "dummy.lib"),
                    ]
                    for proxied_file in proxied_files:
                        self.assertTrue(os.path.exists(proxied_file))
Example #6
0
    def test_proxy(self):
        """
        Test we handle correctly entries of the form 'path PROXY'.
        """
        r_python_proxy_data_template = """\
#!"%(executable)s"
# This proxy was created by egginst from an egg with special instructions
#
import sys
import subprocess

src = %(src)r

sys.exit(subprocess.call([src] + sys.argv[1:]))
"""

        with mkdtemp() as prefix:
            with mock.patch("sys.executable", os.path.join(prefix, "python.exe")):
                proxy_path = os.path.join(prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe")
                if PY2:
                    proxy_path = proxy_path.decode("utf8")
                r_python_proxy_data = r_python_proxy_data_template % \
                    {'executable': os.path.join(prefix, "python.exe"),
                     'src': proxy_path}

                egginst = EggInst(DUMMY_EGG_WITH_PROXY, prefix)
                with ZipFile(egginst.path) as zp:
                    egginst.z = zp
                    egginst.arcnames = zp.namelist()
                    create_proxies(egginst)

                    python_proxy = os.path.join(prefix, "Scripts", "swig-script.py")
                    coff_proxy = os.path.join(prefix, "Scripts", "swig.exe")

                    self.assertTrue(os.path.exists(python_proxy))
                    self.assertTrue(os.path.exists(coff_proxy))

                    self.assertTrue(compute_md5(coff_proxy),
                                    hashlib.md5(exe_data.cli).hexdigest())

                    with open(python_proxy, "rt") as fp:
                        python_proxy_data = fp.read()
                        self.assertMultiLineEqual(python_proxy_data,
                                                  r_python_proxy_data)
Example #7
0
    def test_proxy(self):
        """
        Test we handle correctly entries of the form 'path PROXY'.
        """
        r_python_proxy_data_template = """\
#!"{executable}"
# This proxy was created by egginst from an egg with special instructions
#
import sys
import subprocess

src = '{src}'

sys.exit(subprocess.call([src] + sys.argv[1:]))
"""

        with mkdtemp() as prefix:
            with mock.patch("sys.executable", os.path.join(prefix, "python.exe")):
                proxy_path = os.path.join(prefix, "EGG-INFO", "dummy_with_proxy", "usr", "swig.exe")
                r_python_proxy_data = r_python_proxy_data_template.format(
                        executable=os.path.join(prefix, "python.exe"),
                        src=escape_win32_path(proxy_path))

                egginst = EggInst(DUMMY_EGG_WITH_PROXY, prefix)
                with ZipFile(egginst.path) as zp:
                    egginst.z = zp
                    egginst.arcnames = zp.namelist()
                    create_proxies(egginst)

                    python_proxy = os.path.join(prefix, "Scripts", "swig-script.py")
                    coff_proxy = os.path.join(prefix, "Scripts", "swig.exe")

                    self.assertTrue(os.path.exists(python_proxy))
                    self.assertTrue(os.path.exists(coff_proxy))

                    self.assertTrue(md5_file(coff_proxy),
                                    hashlib.md5(exe_data.cli).hexdigest())

                    with open(python_proxy) as fp:
                        python_proxy_data = fp.read()
                        self.assertMultiLineEqual(
                                python_proxy_data,
                                r_python_proxy_data)