How to use the hpccm.primitives.environment.environment 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_environment.py View on Github external
def test_single_docker(self):
        """Single environment variable specified"""
        e = environment(variables={'A': 'B'}, _export=False)
        self.assertEqual(str(e), 'ENV A=B')
github NVIDIA / hpc-container-maker / test / test_environment.py View on Github external
def test_single_export_docker(self):
        """Single environment variable specified"""
        e = environment(variables={'A': 'B'})
        self.assertEqual(str(e), 'ENV A=B')
github NVIDIA / hpc-container-maker / test / test_environment.py View on Github external
def test_appenv_multiple_singularity(self):
        """Multiple app-specific environment variables specified"""
        e = environment(variables={'ONE': 1, 'TWO': 2, 'THREE': 3},
                        _app='foo')
        self.assertEqual(str(e),
'''%appenv foo
    export ONE=1
github NVIDIA / hpc-container-maker / hpccm / building_blocks / arm_allinea_studio.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('Arm Allinea Studio version {}'.format(self.__version))

        if self.__ospackages:
            # EPEL necessary for Lmod
            self += packages(epel=True, ospackages=self.__ospackages)

        if self.__tarball:
            self += copy(src=self.__tarball, dest=self.__wd)

        self += shell(commands=self.__commands)
        self += environment(variables=self.environment_step())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / intel_psxe.py View on Github external
self += packages(ospackages=self.__ospackages)
        self += copy(src=self.__tarball,
                     dest=posixpath.join(self.__wd, self.__tarball_name))
        if self.__license and not '@' in self.__license:
            # License file
            self += copy(src=self.__license,
                         dest=posixpath.join(self.__wd, 'license.lic'))
        self += shell(commands=self.__commands)

        if self.__psxevars:
            # Source the mpivars environment script when starting the
            # container, but the variables not be available for any
            # subsequent build steps.
            self += shell(commands=['echo "source {0}/compilers_and_libraries/linux/bin/compilervars.sh intel64" >> {1}'.format(self.__prefix, self.__bashrc)])
        else:
            self += environment(variables=self.environment_step())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / pgi.py View on Github external
def __instructions(self):
        """Fill in container instructions"""

        self += comment('PGI compiler version {}'.format(self.__version))
        if self.__tarball:
            # Use tarball from local build context
            self += copy(src=self.__tarball,
                         dest=posixpath.join(self.__wd,
                                             posixpath.basename(self.__tarball)))
        else:
            # Downloading, so need wget
            self.__ospackages.append('wget')
        if self.__ospackages:
            self += packages(ospackages=self.__ospackages)
        self += shell(commands=self.__commands)
        self += environment(variables=self.environment_step())
github NVIDIA / hpc-container-maker / hpccm / building_blocks / arm_allinea_studio.py View on Github external
self.__prefix,
                'armpl-{0}.0_{1}_{2}_gcc_{3}_aarch64-linux'.format(
                    self.__version, microarch_string[microarch],
                    self.__directory_string, self.__gcc_version),
                'lib')
            paths.append(armpl_gcc_redist_path)
            self.rt += copy(_from=_from,
                            src=[posixpath.join(armpl_gcc_redist_path, lib)
                                 for lib in ['libamath.so',
                                             'libamath_dummy.so',
                                             'libastring.so']],
                            dest=posixpath.join(armpl_gcc_redist_path, ''))

        paths.append('$LD_LIBRARY_PATH') # tack on existing value at end
        self.runtime_environment_variables['LD_LIBRARY_PATH'] = ':'.join(paths)
        self.rt += environment(variables=self.environment_step(runtime=True))

        return str(self.rt)
github NVIDIA / hpc-container-maker / hpccm / building_blocks / nvshmem.py View on Github external
def runtime(self, _from='0'):
        """Generate the set of instructions to install the runtime specific
        components from a build in a previous stage.

        # Examples

        ```python
        n = nvshmem(...)
        Stage0 += n
        Stage1 += n.runtime()
        ```
        """
        self.rt += comment('NVSHMEM')
        if self.__binary_tarball:
            self.rt += copy(_from=_from, src=self.__prefix, dest=self.__prefix)
            self.rt += environment(variables=self.environment_step())
        else:
            self.rt += self.__bb.runtime(_from=_from)
        return str(self.rt)
github NVIDIA / hpc-container-maker / hpccm / building_blocks / generic_autotools.py View on Github external
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 / 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'))})