Ejemplo n.º 1
0
    def create_prefix_script(self, prefix_path, merge_install):  # noqa: D102
        prefix_env_path = prefix_path / 'local_setup.sh'
        logger.info("Creating prefix script '%s'" % prefix_env_path)
        expand_template(
            Path(__file__).parent / 'template' / 'prefix.sh.em',
            prefix_env_path,
            {
                'prefix_path': prefix_path,
                'python_executable': sys.executable,
                'merge_install': merge_install,
                'package_script_no_ext': 'package',
            })
        shutil.copy(
            str(self._get_prefix_util_path()),
            str(prefix_path / '_local_setup_util.py'))

        prefix_chain_env_path = prefix_path / 'setup.sh'
        logger.info(
            "Creating prefix chain script '%s'" % prefix_chain_env_path)
        expand_template(
            Path(__file__).parent / 'template' / 'prefix_chain.sh.em',
            prefix_chain_env_path,
            {
                'prefix_path': prefix_path,
                'chained_prefix_path': get_chained_prefix_path(
                    skip=prefix_path),
                'prefix_script_no_ext': 'local_setup',
            })
Ejemplo n.º 2
0
    def create_prefix_script(self, prefix_path, merge_install):  # noqa: D102
        prefix_env_path = prefix_path / 'local_setup.bash'
        logger.info(
            "Creating prefix script '{prefix_env_path}'".format_map(locals()))
        expand_template(
            Path(__file__).parent / 'template' / 'prefix.bash.em',
            prefix_env_path,
            {
                'python_executable': sys.executable,
                'merge_install': merge_install,
                'package_script_no_ext': 'package',
            })
        # no need to copy prefix_util.py explicitly since bash relies on sh

        prefix_chain_env_path = prefix_path / 'setup.bash'
        logger.info(
            "Creating prefix chain script '{prefix_chain_env_path}'"
            .format_map(locals()))
        expand_template(
            Path(__file__).parent / 'template' / 'prefix_chain.bash.em',
            prefix_chain_env_path,
            {
                'chained_prefix_path': get_chained_prefix_path(
                    skip=prefix_path),
                'prefix_script_no_ext': 'local_setup',
            })
Ejemplo n.º 3
0
 def create_package_script(  # noqa: D102
         self, prefix_path, pkg_name, hooks):
     pkg_env_path = prefix_path / 'share' / pkg_name / 'package.dsv'
     logger.info("Creating package descriptor '%s'" % pkg_env_path)
     expand_template(
         Path(__file__).parent / 'template' / 'package.dsv.em',
         pkg_env_path, {
             'hooks': hooks,
         })
Ejemplo n.º 4
0
 def create_hook_set_value(
     self, env_hook_name, prefix_path, pkg_name, name, value,
 ):  # noqa: D102
     hook_path = prefix_path / 'share' / pkg_name / 'hook' / \
         ('%s.bat' % env_hook_name)
     logger.info("Creating environment hook '%s'" % hook_path)
     expand_template(
         Path(__file__).parent / 'template' / 'hook_set_value.bat.em',
         hook_path, {'name': name, 'value': value})
     return hook_path
Ejemplo n.º 5
0
 def create_package_script(self, prefix_path, pkg_name,
                           hooks):  # noqa: D102
     pkg_env_path = prefix_path / 'share' / pkg_name / 'package.bat'
     logger.info("Creating package script '%s'" % pkg_env_path)
     expand_template(
         Path(__file__).parent / 'template' / 'package.bat.em',
         pkg_env_path, {
             'hooks':
             list(filter(lambda hook: str(hook[0]).endswith('.bat'),
                         hooks)),
         })
