How to use the hpccm.primitives.shell.shell function in hpccm

To help you get started, we’ve selected a few hpccm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NVIDIA / hpc-container-maker / test / test_shell.py View on Github external
def test_apptest_singularity(self):
        """test option"""
        cmds = ['a', 'b', 'c']
        s = shell(commands=cmds, _app='foo', chdir=False, _test=True)
        self.assertEqual(str(s), '%apptest foo\n    a\n    b\n    c')
github NVIDIA / hpc-container-maker / hpccm / building_blocks / libsim.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('VisIt libsim version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += shell(commands=self.__commands)
        self += environment(variables=self.environment_step())
github NVIDIA / hpc-container-maker / hpccm / primitives / workdir.py View on Github external
def __str__(self):
        """String representation of the primitive"""
        if self.directory:
            if hpccm.config.g_ctype == container_type.DOCKER:
                return 'WORKDIR {}'.format(self.directory)
            elif hpccm.config.g_ctype == container_type.SINGULARITY:
                s = shell(commands=['mkdir -p {}'.format(self.directory),
                                    'cd {}'.format(self.directory)])
                return str(s)
            elif hpccm.config.g_ctype == container_type.BASH:
                logging.warning('workdir primitive does not map into bash')
                return ''
            else:
                raise RuntimeError('Unknown container type')
        else:
            logging.error('No directory specified')
            return ''
github NVIDIA / hpc-container-maker / hpccm / building_blocks / ofed.py View on Github external
# Examples

        ```python
        o = ofed(...)
        Stage0 += o
        Stage1 += o.runtime()
        ```
        """
        if self.__prefix:
            self.rt += comment('OFED')

            if self.__deppackages:
                self.rt += packages(ospackages=self.__deppackages)

            # Suppress warnings from libibverbs
            self.rt += shell(commands=['mkdir -p /etc/libibverbs.d'])

            self.rt += copy(_from=_from, dest=self.__prefix, src=self.__prefix)
            return str(self.rt)
        else:
            return str(self)
github NVIDIA / hpc-container-maker / hpccm / building_blocks / libsim.py View on Github external
```python
        l = libsim(...)
        Stage0 += l
        Stage1 += l.runtime()
        ```
        """
        self.rt += comment('VisIt libsim')
        if self.__runtime_ospackages:
            self.rt += packages(ospackages=self.__runtime_ospackages)
        self.rt += copy(_from=_from, src=self.__prefix, dest=self.__prefix)
        if self.ldconfig:
            libpath = posixpath.join(self.__prefix, self.__version,
                                     self.__arch)
            suffix1 = 'lib'
            suffix2 = posixpath.join('libsim', 'V2', 'lib')
            self.rt += shell(commands=[
                self.ldcache_step(
                    directory=posixpath.join(libpath, suffix1)),
                self.ldcache_step(
                    directory=posixpath.join(libpath, suffix2))])
        self.rt += environment(variables=self.environment_step())
        return str(self.rt)
github NVIDIA / hpc-container-maker / hpccm / building_blocks / mlnx_ofed.py View on Github external
if self.__prefix:
            commands = []
            if self.__symlink:
                commands.append('mkdir -p {0} && cd {0}'.format(
                    posixpath.join(self.__prefix, 'lib')))
                # Prune the symlink directory itself and any debug
                # libraries
                commands.append('find .. -path ../lib -prune -o -name "*valgrind*" -prune -o -name "lib*.so*" -exec ln -s {} \;')
                commands.append('cd {0} && ln -s usr/bin bin && ln -s usr/include include'.format(
                    self.__prefix))

            # Suppress warnings from libibverbs
            commands.append('mkdir -p /etc/libibverbs.d')

            self += shell(commands=commands)

        self += label(metadata=self.annotate_step())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_autotools.py View on Github external
```python
        g = generic_autotools(...)
        Stage0 += g
        Stage1 += g.runtime()
        ```
        """
        if self.prefix:
            if self.__comment:
                if self.url:
                    self.rt += comment(self.url, reformat=False)
                elif self.repository:
                    self.rt += comment(self.repository, reformat=False)
            self.rt += copy(_from=_from, src=self.prefix, dest=self.prefix)
            if self.ldconfig:
                self.rt += shell(commands=[self.ldcache_step(
                    directory=posixpath.join(self.prefix, self.__libdir))])
            if self.runtime_environment_variables:
                self.rt += environment(
                    variables=self.environment_step(runtime=True))
            if self.annotate:
                self.rt += label(metadata=self.annotate_step())
            return str(self.rt)
        else: # pragma: no cover
            return
github NVIDIA / hpc-container-maker / hpccm / building_blocks / boost.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('Boost version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += shell(commands=self.__commands)
        self += environment(variables=self.environment_step())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / cmake.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('CMake version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += shell(commands=self.__commands)
        self += environment(variables={'PATH': '{}:$PATH'.format(
            posixpath.join(self.__prefix, 'bin'))})
github NVIDIA / hpc-container-maker / hpccm / building_blocks / julia.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('Julia version {}'.format(self.__version))
        self += packages(ospackages=self.__ospackages)
        self += shell(commands=self.__commands)
        self += environment(variables=self.environment_step())