Ejemplo n.º 1
0
    def write_scripts(self) -> None:
        from setuptools.command.easy_install import get_script_args

        # Retrieve sandbox_scripts entry points
        e3_distrib = get_distribution("e3-core")

        class SandboxDist:
            def get_entry_map(self, group):  # type: ignore
                if group != "console_scripts":
                    return {}
                return e3_distrib.get_entry_map("sandbox_scripts")

            def as_requirement(self):  # type: ignore
                return e3_distrib.as_requirement()

        for script in get_script_args(dist=SandboxDist()):
            script_name = script[0]
            script_content = script[1]
            target = os.path.join(self.bin_dir, script_name)
            rm(target)
            if not script_name.endswith(".exe"):
                script_content = script_content.replace(
                    "console_scripts", "sandbox_scripts")
            with open(target, "wb") as f:
                if isinstance(script_content, str):
                    f.write(script_content.encode("utf-8"))
                else:
                    f.write(script_content)
            chmod("a+x", target)
Ejemplo n.º 2
0
    def run(self):
        from setuptools.command.easy_install import get_script_args
        from setuptools.command.easy_install import sys_executable

        self.run_command("egg_info")
        if self.distribution.scripts:
            _install_scripts.run(self)  # run first to set up self.outfiles
        else:
            self.outfiles = []
        if self.no_ep:
            # don't install entry point scripts into .egg file!
            return

        ei_cmd = self.get_finalized_command("egg_info")
        dist = Distribution(
            ei_cmd.egg_base,
            PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info),
            ei_cmd.egg_name,
            ei_cmd.egg_version,
        )
        bs_cmd = self.get_finalized_command('build_scripts')
        executable = getattr(bs_cmd, 'executable', sys_executable)
        is_wininst = getattr(self.get_finalized_command("bdist_wininst"),
                             '_is_running', False)
        for args in get_script_args(dist, executable, is_wininst):
            self.write_script(*args)
Ejemplo n.º 3
0
    def run(self, wininst=False):
        # import bbfreeze only thenabout to run the command
        from bbfreeze import Freezer

        # get information from egg_info
        ei = self.get_finalized_command("egg_info")
        target = normalize_path(self.bdist_base)
        dist = Distribution(
            target,
            PathMetadata(target, os.path.abspath(ei.egg_info)),
            project_name=ei.egg_name)

        # install wrapper_Scripts into self.bdist_base == self.script_dir
        self.install_wrapper_scripts(dist)

        # now get a Freezer()
        f = Freezer(os.path.join(self.dist_dir,
                                 "%s-%s" % (ei.egg_name, ei.egg_version)))
        f.include_py = self.include_py

        # freeze each of the scripts
        for args in get_script_args(dist, wininst=wininst):
            name = args[0]
            if name.endswith('.exe') or name.endswith(".exe.manifest"):
                # skip .exes
                continue
            log.info('bbfreezing %s', os.path.join(self.script_dir, name))
            f.addScript(os.path.join(self.script_dir, name),
                        gui_only=name.endswith('.pyw'))
        # starts the freezing process
        f()
Ejemplo n.º 4
0
    def test_get_script_args(self):
        dist = FakeDist()

        args = next(get_script_args(dist))
        name, script = itertools.islice(args, 2)

        assert script == WANTED
Ejemplo n.º 5
0
    def write_scripts(self):
        from setuptools.command.easy_install import get_script_args

        # Retrieve sandbox_scripts entry points
        e3_distrib = get_distribution('e3-core')

        class SandboxDist(object):
            def get_entry_map(self, group):
                if group != 'console_scripts':
                    return {}
                return e3_distrib.get_entry_map('sandbox_scripts')

            def as_requirement(self):
                return e3_distrib.as_requirement()

        for script in get_script_args(dist=SandboxDist()):
            script_name = script[0]
            script_content = script[1]
            target = os.path.join(self.bin_dir, script_name)
            rm(target)
            if not script_name.endswith('.exe'):
                script_content = script_content.replace(
                    'console_scripts', 'sandbox_scripts')
            with open(target, 'wb') as f:
                if isinstance(script_content, unicode):
                    f.write(script_content.encode('utf-8'))  # py3-only
                else:
                    f.write(script_content)  # py2-only
            chmod('a+x', target)
Ejemplo n.º 6
0
    def test_get_script_args(self):
        dist = FakeDist()

        old_platform = sys.platform
        try:
            name, script = get_script_args(dist).next()
        finally:
            sys.platform = old_platform

        self.assertEquals(script, WANTED)
Ejemplo n.º 7
0
    def test_get_script_args(self):
        dist = FakeDist()

        old_platform = sys.platform
        try:
            name, script = [i for i in next(get_script_args(dist))][0:2]
        finally:
            sys.platform = old_platform

        self.assertEqual(script, WANTED)