Ejemplo n.º 6
0
    def create_prefix_script(self, prefix_path, merge_install):
        # Use parent of prefix_path to display a pretty workspace name
        workspace_name = 'unknown'
        if len(prefix_path.parts) >= 2:
            workspace_name = prefix_path.parts[-2]

        output_path = prefix_path / 'spawn_shell.bash'
        logger.info("Creating '{output_path}'".format_map(locals()))
        expand_template(
            Path(__file__).parent / 'template' / 'spawn_shell.bash.em',
            output_path, {'workspace_name': workspace_name})
Ejemplo n.º 7
0
 def create_hook_prepend_value(
     self, env_hook_name, prefix_path, pkg_name, name, subdirectory,
 ):  # noqa: D102
     hook_path = prefix_path / 'share' / pkg_name / 'hook' / \
         ('%s.sh' % env_hook_name)
     logger.info("Creating environment hook '%s'" % hook_path)
     expand_template(
         Path(__file__).parent / 'template' / 'hook_prepend_value.sh.em',
         hook_path,
         {
             'name': name,
             'subdirectory': subdirectory,
         })
     return hook_path
Ejemplo n.º 8
0
 def create_package_script(self, prefix_path, pkg_name,
                           hooks):  # noqa: D102
     pkg_env_path = prefix_path / 'share' / pkg_name / 'package.ps1'
     logger.info("Creating package script '{pkg_env_path}'".format_map(
         locals()))
     expand_template(
         Path(__file__).parent / 'template' / 'package.ps1.em',
         pkg_env_path, {
             'pkg_name':
             pkg_name,
             'hooks':
             list(filter(lambda hook: str(hook[0]).endswith('.ps1'),
                         hooks)),
         })
Ejemplo n.º 9
0
 def create_hook_prepend_value(
     self, env_hook_name, prefix_path, pkg_name, name, subdirectory,
 ):  # noqa: D102
     hook_path = prefix_path / 'share' / pkg_name / 'hook' / \
         ('%s.dsv' % env_hook_name)
     logger.info("Creating environment descriptor '%s'" % hook_path)
     expand_template(
         Path(__file__).parent / 'template' / 'hook_prepend_value.dsv.em',
         hook_path,
         {
             'type_': 'prepend-non-duplicate',
             'name': name,
             'value': subdirectory,
         })
     return hook_path
Ejemplo n.º 10
0
 def create_hook_set_value(  # noqa: D102
     self,
     env_hook_name,
     prefix_path,
     pkg_name,
     name,
     value,
 ):
     hook_path = prefix_path / 'share' / pkg_name / 'hook' / \
         ('%s.sh' % env_hook_name)
     logger.info("Creating environment hook '%s'" % hook_path)
     if value == '':
         value = '$COLCON_PREFIX_PATH'
     expand_template(
         Path(__file__).parent / 'template' / 'hook_set_value.sh.em',
         hook_path, {
             'name': name,
             'value': value
         })
     return hook_path
Ejemplo n.º 11
0
    def create_prefix_script(self, prefix_path, merge_install):  # noqa: D102
        prefix_env_path = prefix_path / 'local_setup.bat'
        logger.info("Creating prefix script '%s'" % prefix_env_path)
        expand_template(
            Path(__file__).parent / 'template' / 'prefix.bat.em',
            prefix_env_path, {
                'python_executable': sys.executable,
                'merge_install': merge_install,
                'package_script_no_ext': 'package',
            })

        prefix_util_path = prefix_path / '_local_setup_util_bat.py'
        logger.info("Creating prefix util module '%s'" % prefix_util_path)
        expand_template(self._get_prefix_util_template_path(),
                        prefix_util_path, {'shell_extension': self})

        prefix_chain_env_path = prefix_path / 'setup.bat'
        logger.info("Creating prefix chain script '%s'" %
                    prefix_chain_env_path)
        expand_template(
            Path(__file__).parent / 'template' / 'prefix_chain.bat.em',
            prefix_chain_env_path, {
                'chained_prefix_path':
                get_chained_prefix_path(skip=prefix_path),
                'prefix_script_no_ext': 'local_setup',
            })